Pin the body cap's order in every page route group (closes #93) #449

Merged
clawbot merged 1 commits from issue-93-body-limit-followups into next 2026-10-02 17:53:21 +02:00
Collaborator

Follow-ups from the review recorded in #93, each checked against current next first.

  • Item 3: a route test posts an oversized body, with no session and no CSRF token, to every page route group (/pages, /user/{username}, /settings, /hooks, /hook/{sourceID}), and requires 413 with no CSRF cookie. Until now nothing covered /settings or the two webhook groups: moving the body cap after CSRF there failed no test. /settings has no POST route, but its group's middleware runs before the method is matched, so a POST there would still reach CSRF's form parsing.
  • Item 4: the MaxBodySize doc comment says other methods pass through uncapped on purpose, and that a handler which starts reading a body on one needs its method added first.
  • Item 1: the middleware test comment now sits on runMaxBodySize, the function it describes; the result struct has its own one-line comment.
  • Item 5: the three router helpers in the server tests build the Server through New instead of setting its fields by hand. New is handed a lifecycle that is never started, so its hooks never run and nothing listens. The helpers now take the test's t and the *logger.Logger that New takes.

Already settled on next: item 2. The README's middleware section already says the cap runs per route group after the global middleware, and ahead of CSRF and so of any form parsing.

Judgement call: the new test lists /pages/login as well, overlapping the existing login test, so that one test covers every group.

Model: opus-5-5

Follow-ups from the review recorded in https://git.eeqj.de/sneak/webhooker/issues/93, each checked against current `next` first. - Item 3: a route test posts an oversized body, with no session and no CSRF token, to every page route group (`/pages`, `/user/{username}`, `/settings`, `/hooks`, `/hook/{sourceID}`), and requires `413` with no CSRF cookie. Until now nothing covered `/settings` or the two webhook groups: moving the body cap after CSRF there failed no test. `/settings` has no POST route, but its group's middleware runs before the method is matched, so a POST there would still reach CSRF's form parsing. - Item 4: the `MaxBodySize` doc comment says other methods pass through uncapped on purpose, and that a handler which starts reading a body on one needs its method added first. - Item 1: the middleware test comment now sits on `runMaxBodySize`, the function it describes; the result struct has its own one-line comment. - Item 5: the three router helpers in the server tests build the `Server` through `New` instead of setting its fields by hand. `New` is handed a lifecycle that is never started, so its hooks never run and nothing listens. The helpers now take the test's `t` and the `*logger.Logger` that `New` takes. Already settled on `next`: item 2. The README's middleware section already says the cap runs per route group after the global middleware, and ahead of CSRF and so of any form parsing. Judgement call: the new test lists `/pages/login` as well, overlapping the existing login test, so that one test covers every group. Model: opus-5-5
clawbot added the needs-review label 2026-10-02 17:04:39 +02:00
clawbot self-assigned this 2026-10-02 17:04:39 +02:00
Author
Collaborator

Review of #449 against #93: needs rework.

  1. internal/server/export_test.go, the paragraph added to the NewRouterForTest doc comment: the reason it gives for building the Server by hand does not hold. New only adds its start and stop hooks to the lifecycle it is handed, and they run only if that lifecycle is started. A helper that passes one it never starts (for example fxtest.NewLifecycle) gets the real constructor and no listener, and every caller already holds the *logger.Logger that New takes. So a field that New sets and SetupRoutes reads still stays zero in all three router helpers, on a reason that is not true of the tree. Acceptable: build the three helpers through New with a lifecycle that is never started, so the caveat about setting fields in three places goes away; or keep the hand-built struct and give a reason that is true. The PR body's item 5 line carries the same reason and should match.

Judgement call: /settings is left out of the new test, as the plan scopes it to groups with a POST route, but an oversized POST to /settings/ still reaches CSRF's form parsing if that group's body cap is moved after CSRF, and no test catches it; not counted as a finding, cheap to add to the same list.

Model: opus-5-5

Review of https://git.eeqj.de/sneak/webhooker/pulls/449 against https://git.eeqj.de/sneak/webhooker/issues/93: needs rework. 1. `internal/server/export_test.go`, the paragraph added to the `NewRouterForTest` doc comment: the reason it gives for building the `Server` by hand does not hold. `New` only adds its start and stop hooks to the lifecycle it is handed, and they run only if that lifecycle is started. A helper that passes one it never starts (for example `fxtest.NewLifecycle`) gets the real constructor and no listener, and every caller already holds the `*logger.Logger` that `New` takes. So a field that `New` sets and `SetupRoutes` reads still stays zero in all three router helpers, on a reason that is not true of the tree. Acceptable: build the three helpers through `New` with a lifecycle that is never started, so the caveat about setting fields in three places goes away; or keep the hand-built struct and give a reason that is true. The PR body's item 5 line carries the same reason and should match. Judgement call: `/settings` is left out of the new test, as the plan scopes it to groups with a POST route, but an oversized POST to `/settings/` still reaches CSRF's form parsing if that group's body cap is moved after CSRF, and no test catches it; not counted as a finding, cheap to add to the same list. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-02 17:20:25 +02:00
clawbot added 1 commit 2026-10-02 17:38:11 +02:00
A route test now posts an oversized body with no session or CSRF
token to each page route group, /settings included, and requires 413
with no CSRF cookie. Before, only the login form pinned the cap ahead
of CSRF; reordering the /settings, /hooks or /hook groups failed
nothing.

The MaxBodySize doc comment says other methods pass uncapped on
purpose, and the middleware test comment names the helper it
describes. The three router helpers in the server tests build the
Server through New, on a lifecycle that is never started, instead of
setting its fields by hand. The README already described the cap's
position correctly.

Model: opus-5-5
clawbot force-pushed issue-93-body-limit-followups from f76a175091 to 091d17c5ae 2026-10-02 17:38:11 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-02 17:38:28 +02:00
Author
Collaborator

Rework of #449 after the review above.

  1. The three router helpers in internal/server/export_test.go build the Server through New, handing it a lifecycle that is never started, so no field is set by hand. The caveat paragraph and its untrue reason are gone from the doc comment, and from the PR body's item 5. The helpers take the test's t and the *logger.Logger in place of a bare *slog.Logger; their callers pass those.

Suggestion taken: /settings/ is in the new test's list, with one sentence in its comment on why a group with no POST route still counts.

Model: opus-5-5

Rework of https://git.eeqj.de/sneak/webhooker/pulls/449 after the review above. 1. The three router helpers in `internal/server/export_test.go` build the `Server` through `New`, handing it a lifecycle that is never started, so no field is set by hand. The caveat paragraph and its untrue reason are gone from the doc comment, and from the PR body's item 5. The helpers take the test's `t` and the `*logger.Logger` in place of a bare `*slog.Logger`; their callers pass those. Suggestion taken: `/settings/` is in the new test's list, with one sentence in its comment on why a group with no POST route still counts. Model: opus-5-5
Author
Collaborator

Review of #449 against #93 passed.

Model: opus-5-5

Review of https://git.eeqj.de/sneak/webhooker/pulls/449 against https://git.eeqj.de/sneak/webhooker/issues/93 passed. Model: opus-5-5
clawbot merged commit d084f4f912 into next 2026-10-02 17:53:21 +02:00
clawbot deleted branch issue-93-body-limit-followups 2026-10-02 17:53:21 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/webhooker#449