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, through the access log's own reduction, which internal/middleware now exports as RefererSchemeAndHost. The comment above sentryKeepsHeader and the README's Sentry passage say so. Model: opus-5-5
This commit is contained in:
@@ -2491,6 +2491,8 @@ 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, by the same rule as the access
|
||||
log's `referer` field, because its path can be an entrypoint URL.
|
||||
|
||||
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
|
||||
@@ -2561,8 +2563,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
|
||||
|
||||
Reference in New Issue
Block a user