Fix ESCAPE issues in rate anomaly detector

- Added -- separator to awk commands (3 fixes at lines 36-38)
- Prevents filename injection attacks

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
cschantz
2026-01-09 16:26:04 -05:00
parent 630cea7cb7
commit 886a1af35e
+3 -3
View File
@@ -33,9 +33,9 @@ detect_rate_anomaly() {
fi fi
# Count requests in different time windows # Count requests in different time windows
local req_1sec=$(awk -v cutoff="$((current_time - 1))" '$1 > cutoff' "$rate_file" 2>/dev/null | wc -l) local req_1sec=$(awk -v cutoff="$((current_time - 1))" '$1 > cutoff' -- "$rate_file" 2>/dev/null | wc -l)
local req_10sec=$(awk -v cutoff="$((current_time - 10))" '$1 > cutoff' "$rate_file" 2>/dev/null | wc -l) local req_10sec=$(awk -v cutoff="$((current_time - 10))" '$1 > cutoff' -- "$rate_file" 2>/dev/null | wc -l)
local req_60sec=$(awk -v cutoff="$((current_time - 60))" '$1 > cutoff' "$rate_file" 2>/dev/null | wc -l) local req_60sec=$(awk -v cutoff="$((current_time - 60))" '$1 > cutoff' -- "$rate_file" 2>/dev/null | wc -l)
local anomaly_score=0 local anomaly_score=0
local anomaly_type="NORMAL" local anomaly_type="NORMAL"