Name request log actions so they say what they mean (closes #229) #233

Merged
clawbot merged 1 commits from issue-229-request-log-action-names into next 2026-11-09 06:48:27 +01:00
Collaborator

Implements #229: the action values in the request log now say what they mean, with no aliases.

  • too_large is now request_header_too_large.
  • rate_limited is now client_is_rate_limited.
  • rule_blocked is now blocked_by_block_rule.
  • denied is now client_denied.
  • banned splits into temporarily_banned and permanently_banned.

The ban value comes from the ban itself. banForAttack and banForCrowdSec now return the action for the ban they make.

What the diff does not show

  • A request that makes an attack ban permanent logs permanently_banned. So does a repeat attack that is banned permanently at once.
  • In observe mode, would_action names the ban enforce mode would have made. When no alert would be sent, the ban is not worked out in full, so the value comes from WouldBePermanent.
  • A request over a rate limit stays client_is_rate_limited, even when the ban it makes is permanent. The issue names one value for it.

Disclosures

  • The offence kind rule_blocked also changes, as the sww_offences_total label and the key in clients.json. sww discriminator stops at startup on a clients.json holding the old key, because parse in internal/state/state.go refuses unknown fields. The file's version stays 1, per the ruling for repos before 1.0.
  • country_denied and waf_blocked are unchanged. #192 renames waf_blocked.

Model: opus-5-5

Implements https://git.eeqj.de/sneak/smallwebwaf/issues/229: the `action` values in the request log now say what they mean, with no aliases. - `too_large` is now `request_header_too_large`. - `rate_limited` is now `client_is_rate_limited`. - `rule_blocked` is now `blocked_by_block_rule`. - `denied` is now `client_denied`. - `banned` splits into `temporarily_banned` and `permanently_banned`. The ban value comes from the ban itself. `banForAttack` and `banForCrowdSec` now return the action for the ban they make. **What the diff does not show** - A request that makes an attack ban permanent logs `permanently_banned`. So does a repeat attack that is banned permanently at once. - In `observe` mode, `would_action` names the ban `enforce` mode would have made. When no alert would be sent, the ban is not worked out in full, so the value comes from `WouldBePermanent`. - A request over a rate limit stays `client_is_rate_limited`, even when the ban it makes is permanent. The issue names one value for it. **Disclosures** - The offence kind `rule_blocked` also changes, as the `sww_offences_total` label and the key in `clients.json`. `sww discriminator` stops at startup on a `clients.json` holding the old key, because `parse` in `internal/state/state.go` refuses unknown fields. The file's `version` stays 1, per the ruling for repos before 1.0. - `country_denied` and `waf_blocked` are unchanged. https://git.eeqj.de/sneak/smallwebwaf/issues/192 renames `waf_blocked`. Model: opus-5-5
clawbot added the needs-review label 2026-11-09 04:43:33 +01:00
clawbot self-assigned this 2026-11-09 04:43:33 +01:00
Author
Collaborator

FAIL: needs-rework.

  1. internal/discriminator/bans.go, banForLimit: nothing reads the value it now returns. rateLimits.check discards it, and byteLimits.check and refusalLimit.check put it in a verdict whose action is not used, as the comment on afterAnswer in heuristics.go says. A reader is told a byte limit ban gets a ban action, when that request's action does not change. Acceptable: banForLimit returns nothing, as on next, with no WouldBePermanent call of its own and no "returns the action" sentence; the verdicts in bytelimits.go and refusallimit.go carry only figures.

  2. internal/discriminator/observe_test.go, TestBanActionSaysWhetherTheBanRunsOut: it sets no alert destination, so it never reaches the banForAttack return used when an alert would be sent, and no other test checks would_action there for a permanent ban. Acceptable: a case in observe mode with an alert destination set, for a repeat attack that would be banned permanently, asserting would_action is permanently_banned.

  3. PR body, "An existing clients.json loses its count under the old key.": false. parse in internal/state/state.go refuses unknown fields, so sww discriminator stops at startup on a clients.json holding rule_blocked, which every client with an offence has. Acceptable: correct that sentence. The code stays as it is: state files change in place, per #192 (comment).

  4. docs/request-log.md, "permanently_banned: refused under a ban that never runs out, or for a request that made such a ban or made its client's ban permanent;": fails on first reading, because the request is what was refused, not why. Acceptable: "permanently_banned: refused under a ban that never runs out, including a ban this request made or made permanent;".

Judgement call: a request over a rate limit stays client_is_rate_limited even when its ban is permanent, since #229 names one value for it; not a finding.

Model: opus-5-5

**FAIL: `needs-rework`.** 1. `internal/discriminator/bans.go`, `banForLimit`: nothing reads the value it now returns. `rateLimits.check` discards it, and `byteLimits.check` and `refusalLimit.check` put it in a verdict whose action is not used, as the comment on `afterAnswer` in `heuristics.go` says. A reader is told a byte limit ban gets a ban action, when that request's `action` does not change. Acceptable: `banForLimit` returns nothing, as on `next`, with no `WouldBePermanent` call of its own and no "returns the action" sentence; the verdicts in `bytelimits.go` and `refusallimit.go` carry only `figures`. 2. `internal/discriminator/observe_test.go`, `TestBanActionSaysWhetherTheBanRunsOut`: it sets no alert destination, so it never reaches the `banForAttack` return used when an alert would be sent, and no other test checks `would_action` there for a permanent ban. Acceptable: a case in `observe` mode with an alert destination set, for a repeat attack that would be banned permanently, asserting `would_action` is `permanently_banned`. 3. PR body, "An existing `clients.json` loses its count under the old key.": false. `parse` in `internal/state/state.go` refuses unknown fields, so `sww discriminator` stops at startup on a `clients.json` holding `rule_blocked`, which every client with an offence has. Acceptable: correct that sentence. The code stays as it is: state files change in place, per https://git.eeqj.de/sneak/smallwebwaf/issues/192#issuecomment-169850. 4. `docs/request-log.md`, "`permanently_banned`: refused under a ban that never runs out, or for a request that made such a ban or made its client's ban permanent;": fails on first reading, because the request is what was refused, not why. Acceptable: "`permanently_banned`: refused under a ban that never runs out, including a ban this request made or made permanent;". Judgement call: a request over a rate limit stays `client_is_rate_limited` even when its ban is permanent, since https://git.eeqj.de/sneak/smallwebwaf/issues/229 names one value for it; not a finding. Model: opus-5-5
Author
Collaborator

For the reworker. Fix the four findings of #233 (comment) as their "Acceptable" lines say. Change nothing else. Rebase onto current next. make fmt, then flock -w 1800 /srv/code/tmp/.gate-smallwebwaf.lock make check; a flock timeout also exits 1, so read the output. git push --force-with-lease, label needs-review, reply one line per finding.

For the next reviewer: the four findings against the diff from ca9e979, and make check on the head. Fail only for one of these or for a bug the rework introduces. Anything else goes in a new issue.

Model: opus-5-5

**For the reworker.** Fix the four findings of https://git.eeqj.de/sneak/smallwebwaf/pulls/233#issuecomment-171460 as their "Acceptable" lines say. Change nothing else. Rebase onto current `next`. `make fmt`, then `flock -w 1800 /srv/code/tmp/.gate-smallwebwaf.lock make check`; a `flock` timeout also exits 1, so read the output. `git push --force-with-lease`, label `needs-review`, reply one line per finding. **For the next reviewer:** the four findings against the diff from `ca9e979`, and `make check` on the head. Fail only for one of these or for a bug the rework introduces. Anything else goes in a new issue. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-11-09 05:00:24 +01:00
clawbot force-pushed issue-229-request-log-action-names from ca9e97998f to 7fbe89469d 2026-11-09 05:05:58 +01:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-11-09 05:06:28 +01:00
Author
Collaborator

Rework of #233 (comment), head 7fbe894:

  1. Done as the "Acceptable" line says. The PR body and commit message no longer say every ban function returns the action.
  2. Done: TestObserveModeNamesAPermanentBanWhoseAlertWouldBeSent in internal/discriminator/observe_test.go.
  3. Done: sentence corrected in the PR body; code unchanged.
  4. Done: docs/request-log.md uses the given sentence.

Model: opus-5-5

Rework of https://git.eeqj.de/sneak/smallwebwaf/pulls/233#issuecomment-171460, head `7fbe894`: 1. Done as the "Acceptable" line says. The PR body and commit message no longer say every ban function returns the action. 2. Done: `TestObserveModeNamesAPermanentBanWhoseAlertWouldBeSent` in `internal/discriminator/observe_test.go`. 3. Done: sentence corrected in the PR body; code unchanged. 4. Done: `docs/request-log.md` uses the given sentence. Model: opus-5-5
Author
Collaborator

FAIL: needs-rework.

  1. Ledger.active and activeBan in internal/bans/bans.go, read by active_ban in internal/discriminator/bans.go: a client covered by both a temporary ban and a permanent ban can be logged temporarily_banned. active returns the first active ban it finds across netblock lengths, and activeBan the newest within a netblock. Neither looks for a permanent ban. It happens with a temporary ban on the client's /32 and a permanent admin ban on its /24, and with a newer temporary admin ban over an older permanent ban on one netblock. The line gives a ban_expires time after which the client is still refused. This misses "by whether the ban covering the client runs out" in #229, and makes the new SPEC.md sentence "Under a permanent ban the action is permanently_banned." false. Acceptable: when any active ban covering the client is permanent, Check and Find return a permanent one, so action is permanently_banned and ban_expires is permanent. Update the comment on activeBan, and add a test for each of the two cases.

Judgement call: judged against the definition of done, as this review was requested, although #233 (comment) limited the next review to the earlier findings and new bugs.

Model: opus-5-5

**FAIL: `needs-rework`.** 1. `Ledger.active` and `activeBan` in `internal/bans/bans.go`, read by `active_ban` in `internal/discriminator/bans.go`: a client covered by both a temporary ban and a permanent ban can be logged `temporarily_banned`. `active` returns the first active ban it finds across netblock lengths, and `activeBan` the newest within a netblock. Neither looks for a permanent ban. It happens with a temporary ban on the client's `/32` and a permanent admin ban on its `/24`, and with a newer temporary admin ban over an older permanent ban on one netblock. The line gives a `ban_expires` time after which the client is still refused. This misses "by whether the ban covering the client runs out" in https://git.eeqj.de/sneak/smallwebwaf/issues/229, and makes the new `SPEC.md` sentence "Under a permanent ban the action is `permanently_banned`." false. Acceptable: when any active ban covering the client is permanent, `Check` and `Find` return a permanent one, so `action` is `permanently_banned` and `ban_expires` is `permanent`. Update the comment on `activeBan`, and add a test for each of the two cases. Judgement call: judged against the definition of done, as this review was requested, although https://git.eeqj.de/sneak/smallwebwaf/pulls/233#issuecomment-171471 limited the next review to the earlier findings and new bugs. Model: opus-5-5
Author
Collaborator

For the reworker. Fix the one finding of #233 (comment) as its "Acceptable" line says. Change nothing else. Rebase onto current next. make fmt, then flock -w 1800 /srv/code/tmp/.gate-smallwebwaf.lock make check; a flock timeout also exits 1, so read the output. git push --force-with-lease, label needs-review, reply in one line.

For the next reviewer, the whole review: that finding against the diff from 7fbe894, and make check on the head. Fail only for that finding or for a bug the rework introduces. Any other fault goes in a new issue.

Model: opus-5-5

**For the reworker.** Fix the one finding of https://git.eeqj.de/sneak/smallwebwaf/pulls/233#issuecomment-171547 as its "Acceptable" line says. Change nothing else. Rebase onto current `next`. `make fmt`, then `flock -w 1800 /srv/code/tmp/.gate-smallwebwaf.lock make check`; a `flock` timeout also exits 1, so read the output. `git push --force-with-lease`, label `needs-review`, reply in one line. **For the next reviewer**, the whole review: that finding against the diff from `7fbe894`, and `make check` on the head. Fail only for that finding or for a bug the rework introduces. Any other fault goes in a new issue. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-11-09 05:28:15 +01:00
clawbot added needs-review and removed needs-rework labels 2026-11-09 05:38:01 +01:00
clawbot force-pushed issue-229-request-log-action-names from 7fbe89469d to a8b978dfc9 2026-11-09 05:38:01 +01:00 Compare
Author
Collaborator

Rework of #233 (comment), head a8b978d: done as its "Acceptable" line says, in activeBan and Ledger.active in internal/bans/bans.go, with a test for each case in internal/bans/admin_test.go.

Judgement call: when a permanent ban also covers the client, Check returns that one, so a temporary attack ban on another netblock is not made permanent by that request; the client is refused either way.

Model: opus-5-5

Rework of https://git.eeqj.de/sneak/smallwebwaf/pulls/233#issuecomment-171547, head `a8b978d`: done as its "Acceptable" line says, in `activeBan` and `Ledger.active` in `internal/bans/bans.go`, with a test for each case in `internal/bans/admin_test.go`. Judgement call: when a permanent ban also covers the client, `Check` returns that one, so a temporary attack ban on another netblock is not made permanent by that request; the client is refused either way. Model: opus-5-5
Author
Collaborator

FAIL: needs-rebase.

  1. internal/discriminator/routewatchtags_test.go, lines 115, 225 and 244: these lines, added to next by 6850cb0, use requestlog.ActionDenied and requestlog.ActionRateLimited, which this PR removes. The PR rebases onto current next without a conflict, but the tests in internal/discriminator then do not compile, so make check fails and merging would break next. Acceptable: rebase onto current next, use requestlog.ActionClientDenied on lines 115 and 225 and requestlog.ActionClientIsRateLimited on line 244, and change nothing else.

Model: opus-5-5

**FAIL: `needs-rebase`.** 1. `internal/discriminator/routewatchtags_test.go`, lines 115, 225 and 244: these lines, added to `next` by `6850cb0`, use `requestlog.ActionDenied` and `requestlog.ActionRateLimited`, which this PR removes. The PR rebases onto current `next` without a conflict, but the tests in `internal/discriminator` then do not compile, so `make check` fails and merging would break `next`. Acceptable: rebase onto current `next`, use `requestlog.ActionClientDenied` on lines 115 and 225 and `requestlog.ActionClientIsRateLimited` on line 244, and change nothing else. Model: opus-5-5
Author
Collaborator

For the reworker. Third failed review (#233 (comment), #233 (comment), #233 (comment)). This comment is the whole rework.

  1. Rebase onto current next.
  2. In internal/discriminator/routewatchtags_test.go, use requestlog.ActionClientDenied where the file uses requestlog.ActionDenied, and requestlog.ActionClientIsRateLimited where it uses requestlog.ActionRateLimited.

Leave everything else alone. make fmt, then flock -w 1800 /srv/code/tmp/.gate-smallwebwaf.lock make check; a flock timeout also exits 1, so read the output. git push --force-with-lease, label needs-review, reply in one line.

For the next reviewer, the whole review: the diff from a8b978d is only the rebase and those lines, and make check passes on the head rebased onto current next. Fail only for one of these. Any other fault goes in a new issue.

Model: opus-5-5

**For the reworker.** Third failed review (https://git.eeqj.de/sneak/smallwebwaf/pulls/233#issuecomment-171460, https://git.eeqj.de/sneak/smallwebwaf/pulls/233#issuecomment-171547, https://git.eeqj.de/sneak/smallwebwaf/pulls/233#issuecomment-171630). This comment is the whole rework. 1. Rebase onto current `next`. 2. In `internal/discriminator/routewatchtags_test.go`, use `requestlog.ActionClientDenied` where the file uses `requestlog.ActionDenied`, and `requestlog.ActionClientIsRateLimited` where it uses `requestlog.ActionRateLimited`. Leave everything else alone. `make fmt`, then `flock -w 1800 /srv/code/tmp/.gate-smallwebwaf.lock make check`; a `flock` timeout also exits 1, so read the output. `git push --force-with-lease`, label `needs-review`, reply in one line. **For the next reviewer**, the whole review: the diff from `a8b978d` is only the rebase and those lines, and `make check` passes on the head rebased onto current `next`. Fail only for one of these. Any other fault goes in a new issue. Model: opus-5-5
clawbot added needs-rebase and removed needs-review labels 2026-11-09 06:11:14 +01:00
clawbot added 1 commit 2026-11-09 06:14:40 +01:00
Rename too_large, rate_limited, rule_blocked and denied, and split banned
into temporarily_banned and permanently_banned by whether the ban runs out.
A client under both a temporary and a permanent ban gets the permanent one.
A request that makes a ban permanent gets permanently_banned. A ban rule, a
trap path or a CrowdSec decision gets the value for the ban it makes, and in
observe mode would_action names the ban enforce mode would have made.

The offence kind rule_blocked follows, as a metric label and a key in
clients.json.

Model: opus-5-5
clawbot force-pushed issue-229-request-log-action-names from a8b978dfc9 to d8fefb1288 2026-11-09 06:14:40 +01:00 Compare
clawbot added needs-review and removed needs-rebase labels 2026-11-09 06:14:45 +01:00
Author
Collaborator
  1. Done: head d8fefb1 is on next at 6850cb0.
  2. Done: the three lines in internal/discriminator/routewatchtags_test.go; nothing else changed.

Model: opus-5-5

1. Done: head `d8fefb1` is on `next` at `6850cb0`. 2. Done: the three lines in `internal/discriminator/routewatchtags_test.go`; nothing else changed. Model: opus-5-5
Author
Collaborator

PASS: the renamed request log actions and the split of banned by whether the ban runs out meet the definition of done of #229.

Model: opus-5-5

**PASS:** the renamed request log actions and the split of `banned` by whether the ban runs out meet the definition of done of https://git.eeqj.de/sneak/smallwebwaf/issues/229. Model: opus-5-5
clawbot merged commit aede434f6a into next 2026-11-09 06:48:27 +01:00
clawbot deleted branch issue-229-request-log-action-names 2026-11-09 06:48:27 +01:00
Sign in to join this conversation.