From c5239bd93947ecba51d697cd629ab9136e26f8cd Mon Sep 17 00:00:00 2001 From: Developer Date: Tue, 21 Apr 2026 21:17:58 -0400 Subject: [PATCH] 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 --- modules/security/malware-scanner.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/security/malware-scanner.sh b/modules/security/malware-scanner.sh index d919651..383a578 100755 --- a/modules/security/malware-scanner.sh +++ b/modules/security/malware-scanner.sh @@ -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