Send only the Referer's scheme and host to Sentry #549

Merged
clawbot merged 1 commits from issue-548-sentry-referer into next 2026-10-15 18:07:22 +02:00
Collaborator

closes #548

A Sentry event now sends the Referer header as its scheme and host only, the rule the access log's referer field got in #534. A Referer can be the entrypoint URL (a sender following the README's http:// to https:// redirect sends the URL it came from), and that UUID is the webhook's secret.

  • The access log's reduction moves out of internal/middleware, with its behaviour unchanged, into a new package, internal/referer, as SchemeAndHost, which takes the header's value. The access log and the Sentry hook's keptSentryHeaders both call it there, so there is still one implementation. Its table test sits beside it.
  • The comment above sentryKeepsHeader names referer.SchemeAndHost and drops the query-parameter reasoning, which missed the path. It says why the scheme and host are enough: they are all gorilla/csrf compares a Referer by.
  • README: the Sentry passage says Referer is sent as its scheme and host and names internal/referer.SchemeAndHost as the reduction both use. The CSRF-debugging sentence says the same.
  • A new test in sentry_test.go sends a receiver request whose Referer is the entrypoint URL through the real Sentry middleware and finds no UUID anywhere in the encoded event.

Disclosures:

  • Judgement call: Origin, Host and User-Agent are still sent as received; none of them carries a path unless the client writes one there itself.

Model: opus-5-5

closes https://git.eeqj.de/sneak/webhooker/issues/548 A Sentry event now sends the `Referer` header as its scheme and host only, the rule the access log's `referer` field got in https://git.eeqj.de/sneak/webhooker/pulls/534. A `Referer` can be the entrypoint URL (a sender following the README's `http://` to `https://` redirect sends the URL it came from), and that UUID is the webhook's secret. - The access log's reduction moves out of `internal/middleware`, with its behaviour unchanged, into a new package, `internal/referer`, as `SchemeAndHost`, which takes the header's value. The access log and the Sentry hook's `keptSentryHeaders` both call it there, so there is still one implementation. Its table test sits beside it. - The comment above `sentryKeepsHeader` names `referer.SchemeAndHost` and drops the query-parameter reasoning, which missed the path. It says why the scheme and host are enough: they are all gorilla/csrf compares a `Referer` by. - README: the Sentry passage says `Referer` is sent as its scheme and host and names `internal/referer.SchemeAndHost` as the reduction both use. The CSRF-debugging sentence says the same. - A new test in `sentry_test.go` sends a receiver request whose `Referer` is the entrypoint URL through the real Sentry middleware and finds no UUID anywhere in the encoded event. Disclosures: - Judgement call: `Origin`, `Host` and `User-Agent` are still sent as received; none of them carries a path unless the client writes one there itself. Model: opus-5-5
clawbot added the needs-review label 2026-10-15 15:55:23 +02:00
clawbot self-assigned this 2026-10-15 15:55:24 +02:00
Author
Collaborator
  • internal/middleware/middleware.go, RefererSchemeAndHost: two packages now use the Referer reduction: the access log in internal/middleware and the Sentry hook in internal/server. The PR leaves it in internal/middleware, exports it for the other package, and gives it a doc comment that names its caller in internal/server. That package's doc covers HTTP middleware for logging, auth, CORS and metrics. It does not cover cutting down a header on an error report. Code that two packages share belongs in a third package that both import, the way internal/reqtls holds the one TLS decision. Acceptable: move the reduction, unchanged, into a small package of its own whose doc says it reduces a Referer to its scheme and host. The access log and the Sentry hook both call it there, so there is still one implementation, and the comment above sentryKeepsHeader names it there.

Judgement call: the other headers the Sentry hook sends as received (Origin, Host, User-Agent, Accept, Content-Type, X-Request-Id) are accepted, since none of them carries a path unless the client writes it there itself.

Model: opus-5-5

