From a7afe20536d971309abfd59afacdebca0b566e11 Mon Sep 17 00:00:00 2001 From: cschantz Date: Fri, 21 Nov 2025 17:52:49 -0500 Subject: [PATCH] CRITICAL: Fix bot-analyzer parse_logs output redirection bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ROOT CAUSE: The parse_logs function used a pipeline with while-loop that ran in a subshell: find ... | while read -r logfile; do awk ... "$logfile" done > "$TEMP_DIR/parsed_logs.txt" The redirect (> file) was OUTSIDE the loop, so it captured nothing from the subshell. This caused "No log entries were parsed" error even though logs were being processed. THE BUG: Lines 325-401: Output from awk inside while-loop was lost because the redirect happened after the subshell closed. THE FIX: Wrapped the entire find|while block in a command group {}: { find ... | while read -r logfile; do awk ... "$logfile" done } > "$TEMP_DIR/parsed_logs.txt" Now the redirect captures all output from the command group, including the subshell output. IMPACT: Bot-analyzer can now successfully parse InterWorx, cPanel, and Plesk logs. This was a blocking bug preventing ALL log analysis from working. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- modules/security/bot-analyzer.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/security/bot-analyzer.sh b/modules/security/bot-analyzer.sh index bf5819a..d401bee 100755 --- a/modules/security/bot-analyzer.sh +++ b/modules/security/bot-analyzer.sh @@ -322,6 +322,7 @@ parse_logs() { local file_count=0 local progress_interval=50 echo "" + { find "$log_search_path" -type f -name "$log_search_name" ! -name "*-bytes_log" ! -name "*.offset" ! -name "*error_log" "${find_opts[@]}" 2>/dev/null | while read -r logfile; do # Skip empty files [ -s "$logfile" ] || continue @@ -398,7 +399,8 @@ parse_logs() { print ip "|" domain "|" request_url "|" status "|" size "|" user_agent "|" http_method "|" timestamp } }' "$logfile" 2>/dev/null - done > "$TEMP_DIR/parsed_logs.txt" + done + } > "$TEMP_DIR/parsed_logs.txt" # Clear the progress line echo -ne "\r\033[K"