fix: incorrect decision pulling from CrowdSec locally
This commit is contained in:
1 parent
d91cfc7e1f
commit
82352110a4
1 file changed
+12
-5
+12
-5
@@ -21,11 +21,18 @@ class FirewallAuditor:
|
|||||||
res = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
res = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
||||||
data = json.loads(res.stdout) or []
|
data = json.loads(res.stdout) or []
|
||||||
|
|
||||||
return {
|
truth_map = {}
|
||||||
d["value"]: d.get("duration")
|
for item in data:
|
||||||
for d in data
|
# cscli JSON can be a list of alerts, each containing a list of decisions
|
||||||
if isinstance(d, dict) and d.get("origin") != "CAPI"
|
decisions = item.get('decisions', [])
|
||||||
}
|
for d in decisions:
|
||||||
|
val = d.get('value')
|
||||||
|
# Filter: must have a value, must not be CAPI
|
||||||
|
if val and d.get('origin') != 'CAPI':
|
||||||
|
truth_map[val] = d.get('duration')
|
||||||
|
|
||||||
|
logging.info(f"LAPI Local Parser: Found {len(truth_map)} active bans.")
|
||||||
|
return truth_map
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Failed to get LAPI truth: {e}")
|
logging.error(f"Failed to get LAPI truth: {e}")
|
||||||
return {}
|
return {}
|
||||||
|
|||||||
Reference in new issue
Block a user