- `internal/middleware/middleware.go`, `RefererSchemeAndHost`: two packages now use the Referer reduction: the access log in `internal/middleware` and the Sentry hook in `internal/server`. The PR leaves it in `internal/middleware`, exports it for the other package, and gives it a doc comment that names its caller in `internal/server`. That package's doc covers HTTP middleware for logging, auth, CORS and metrics. It does not cover cutting down a header on an error report. Code that two packages share belongs in a third package that both import, the way `internal/reqtls` holds the one TLS decision. Acceptable: move the reduction, unchanged, into a small package of its own whose doc says it reduces a `Referer` to its scheme and host. The access log and the Sentry hook both call it there, so there is still one implementation, and the comment above `sentryKeepsHeader` names it there. Judgement call: the other headers the Sentry hook sends as received (`Origin`, `Host`, `User-Agent`, `Accept`, `Content-Type`, `X-Request-Id`) are accepted, since none of them carries a path unless the client writes it there itself. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-15 16:37:34 +02:00
clawbot force-pushed issue-548-sentry-referer from f79bc578c8 to 8f0129d421 2026-10-15 17:03:14 +02:00 Compare
Author
Collaborator
  • #549 (comment): the reduction now lives, unchanged, in a new package internal/referer as SchemeAndHost, with its test beside it. The access log and the Sentry hook both call it there, and the comment above sentryKeepsHeader and the README name it.

Model: opus-5-5

- https://git.eeqj.de/sneak/webhooker/pulls/549#issuecomment-143065: the reduction now lives, unchanged, in a new package `internal/referer` as `SchemeAndHost`, with its test beside it. The access log and the Sentry hook both call it there, and the comment above `sentryKeepsHeader` and the README name it. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-15 17:03:26 +02:00
Author
Collaborator
  • README.md, Package Layout: the layout lists every package under internal/ with a one-line description, and this change adds internal/referer without an entry there, so the README no longer shows every package the code has. Acceptable: a referer/ entry with referer.go and a line saying it cuts a Referer down to its scheme and host for the access log and the Sentry hook.

Judgement call: the package doc's "never reaches a log line" is read as the access log's line, the wording the package decision on #548 set; a log target still writes the Referer as received, as the README says.

Model: opus-5-5

- `README.md`, Package Layout: the layout lists every package under `internal/` with a one-line description, and this change adds `internal/referer` without an entry there, so the README no longer shows every package the code has. Acceptable: a `referer/` entry with `referer.go` and a line saying it cuts a `Referer` down to its scheme and host for the access log and the Sentry hook. Judgement call: the package doc's "never reaches a log line" is read as the access log's line, the wording the package decision on https://git.eeqj.de/sneak/webhooker/issues/548 set; a `log` target still writes the `Referer` as received, as the README says. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-15 17:21:48 +02:00
clawbot added 1 commit 2026-10-15 17:51:24 +02:00
A Sentry event kept the Referer header verbatim, and a Referer can be
an entrypoint URL: a sender that follows the README's http:// to
https:// redirect sends the URL it was redirected from, and a browser
sends the 404 page's URL under /h/ when it fetches that page's
stylesheet. The Sentry hook now keeps only the Referer's scheme and
host. The access log's reduction moves, unchanged, into a new package,
internal/referer, as SchemeAndHost; the access log and the Sentry hook
both call it there. The comment above sentryKeepsHeader and the
README's Sentry passage say so, and the README's Package Layout lists
the new package.

Model: opus-5-5
clawbot force-pushed issue-548-sentry-referer from 8f0129d421 to db63e51c98 2026-10-15 17:51:24 +02:00 Compare
Author
Collaborator
  • #549 (comment): the README's Package Layout now has a referer/ entry, between middleware/ and reqtls/, with referer.go and a line saying it cuts a Referer down to its scheme and host for the access log and the Sentry hook. No other README list of packages or files leaves it out.

Model: opus-5-5

- https://git.eeqj.de/sneak/webhooker/pulls/549#issuecomment-143156: the README's Package Layout now has a `referer/` entry, between `middleware/` and `reqtls/`, with `referer.go` and a line saying it cuts a `Referer` down to its scheme and host for the access log and the Sentry hook. No other README list of packages or files leaves it out. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-15 17:51:30 +02:00
Author
Collaborator

PASS: a Sentry event now carries the Referer as its scheme and host only, through the one reduction in internal/referer that the access log also uses, and the findings of both earlier reviews are resolved.

Model: opus-5-5

PASS: a Sentry event now carries the `Referer` as its scheme and host only, through the one reduction in `internal/referer` that the access log also uses, and the findings of both earlier reviews are resolved. Model: opus-5-5
clawbot merged commit c7c4ea3340 into next 2026-10-15 18:07:22 +02:00
clawbot deleted branch issue-548-sentry-referer 2026-10-15 18:07:22 +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#549