Commit Graph
66 Commits
Author SHA1 Message Date
patrickandClaude Opus 5.5 e76e957282 fix(auditor): report range decisions the kernel can't enforce instead of healing
CI / Unit tests (push) Successful in 3s
CI / Unit tests (pull_request) Successful in 7s
A LAPI range decision (e.g. 195.178.110.0/24) inserted into an nft set
without the interval flag is stored as its bare network address. The
string diff saw that as one missing and one extra entry, and every heal
re-added the same address, so nodes stuck in DESYNC_DETECTED with the
flap guard suppressing repeat heals.

Pair such ranges with their network address, report them as
unenforceable_ranges with a dedicated warning, and keep them out of the
drift counts and fingerprint. The reporter records
unenforceable_range_count and shows DEGRADED for a node that is
otherwise in sync. Desync log lines now name the missing and extra
values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 09:43:46 -04:00
patrick 57ed6cfc1c Merge pull request 'fix(auditor): don't heal when the LAPI is unreachable' (#4) from fix/lapi-unreachable-no-heal into main
CI / Unit tests (push) Successful in 2s
Reviewed-on: #4
2026-10-21 20:51:26 +00:00
patrickandClaude Opus 5.5 8c8be8ec63 fix(auditor): don't heal when the LAPI is unreachable
CI / Unit tests (push) Successful in 4s
CI / Unit tests (pull_request) Successful in 3s
get_remote_lapi_truth() returned {} when 'cscli decisions list' failed, which is
indistinguishable from "no active bans". reconcile() then saw every kernel ban as extra,
reported membership_mismatch, and the heal restarted crowdsec-firewall-bouncer. A LAPI
outage would do that on every node at once, every heal interval.

