From 9a98f4b25198b9f0d974179e4a8a590789484d49 Mon Sep 17 00:00:00 2001 From: cschantz Date: Fri, 9 Jan 2026 16:28:28 -0500 Subject: [PATCH] Fix remaining ESCAPE issues in rate anomaly detector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added -- separator to awk commands (3 more fixes at lines 76, 101, 185) - Total of 6 ESCAPE fixes in this file 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- lib/rate-anomaly-detector.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rate-anomaly-detector.sh b/lib/rate-anomaly-detector.sh index 0081573..e2e284f 100644 --- a/lib/rate-anomaly-detector.sh +++ b/lib/rate-anomaly-detector.sh @@ -73,7 +73,7 @@ detect_rate_anomaly() { # Cleanup old entries (keep last 60 seconds only) if [ -f "$rate_file" ]; then - awk -v cutoff="$((current_time - 60))" '$1 > cutoff' "$rate_file" > "${rate_file}.tmp" 2>/dev/null + awk -v cutoff="$((current_time - 60))" '$1 > cutoff' -- "$rate_file" > "${rate_file}.tmp" 2>/dev/null mv "${rate_file}.tmp" "$rate_file" 2>/dev/null fi @@ -98,7 +98,7 @@ analyze_request_pattern() { local cutoff=$((current_time - window)) # Get timestamps in window - local timestamps=$(awk -v cutoff="$cutoff" '$1 > cutoff {print $1}' "$rate_file" 2>/dev/null | sort -n) + local timestamps=$(awk -v cutoff="$cutoff" '$1 > cutoff {print $1}' -- "$rate_file" 2>/dev/null | sort -n) local total_count=$(echo "$timestamps" | wc -l) if [ "$total_count" -lt 5 ]; then @@ -182,7 +182,7 @@ get_current_rate() { local current_time=$(date +%s) local cutoff=$((current_time - window)) - local count=$(awk -v cutoff="$cutoff" '$1 > cutoff' "$rate_file" 2>/dev/null | wc -l) + local count=$(awk -v cutoff="$cutoff" '$1 > cutoff' -- "$rate_file" 2>/dev/null | wc -l) # Calculate requests per second local rate=$((count / window))