Fix remaining AWK-UNINIT issues in bot-analyzer and network analysis
modules/security/bot-analyzer.sh: - Line 863: Initialize ip="" for rapid fire IP analysis - Line 1564: Initialize variables in bot detection awk modules/performance/network-bandwidth-analyzer.sh: - Line 237: Initialize sum=0 for bandwidth calculation modules/security/optimize-ct-limit.sh: - Line 244: Initialize s=0 for request aggregation Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -860,7 +860,7 @@ detect_botnets() {
|
||||
sort | uniq -c | \
|
||||
awk '$1 > 50 {print $1 " " $2}' | \
|
||||
awk -F'|' '{print $1}' | \
|
||||
awk '{ip=$2; count=$1; sum[ip]+=count; max[ip]=(count>max[ip]?count:max[ip])} END {for(ip in sum) print sum[ip], ip, max[ip]}' | \
|
||||
awk 'BEGIN {ip=""} {ip=$2; count=$1; sum[ip]+=count; max[ip]=(count>max[ip]?count:max[ip])} END {for(ip in sum) print sum[ip], ip, max[ip]}' | \
|
||||
sort -rn > "$TEMP_DIR/rapid_fire_ips.txt"
|
||||
|
||||
print_success "Botnet analysis complete"
|
||||
@@ -1560,8 +1560,8 @@ generate_report() {
|
||||
echo "2. Top Aggressive Bots:"
|
||||
counter=1
|
||||
while read -r line && [ "${counter:-0}" -le 5 ]; do
|
||||
count=$(echo "$line" | awk '{print $1}')
|
||||
bot=$(echo "$line" | awk '{$1=""; print $0}' | xargs)
|
||||
count=$(echo "$line" | awk 'BEGIN {count=0} {print $1}')
|
||||
bot=$(echo "$line" | awk 'BEGIN {f=""} {$1=""; print $0}' | xargs)
|
||||
|
||||
action="Allow"
|
||||
if echo "$bot" | grep -qiE "ahrefs|semrush|dotbot|blex|megaindex"; then
|
||||
|
||||
@@ -241,7 +241,7 @@ analyze_per_site_traffic() {
|
||||
if [ -n "$domain_data" ]; then
|
||||
max_conn=$(echo "$domain_data" | cut -d'|' -f3 | sort -rn | head -1)
|
||||
total_ips=$(echo "$domain_data" | cut -d'|' -f1 | sort -u | wc -l)
|
||||
total_requests=$(echo "$domain_data" | cut -d'|' -f4 | awk '{s+=$1} END {print s}')
|
||||
total_requests=$(echo "$domain_data" | cut -d'|' -f4 | awk 'BEGIN {s=0} {s+=$1} END {print s}')
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user