Raise LapiUnavailableError instead. reconcile() propagates it, so the main loop records
it as last_error and retries in 60s without healing; post-heal verification records it
as verify_error. A genuinely empty decision list still returns {} as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 16:47:48 -04:00
patrick cb2a88917c Merge pull request 'feat(reporter): count heals the gate suppresses' (#3) from feat/count-suppressed-heals into main
CI / Unit tests (push) Successful in 3s
Reviewed-on: #3
2026-10-19 22:10:31 +00:00
patrickandClaude Opus 5.5 4e8a4d6717 feat(reporter): count heals the gate suppresses
CI / Unit tests (push) Successful in 4s
CI / Unit tests (pull_request) Successful in 3s
A drift whose fingerprint matches a heal from the last heal_min_interval
seconds was counted as a drift event but never as a heal attempt, so the
24h counters showed a drift with no heal and no failure. Decide on the
heal before recording the check and report heals_suppressed_24h and
heals_suppressed_total, so every drift event is either a heal attempt
or a suppressed heal. The suppression warning now names the earlier
heal that did not hold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 18:04:24 -04:00
patrick 02ca338eb7 Merge pull request 'Add Gitea Actions CI for all branches' (#2) from ci/gitea-actions into main
CI / Unit tests (push) Successful in 4s
Reviewed-on: #2
2026-10-15 00:53:40 +00:00
patrick 73d5112afe Fix CI Python setup with an explicit Ubuntu job image
CI / Unit tests (push) Successful in 3s
CI / Unit tests (pull_request) Successful in 4s
2026-10-14 20:52:20 -04:00
patrick b236611044 Add Gitea Actions CI for all branches
CI / Unit tests (push) Failing after 14s
2026-10-14 20:49:25 -04:00
patrick 053991669b Merge pull request 'fix: replace shorter CrowdSec bans instead of adding beside them' (#1) from fix/multi-set-ttl-drift into main
Reviewed-on: #1
2026-10-14 20:29:00 +00:00
patrickandClaude Opus 5.5 772892b78d feat(healing): re-check membership mismatches before healing
A decision created moments before an audit shows up as missing=1 until
the bouncer's next poll, which triggered a bouncer restart for nothing.

When the audit finds a membership mismatch, wait membership_recheck_delay
seconds (default 30, 0 disables) and audit again; only drift that is still
present is reported and healed. Metadata drift is not delayed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 19:38:39 -04:00
patrickandClaude Opus 5.5 79f72512e4 fix(auditor): use longest kernel expiry for IPs in multiple sets
The bouncer keeps one nft set per decision origin, so an IP with both a
crowdsec ban and a later, longer cscli ban sits in two sets. The kernel
scan kept whichever set it read last, so the short TTL could be compared
against the longest LAPI decision and reported as metadata drift.

Keep the longest expiry per IP instead, and log per-IP evidence (expected
vs kernel seconds, source sets, LAPI decisions) whenever drift is flagged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 19:27:59 -04:00
patrick 9d68d1f4b4 docs(readme): rewrite project overview and operating model 2026-04-04 20:30:47 -04:00
patrick f5615faeae fix(healing): normalize history timestamps to UTC in heal flap gate 2026-03-06 22:31:24 -05:00
patrick 1013b05790 fix(reporter): emit UTC-aware timestamps for state and heal history 2026-03-06 19:22:25 -05:00
patrick ecda631049 fix(reporter): refresh last_heal_timestamp on every heal result 2026-03-06 18:43:34 -05:00
patrick 469a30df6a feat(reporter): add rolling 24h drift/heal counters to state snapshot 2026-03-06 17:38:42 -05:00
patrick 8c7b0768b0 feat(reporter): add drift event and heal-attempt counters to state snapshot 2026-03-05 21:28:25 -05:00
patrick a2030a71b7 feat(reporter): track last_heal_timestamp in state snapshot 2026-03-05 21:03:56 -05:00
patrick 3b1e25d5cd feat(reporter): add uptime and fleet counters to state snapshot 2026-03-05 20:57:16 -05:00
patrick 7f323ed78b feat(config): validate runtime settings at boot and fail fast on critical errors 2026-03-05 20:55:00 -05:00
patrick be92bb2493 feat(agent): add --doctor preflight self-test mode with structured checks 2026-03-05 20:49:37 -05:00
patrick d2fdd5be44 feat(main): add bounded randomized check-interval jitter across nodes 2026-03-05 20:39:22 -05:00
patrick b34ac69ac1 feat(reporter): persist drift metrics and last heal result in state snapshot 2026-03-05 20:35:18 -05:00
patrick c698d01c40 feat(auditor): add startup enforcement sanity check and dedupe set-mismatch warnings 2026-03-05 20:32:29 -05:00
patrick 389f310f24 chore(config): align enforcement set names with live CrowdSec nft sets 2026-03-05 20:28:52 -05:00
patrick 172f5d7ced fix(auditor): fail open when configured enforcement sets do not match nft state 2026-03-05 20:23:00 -05:00
patrick bffe28485d feat(config): enforce runtime nft targets and managed sets from config.yaml 2026-03-05 20:19:31 -05:00
patrick 3c6c4e384b fix(main,reporter): handle SIGTERM gracefully and normalize history file path 2026-03-05 20:12:17 -05:00
patrick 9b53a4c491 fix(healing): handle post-heal verify exceptions without crashing loop 2026-03-01 21:14:59 -05:00
patrick 9edce6b31d perf(healing): scan heal history from file tail instead of full read
- add tail-based HEAL line lookup to avoid O(file-size) reads in should_heal()
- keep a safe fallback full scan when no HEAL marker is found in tail window
- add regression test for large history files with recent HEAL marker
2026-03-01 21:12:55 -05:00
patrick 55cc29071e Add nft handle fallback when flushing CrowdSec sets with slash-based names 2026-02-26 14:14:20 -05:00
patrick 716468901c Harden metadata heal across nft table variants and non-fatal flush errors 2026-02-26 13:37:48 -05:00
patrick aae920fb73 fix: metadata drift false positives - corrected by normalizing nft TTL and skipping unverifiable expiry 2026-02-25 15:02:24 -05:00
patrick 0f7f03f005 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.
2026-02-25 14:59:44 -05:00
patrick 28267a0cf4 fix(auditor): heal on decision-duration drift, not just IP membership/count 2026-02-23 22:20:16 -05:00
patrick 480eea8095 refactor(agent): split orchestration into config, healing, and main modules 2026-02-10 22:11:33 -05:00
patrick 5fc5b8c114 test(agent): add coverage for drift gating and post-heal verification; remove bare except 2026-02-10 22:04:57 -05:00
patrick 461512f20a feat(config): wire runtime settings from env/config with sane defaults 2026-02-10 22:01:17 -05:00
patrick 6dac06c117 docs(readme): sync architecture and runtime flow with current agent behavior 2026-02-10 21:57:11 -05:00
patrick 234224a5c6 feat(healing): add post-restart verification and heal outcome telemetry 2026-02-10 21:55:43 -05:00
patrick b2c489602a fix(paths): switch agent log and state defaults 2026-02-10 21:53:41 -05:00
patrick e342d83a70 fix(reconcile): gate heal flapping by drift fingerprint instead of kernel count 2026-02-10 21:48:50 -05:00
patrick 3d7c1b3f2a fix(auditor): support flat and nested cscli decision JSON parsing 2026-02-10 21:45:37 -05:00
patrick 82352110a4 fix: incorrect decision pulling from CrowdSec locally 2026-01-25 22:49:19 -05:00
patrick d91cfc7e1f fix: file dir edit for state_file after merge with other branch 2026-01-26 03:33:01 +00:00
patrick 6e98117126 fix: add cscli decision list check for LAPI threat-agent 2026-01-26 03:30:42 +00:00
patrick 6f180753f2 fix: file dir update 2026-01-26 03:24:07 +00:00
patrick f0a70273d3 fix: quick node name update 2026-01-26 03:22:02 +00:00
patrick 42c25c145e fix: finalize merge with agent-node branch 2026-01-26 03:14:46 +00:00
patrick 9977a0d8cf fix: add *.log* to .gitignore 2026-01-26 03:12:21 +00:00