waf: the steps after the answer as plain statements (closes #445) #471

Open
clawbot wants to merge 1 commits from issue-445-after-answer-statements into next
pull from: issue-445-after-answer-statements
Collaborator

Closes #445.

  • New banAndCount(ctx, list) in internal/waf/request.go runs list (the heuristics that only ban), then countAnomalies, then addToHistory, as plain statements.
  • A refused request's decision calls it with afterAnswer(); an allowed request's report, in finishWith, calls it with onReport().
  • answerQuestion keeps one defer: finish, then holdForReport.
  • The denied and own-prefix answers now share one if/else, so banAndCount is called once after either.
  • runAfterAnswer is removed: the allowed path calls runBanningHeuristics(ctx, afterAnswer()) directly, after allow() as before.

Behaviour change, as the issue states: when a check panics, the request is no longer counted in its client's history or for the anomaly thresholds. The log line and the held decision still happen.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/smallwebwaf/issues/445. - New `banAndCount(ctx, list)` in `internal/waf/request.go` runs `list` (the heuristics that only ban), then `countAnomalies`, then `addToHistory`, as plain statements. - A refused request's decision calls it with `afterAnswer()`; an allowed request's report, in `finishWith`, calls it with `onReport()`. - `answerQuestion` keeps one `defer`: `finish`, then `holdForReport`. - The denied and own-prefix answers now share one `if`/`else`, so `banAndCount` is called once after either. - `runAfterAnswer` is removed: the allowed path calls `runBanningHeuristics(ctx, afterAnswer())` directly, after `allow()` as before. Behaviour change, as the issue states: when a check panics, the request is no longer counted in its client's history or for the anomaly thresholds. The log line and the held decision still happen. Model: opus-5-5
clawbot added 1 commit 2026-11-19 18:44:31 +01:00
banAndCount runs the heuristics that only ban, then countAnomalies,
then addToHistory. A refused request's decision and an allowed
request's report both call it, each with its own list. answerQuestion
keeps one defer, which writes the log line and holds the decision for
the report.

A check that panics now leaves the request out of its client's history
and the anomaly counts, as the issue states.

Model: opus-5-5
clawbot added the needs-review label 2026-11-19 18:44:33 +01:00
clawbot self-assigned this 2026-11-19 18:44:34 +01:00
Author
Collaborator

Verdict: PASS
Head: d6002e282f

The steps after the answer are now plain statements in banAndCount, which both the refused request's decision and the allowed request's report call, and answerQuestion keeps one defer, as #445 asks.

Model: opus-5-5

Verdict: PASS Head: d6002e282f5c5e0a89f63fb5468e5c44551f6a38 The steps after the answer are now plain statements in `banAndCount`, which both the refused request's decision and the allowed request's report call, and `answerQuestion` keeps one `defer`, as https://git.eeqj.de/sneak/smallwebwaf/issues/445 asks. 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-445-after-answer-statements:issue-445-after-answer-statements
git checkout issue-445-after-answer-statements
Sign in to join this conversation.