8a154753bd
ISSUE: The SYN/ESTABLISHED ratio detection calculates a ratio value inside the skip_scoring block but uses it later in the intel_tags logic OUTSIDE the block. When skip_scoring=1 (whitelisted IP), the ratio variable is never initialized. ROOT CAUSE: Similar to BUG #10 (multi_vector, geo_bonus), the ratio variable was declared as 'local' INSIDE the skip_scoring conditional block (line 2814), but referenced at line 3030 which is OUTSIDE the block: - Line 2814: local ratio=$((count * 10 / established_conns)) [INSIDE skip_scoring] - Line 3030: [ "${ratio:-0}" -ge 30 ] && intel_tags="..." [OUTSIDE skip_scoring] IMPACT: - Whitelisted IPs: BAD-RATIO tag never shown (even if suspicious ratio exists) - For skip_scoring=1 IPs, ratio defaults to 0 via ${ratio:-0} - Intel tags incomplete for whitelisted IPs with bad SYN/ESTABLISHED ratios - Threat assessment missing important ratio indicator BEHAVIOR WITH BUG: 1. When skip_scoring=0: ratio is calculated and used (works) 2. When skip_scoring=1: ratio never initialized - [ "${ratio:-0}" -ge 30 ] → [ "${:-0}" -ge 30 ] → always false - BAD-RATIO tag not added to intel_tags - Misleading threat summary for whitelisted IPs FIX: Move ratio variable declaration OUTSIDE skip_scoring block (before line 2755). Initialize to 0 like the other variables (multi_vector, geo_bonus). Remove duplicate declaration inside skip_scoring block. Result: ratio is always initialized and available for intel_tags logic. LINES CHANGED: - Added: local ratio=0 declaration before skip_scoring block - Removed: local ratio=... from line 2814 - Changed: local ratio= to just ratio= on line 2814 VERIFICATION: - Syntax: ✓ Pass - Scope: ✓ Variable available both inside and outside skip_scoring - Logic: ✓ Consistent with other scope-dependent variables Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>