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:
1 parent
28267a0cf4
commit
0f7f03f005
4 files changed
+122
-2
No files matched your search
@@ -18,10 +18,15 @@ class FakeAuditor:
|
||||
def __init__(self, heal_ok=True, reconcile_result=None):
|
||||
self.heal_ok = heal_ok
|
||||
self.reconcile_result = reconcile_result
|
||||
self.last_heal_drift = None
|
||||
|
||||
def heal(self):
|
||||
return self.heal_ok
|
||||
|
||||
def heal_with_drift(self, drift):
|
||||
self.last_heal_drift = drift
|
||||
return self.heal_ok
|
||||
|
||||
def reconcile(self):
|
||||
return self.reconcile_result
|
||||
|
||||
@@ -72,6 +77,7 @@ class PostHealVerificationTests(unittest.TestCase):
|
||||
self.assertEqual("success", heal_result)
|
||||
self.assertEqual(post_drift, returned_post_drift)
|
||||
self.assertEqual([(True, 12, None)], reporter.update_calls)
|
||||
self.assertEqual({"fingerprint": "pre123"}, auditor.last_heal_drift)
|
||||
|
||||
@patch("healing.time.sleep", return_value=None)
|
||||
def test_execute_heal_and_verify_restart_failed(self, _sleep):
|
||||
|
||||
Reference in new issue
Block a user