Fix arithmetic syntax error in analyze_all_domains

Problem:
- Line 220: syntax error in expression (error token is "0")
- grep -c returns "0" on no match, but || echo "0" was still appending
- Result: Variables contained "0\n0" causing arithmetic errors

Fix:
- Changed || echo "0" to || true
- Added default value assignment: ${var:-0}
- Ensures counts are always single integers

Lines fixed: 215-224
This commit is contained in:
cschantz
2025-12-03 01:27:25 -05:00
parent 083d0c5b8b
commit 4cd5f8ddb1
+10 -4
View File
@@ -212,10 +212,16 @@ analyze_all_domains() {
# Count issues by severity # Count issues by severity
local critical_count high_count medium_count low_count local critical_count high_count medium_count low_count
critical_count=$(echo "$issues" | grep -c "^[^|]*|CRITICAL|" || echo "0") critical_count=$(echo "$issues" | grep -c "^[^|]*|CRITICAL|" || true)
high_count=$(echo "$issues" | grep -c "^[^|]*|HIGH|" || echo "0") high_count=$(echo "$issues" | grep -c "^[^|]*|HIGH|" || true)
medium_count=$(echo "$issues" | grep -c "^[^|]*|MEDIUM|" || echo "0") medium_count=$(echo "$issues" | grep -c "^[^|]*|MEDIUM|" || true)
low_count=$(echo "$issues" | grep -c "^[^|]*|LOW|" || echo "0") low_count=$(echo "$issues" | grep -c "^[^|]*|LOW|" || true)
# Default to 0 if empty
critical_count=${critical_count:-0}
high_count=${high_count:-0}
medium_count=${medium_count:-0}
low_count=${low_count:-0}
local total_issues=$((critical_count + high_count + medium_count + low_count)) local total_issues=$((critical_count + high_count + medium_count + low_count))