Send only the Referer's scheme and host to Sentry (closes #548)
check / check (push) Waiting to run
check / check (push) Waiting to run
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
This commit is contained in:
@@ -2494,6 +2494,9 @@ are both taken unconditionally, the body precisely because these handlers call
|
||||
body with `(redacted)`, drops cookies and the remote-address environment, and
|
||||
reduces the headers to a fixed allowlist — `Accept`, `Content-Length`,
|
||||
`Content-Type`, `Host`, `Origin`, `Referer`, `User-Agent` and `X-Request-Id`.
|
||||
`Referer` is sent as its scheme and host only, because its path can be an
|
||||
entrypoint URL; `internal/referer.SchemeAndHost` does that reduction for both
|
||||
the access log's `referer` field and this hook.
|
||||
|
||||
The same hook rewrites the request URL. The SDK builds it as
|
||||
`scheme://host/path` from the concrete path, which on the receiver route is
|
||||
@@ -2564,8 +2567,9 @@ receiver route. What survives still names the failing route — scheme, host,
|
||||
route pattern, method — and `X-Request-Id` ties the event to the local access
|
||||
log line that holds the rest. Nothing dropped is needed for the likeliest use,
|
||||
debugging a CSRF rejection. Its three inputs are the TLS decision, `Origin` and
|
||||
`Referer`; the latter two are kept, and the first is the scheme of the retained
|
||||
URL, because the SDK derives that scheme from
|
||||
`Referer`; the latter two are kept (`Referer` as its scheme and host, which is
|
||||
all the check compares), and the first is the scheme of the retained URL,
|
||||
because the SDK derives that scheme from
|
||||
`r.TLS != nil || r.Header.Get("X-Forwarded-Proto") == "https"`. That predicate
|
||||
is the SDK's own and is stricter than `internal/reqtls.IsTLS`, which this
|
||||
service now uses everywhere it decides transport: the SDK reports `http` for the
|
||||
@@ -3097,6 +3101,8 @@ webhooker/
|
||||
│ │ ├── ratelimit.go # Per-IP rate limiting middleware (go-chi/httprate)
|
||||
│ │ ├── loginguard.go # Login failure counters and the Argon2id verification semaphore
|
||||
│ │ └── middlewaretest/ # Test support: a Middleware for tests in other packages
|
||||
│ ├── referer/
|
||||
│ │ └── referer.go # SchemeAndHost: cuts a Referer down to its scheme and host, for the access log and the Sentry hook
|
||||
│ ├── reqtls/
|
||||
│ │ └── reqtls.go # IsTLS: the one TLS predicate, r.TLS or X-Forwarded-Proto
|
||||
│ ├── server/
|
||||
|
||||
Reference in New Issue
Block a user