Fix metadata-drift healing by flushing CrowdSec nft sets before restart

Add drift-aware heal path in FirewallAuditor to remediate metadata drift by discovering and flushing
  *-cscli sets in crowdsec/crowdsec6 tables, then restarting the bouncer.

Update execute_heal_and_verify to pass drift context to heal_with_drift when supported, keeping
  backward compatibility via heal().

Add unit tests covering metadata-drift flush+restart behavior, non-metadata restart-only behavior,
  and drift context propagation.
This commit is contained in:
patrick committed 2026-02-25 14:59:44 -05:00
1 parent 28267a0cf4
commit 0f7f03f005
4 files changed
+122 -2

No files matched your search

+4 -1
View File
@@ -48,7 +48,10 @@ def execute_heal_and_verify(auditor, reporter, count, drift, heal_verify_delay):
"""
Executes heal + post-heal verification and persists reporter state.
"""
heal_ok = auditor.heal()
if hasattr(auditor, "heal_with_drift"):
heal_ok = auditor.heal_with_drift(drift or {})
else:
heal_ok = auditor.heal()
heal_result = "restart_failed"
post_drift = {
"reason": "not_verified",