Fix critical bug: Add missing is_ip_blocked function
CRITICAL BUG FIX: Auto-blocking and Quick Actions were not working Problem: - Code called is_ip_blocked() function that didn't exist - Function failures caused silent errors (2>/dev/null) - Result: IPs with score 100 were NOT auto-blocked - Result: Quick Actions never showed any IPs to block - Auto-mitigation engine was completely broken Solution: - Added is_ip_blocked() function with dual checking: 1. CSF deny list check (csf -g) 2. iptables direct check (iptables -L) - Returns 0 (blocked) or 1 (not blocked) Impact: - Auto-blocking now works at score >= 80 - Quick Actions now shows IPs with score >= 60 - Users can see and manually block medium threats - Auto-mitigation engine now functional This was preventing ALL blocking functionality from working
This commit is contained in:
@@ -690,6 +690,27 @@ calculate_context_bonus() {
|
||||
echo "${bonus}|${reasons}"
|
||||
}
|
||||
|
||||
# Check if IP is currently blocked in CSF/iptables
|
||||
is_ip_blocked() {
|
||||
local ip="$1"
|
||||
|
||||
# Check CSF deny list
|
||||
if command -v csf &>/dev/null; then
|
||||
if csf -g "$ip" 2>/dev/null | grep -q "DENY"; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check iptables directly
|
||||
if command -v iptables &>/dev/null; then
|
||||
if iptables -L -n 2>/dev/null | grep -q "$ip"; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# Get threat level from score
|
||||
get_threat_level() {
|
||||
local score="$1"
|
||||
|
||||
Reference in New Issue
Block a user