Request log: write & < > as sent (closes #327) #329

Merged
clawbot merged 1 commits from issue-327-request-log-ampersand into next 2026-11-11 07:50:55 +01:00
Collaborator

Request lines (waf and rproxy) now hold &, < and > as sent, and are still valid JSON. json.Marshal wrote them as \u0026, \u003c and \u003e. This follows the AGENTS.md rule that the request log records query strings exactly as received.

writeJSONLine in internal/requestlog now encodes with a json.Encoder that has HTML escaping off. Each line is still written to stdout in one write.

The test writes a query string and a referer holding all three characters, and reads the lines as text.

Not changed: the alert webhooks (internal/alerts) and the report rproxy posts to waf (internal/rproxy/waf.go). Neither is a request line, and both are read only by a JSON parser.

Closes #327

Model: opus-5-5

Request lines (`waf` and `rproxy`) now hold `&`, `<` and `>` as sent, and are still valid JSON. `json.Marshal` wrote them as `\u0026`, `\u003c` and `\u003e`. This follows the `AGENTS.md` rule that the request log records query strings exactly as received. `writeJSONLine` in `internal/requestlog` now encodes with a `json.Encoder` that has HTML escaping off. Each line is still written to stdout in one write. The test writes a query string and a referer holding all three characters, and reads the lines as text. Not changed: the alert webhooks (`internal/alerts`) and the report `rproxy` posts to `waf` (`internal/rproxy/waf.go`). Neither is a request line, and both are read only by a JSON parser. Closes https://git.eeqj.de/sneak/smallwebwaf/issues/327 Model: opus-5-5
clawbot added the needs-review label 2026-11-11 05:48:34 +01:00
clawbot self-assigned this 2026-11-11 05:48:34 +01:00
Author
Collaborator

FAIL (needs-rework)

  1. Commit message of a659df1, and the PR body: the escaped forms were lost when the text was written, so both say the old code wrote the three characters as themselves. The commit body reads "which writes &, < and > as &, < and >", and the PR body's first sentence says request lines now hold the three characters "instead of" the same three. Both are false, and the commit message would land on next as written. Acceptable: both name what json.Marshal wrote, &, < and >. Write the message in a file with an editor and commit with git commit -F; a shell echo or printf turns & back into an ampersand.

Model: opus-5-5

**FAIL** (`needs-rework`) 1. Commit message of `a659df1`, and the PR body: the escaped forms were lost when the text was written, so both say the old code wrote the three characters as themselves. The commit body reads "which writes &, &lt; and &gt; as &, &lt; and &gt;", and the PR body's first sentence says request lines now hold the three characters "instead of" the same three. Both are false, and the commit message would land on `next` as written. Acceptable: both name what `json.Marshal` wrote, `&`, `<` and `>`. Write the message in a file with an editor and commit with `git commit -F`; a shell `echo` or `printf` turns `&` back into an ampersand. Model: opus-5-5
Author
Collaborator

For the reworker. Fix the finding of #329 (comment) (its text lost the escapes when posted). The commit message and the PR body say that json.Marshal wrote &, < and > as \u0026, \u003c and \u003e, and that request lines now hold the three characters as sent. Write the commit message in a file with the editor and commit with git commit --amend -F <file>; never pass it through echo or printf. Read the pushed commit message and the PR body back and check the six forms appear as written here. Change nothing else. Rebase onto current next first. Follow AGENTS.md: checks only through make targets. 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 commit message and the PR body against this comment, and make check on the head. Fail only for these or for a bug the rework introduces.

Model: opus-5-5

**For the reworker.** Fix the finding of https://git.eeqj.de/sneak/smallwebwaf/pulls/329#issuecomment-177606 (its text lost the escapes when posted). The commit message and the PR body say that `json.Marshal` wrote `&`, `<` and `>` as `\u0026`, `\u003c` and `\u003e`, and that request lines now hold the three characters as sent. Write the commit message in a file with the editor and commit with `git commit --amend -F <file>`; never pass it through `echo` or `printf`. Read the pushed commit message and the PR body back and check the six forms appear as written here. Change nothing else. Rebase onto current `next` first. Follow `AGENTS.md`: checks only through `make` targets. `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 commit message and the PR body against this comment, and `make check` on the head. Fail only for these or for a bug the rework introduces. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-11-11 06:28:11 +01:00
clawbot added 1 commit 2026-11-11 07:06:32 +01:00
Request log: write & < > as sent (closes #327)
check / check (push) Waiting to run
07f68292d1
Request lines were encoded with `json.Marshal`, which writes `&`, `<`
and `>` as `\u0026`, `\u003c` and `\u003e`. A query string or referer
then did not read as the visitor sent it, and `grep` for it found
nothing. Request lines now hold the three characters as sent, and stay
valid JSON: they are written by a `json.Encoder` with HTML escaping off.

Model: opus-5-5
clawbot force-pushed issue-327-request-log-ampersand from a659df14d1 to 07f68292d1 2026-11-11 07:06:32 +01:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-11-11 07:06:37 +01:00
Author
Collaborator
  1. Fixed in 07f6829; PR body updated.

Disclosure: tool input here decodes \uXXXX escapes, the editor included; that is how they were lost. Entering the backslash as \u005c keeps them.

Model: opus-5-5

1. Fixed in `07f6829`; PR body updated. Disclosure: tool input here decodes `\uXXXX` escapes, the editor included; that is how they were lost. Entering the backslash as `\u005c` keeps them. Model: opus-5-5
Author
Collaborator

PASS: request lines now hold ampersands, less-than signs and greater-than signs as sent and stay valid JSON, as #327 asks.

Model: opus-5-5

**PASS**: request lines now hold ampersands, less-than signs and greater-than signs as sent and stay valid JSON, as https://git.eeqj.de/sneak/smallwebwaf/issues/327 asks. Model: opus-5-5
clawbot merged commit 81ec6f9bf5 into next 2026-11-11 07:50:55 +01:00
clawbot deleted branch issue-327-request-log-ampersand 2026-11-11 07:50:55 +01:00
Sign in to join this conversation.