Skip to content

logging: Parse request URIs in the query filter like the server does - #8255

Open
jayhemnani9910 wants to merge 1 commit into
caddyserver:masterfrom
jayhemnani9910:fix-log-query-filter-request-uri
Open

jayhemnani9910 wants to merge 1 commit into
caddyserver:masterfrom
jayhemnani9910:fix-log-query-filter-request-uri

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

Closes #8254

The query filter parsed the logged URI with url.Parse, which treats # as a fragment. For a request-target the server has no fragment, so /a?x=1#&token=s3cr3t was logged with token unredacted, and /a?token=s3cr3t#%zz failed to parse and was logged unchanged. Values starting with / are now parsed with url.ParseRequestURI, the same parser the server uses for the request line; other values still use url.Parse.

Side effect: a relative URL with a fragment in another field (for example Location: /a?x=1#section) now has the fragment read as part of the query. Absolute-form request-targets are unchanged.

Test: TestQueryFilterHashInRequestURI covers both requests. It fails without the change.

go test -short ./... 30 ok, same as master; golangci-lint 0 issues for modules/logging.

Manual check with the config in the issue: v2.11.7 logs /a?x=1#&token=s3cr3t and /a?token=s3cr3t#%zz; with the change they log /a?token=REDACTED&x=1%23 and /a.

Assistance Disclosure

AI used (Claude Code).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

logging: query filter leaves parameters unredacted when the request URI contains #

2 participants