Fix: Add error handling to generate_client_report scan info extraction
ISSUE: Lines 3404-3405 used pipes with grep -v without error handling. With set -o pipefail enabled, if grep -v returns no matches (exit code 1), the entire command substitution would fail. CONTEXT: generate_client_report() function at line 3389, called by main scan logic to generate client-facing reports after scan completion. FIXES: - Line 3404: Added || echo "Unknown" fallback to scan_date extraction - Line 3405: Added || echo "/" fallback to scan_paths extraction Ensures variables are always initialized even if patterns don't match. Maintains consistent error handling with similar code at line 2197. VERIFIED: bash -n syntax check passes
This commit is contained in:
@@ -3401,8 +3401,8 @@ generate_client_report() {
|
||||
|
||||
# Extract scan info
|
||||
local session_name=$(basename "$scan_dir")
|
||||
local scan_date=$(grep "Started:" "$summary_file" | head -1 | sed 's/Started: //')
|
||||
local scan_paths=$(sed -n '/^Paths:/,/^$/p' "$summary_file" | tail -n +2 | grep -v "^$" | tr '\n' ', ' | sed 's/, $//')
|
||||
local scan_date=$(grep "Started:" "$summary_file" | head -1 | sed 's/Started: //' || echo "Unknown")
|
||||
local scan_paths=$(sed -n '/^Paths:/,/^$/p' "$summary_file" | tail -n +2 | grep -v "^$" | tr '\n' ', ' | sed 's/, $//' || echo "/")
|
||||
|
||||
# Count threats
|
||||
local total_threats=0
|
||||
|
||||
Reference in New Issue
Block a user