bans: one ledger method makes a request's ban, one place decides observe mode (closes #444) #469

Open
clawbot wants to merge 1 commits from issue-444-one-ban-method into next
pull from: issue-444-one-ban-method
Collaborator

closes #444

The ledger's four methods for a request's ban (BanForLimit, WouldBanForLimit, BanForAttack, WouldBanForAttack) become two. internal/waf/bans.go gets one function holding the skeleton the two callers repeated; it is the only place that tests observe mode on the way to a ban.

New names:

  • bans.Grounds: why a request makes a ban, its cause (CauseLimit or CauseAttack) and its notes.
  • (*bans.Ledger).Ban: makes a request's ban on a netblock, on grounds; the reason and length follow from the cause.
  • (*bans.Ledger).WouldBan: returns what Ban would, without making the ban.
  • (*request).banClient: bans the client's netblock on grounds and returns the log action; in observe mode it makes no ban and raises the alert for the one it would have made.
  • (*request).withClientNotes: returns notes with what the request tells of the client added (AS, country, reputation, the request, the netblock's request count).

Things the diff does not show:

  • The limiter reset after a ban for a broken limit moved into banClient, behind a test of the cause.
  • Ban and WouldBan panic for a cause other than CauseLimit or CauseAttack; before, only those two methods could be called.
  • In observe mode, a broken limit whose alert would not be sent now also asks WouldBePermanent, as an attack already did; the answer is unused. It only reads the ledger.
  • Tests change only at the calls to the four methods.

Model: opus-5-5

closes https://git.eeqj.de/sneak/smallwebwaf/issues/444 The ledger's four methods for a request's ban (`BanForLimit`, `WouldBanForLimit`, `BanForAttack`, `WouldBanForAttack`) become two. `internal/waf/bans.go` gets one function holding the skeleton the two callers repeated; it is the only place that tests observe mode on the way to a ban. New names: - `bans.Grounds`: why a request makes a ban, its cause (`CauseLimit` or `CauseAttack`) and its notes. - `(*bans.Ledger).Ban`: makes a request's ban on a netblock, on grounds; the reason and length follow from the cause. - `(*bans.Ledger).WouldBan`: returns what `Ban` would, without making the ban. - `(*request).banClient`: bans the client's netblock on grounds and returns the log action; in observe mode it makes no ban and raises the alert for the one it would have made. - `(*request).withClientNotes`: returns notes with what the request tells of the client added (AS, country, reputation, the request, the netblock's request count). Things the diff does not show: - The limiter reset after a ban for a broken limit moved into `banClient`, behind a test of the cause. - `Ban` and `WouldBan` panic for a cause other than `CauseLimit` or `CauseAttack`; before, only those two methods could be called. - In observe mode, a broken limit whose alert would not be sent now also asks `WouldBePermanent`, as an attack already did; the answer is unused. It only reads the ledger. - Tests change only at the calls to the four methods. Model: opus-5-5
clawbot added the needs-review label 2026-11-19 18:44:27 +01:00
clawbot self-assigned this 2026-11-19 18:44:27 +01:00
clawbot added 1 commit 2026-11-19 18:44:27 +01:00
The ledger's BanForLimit, WouldBanForLimit, BanForAttack and
WouldBanForAttack become Ban and WouldBan, which take the cause and the
notes in one bans.Grounds. The waf's banForLimit and banForAttack fill in
what differs and call banClient, the one function that tests observe
mode on the way to a ban. Behaviour is unchanged; tests change only
where they called the four methods.

Model: opus-5-5
Author
Collaborator

Verdict: PASS
Head: 89f2918d25

The ledger's four ban methods become Ban and WouldBan, and banClient is the one place that checks observe mode for a request's ban, with behaviour unchanged and tests touched only at the old call sites.

Model: opus-5-5

Verdict: PASS Head: 89f2918d25bf71f761cbab2821c053a52b5f9f82 The ledger's four ban methods become `Ban` and `WouldBan`, and `banClient` is the one place that checks observe mode for a request's ban, with behaviour unchanged and tests touched only at the old call sites. Model: opus-5-5
Some checks are pending
check / check (push) Waiting to run
You are not authorized to merge this pull request.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin issue-444-one-ban-method:issue-444-one-ban-method
git checkout issue-444-one-ban-method
Sign in to join this conversation.