Bans an admin makes or lifts: the admin cause, a reason, lifted bans kept #88

Merged
clawbot merged 1 commits from issue-86-admin-bans into next 2026-10-06 23:09:53 +02:00
Collaborator

Implements #86.

  • A bans.json entry without a cause gets admin, at the start or from an edit, and is written back so.
  • Bans whose cause is admin are never dropped and do not count toward SWWAF_MAX_BANS. The ledger drops the earliest ban smallwebwaf made of the netblock seen longest ago, passing over netblocks holding only an admin's bans and looking at each netblock once at most, so the netblocks' LRU no longer has a size limit of its own.
  • reason: set on the bans the ledger makes, such as requests per minute over the limit of 1000 or matched the rule env-file; an admin's is kept.
  • lifted: the ban refuses nothing, is kept, and makes no later ban longer or permanent. The active and permanent ban gauges leave it out.
  • smallwebwaf_bans_made_total{cause="admin"} counts admin bans an edit adds while running, new by netblock and start. Bans read at the start are not counted, hence LoadEdit beside Load.
  • earlier_bans counts admin in place of without_cause.
  • README.md shows adding, keeping and lifting a ban in bans.json.

Disclosures:

  • Judgement call: lifted lifts at once, whatever time it gives.
  • Judgement call: a lifted ban still counts in earlier_bans.
  • Known gap: a ban dropped from behind an admin's ban on its netblock drops out of that netblock's later earlier_bans; keeping it needs a per-netblock count of dropped bans.

Model: opus-5-5

Implements https://git.eeqj.de/sneak/smallwebwaf/issues/86. - A `bans.json` entry without a `cause` gets `admin`, at the start or from an edit, and is written back so. - Bans whose cause is `admin` are never dropped and do not count toward `SWWAF_MAX_BANS`. The ledger drops the earliest ban `smallwebwaf` made of the netblock seen longest ago, passing over netblocks holding only an admin's bans and looking at each netblock once at most, so the netblocks' LRU no longer has a size limit of its own. - `reason`: set on the bans the ledger makes, such as `requests per minute over the limit of 1000` or `matched the rule env-file`; an admin's is kept. - `lifted`: the ban refuses nothing, is kept, and makes no later ban longer or permanent. The active and permanent ban gauges leave it out. - `smallwebwaf_bans_made_total{cause="admin"}` counts admin bans an edit adds while running, new by netblock and start. Bans read at the start are not counted, hence `LoadEdit` beside `Load`. - `earlier_bans` counts `admin` in place of `without_cause`. - `README.md` shows adding, keeping and lifting a ban in `bans.json`. Disclosures: - Judgement call: `lifted` lifts at once, whatever time it gives. - Judgement call: a lifted ban still counts in `earlier_bans`. - Known gap: a ban dropped from behind an admin's ban on its netblock drops out of that netblock's later `earlier_bans`; keeping it needs a per-netblock count of dropped bans. Model: opus-5-5
clawbot added the needs-review label 2026-10-06 22:37:21 +02:00
clawbot self-assigned this 2026-10-06 22:37:21 +02:00
Author
Collaborator

Review failed.

  • internal/bans/admin_test.go, TestAdminsBansAreNeverDroppedAndDoNotCountTowardMaxBans: with bans whose cause is admin counted toward SWWAF_MAX_BANS, the test does not fail; dropOne loops for good, and the run ends only when the 90-second test timeout stops the whole package, losing the rest of its results. Acceptable: the test fails promptly with that rule broken, without relying on a timeout.

Judgement calls accepted:

  • lifted takes effect at once, whatever time it gives.
  • A lifted ban still counts in earlier_bans.
  • A ban dropped from behind an admin's ban on its netblock drops out of that netblock's later earlier_bans.
  • smallwebwaf_bans_made_total{cause="admin"} counts only the admin's bans an edit adds, through LoadEdit beside Load.

Model: opus-5-5

Review failed. - `internal/bans/admin_test.go`, `TestAdminsBansAreNeverDroppedAndDoNotCountTowardMaxBans`: with bans whose cause is `admin` counted toward `SWWAF_MAX_BANS`, the test does not fail; `dropOne` loops for good, and the run ends only when the 90-second test timeout stops the whole package, losing the rest of its results. Acceptable: the test fails promptly with that rule broken, without relying on a timeout. Judgement calls accepted: - `lifted` takes effect at once, whatever time it gives. - A lifted ban still counts in `earlier_bans`. - A ban dropped from behind an admin's ban on its netblock drops out of that netblock's later `earlier_bans`. - `smallwebwaf_bans_made_total{cause="admin"}` counts only the admin's bans an edit adds, through `LoadEdit` beside `Load`. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-06 22:51:51 +02:00
clawbot added 1 commit 2026-10-06 22:57:17 +02:00
A bans.json entry without a cause gets the cause admin, written back so.
Bans whose cause is admin are never dropped and do not count toward
SWWAF_MAX_BANS, so setting a ban's cause to admin keeps it. Bans
smallwebwaf makes get a reason: the limit broken or the rule matched. A
lifted ban refuses nothing, is kept, and makes no later ban longer.
smallwebwaf_bans_made_total counts admin bans an edit adds while running;
earlier_bans counts admin in place of without_cause.

Judgement call: lifted lifts at once, whatever time it gives.
Judgement call: a lifted ban still counts in earlier_bans.
Known gap: a ban dropped from behind an admin's ban on its netblock leaves that netblock's later earlier_bans.

Model: opus-5-5
clawbot force-pushed issue-86-admin-bans from 4290e76472 to d5a6c74e4e 2026-10-06 22:57:17 +02:00 Compare
Author
Collaborator

dropOne now looks at each netblock once at most, so with bans whose cause is admin counted toward SWWAF_MAX_BANS the test fails at once instead of hanging. Model: opus-5-5

`dropOne` now looks at each netblock once at most, so with bans whose cause is `admin` counted toward `SWWAF_MAX_BANS` the test fails at once instead of hanging. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-06 22:57:28 +02:00
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit ee9ba08a8a into next 2026-10-06 23:09:53 +02:00
clawbot deleted branch issue-86-admin-bans 2026-10-06 23:09:53 +02:00
Sign in to join this conversation.