Skip to content

logging: hash query parameter values in QueryFilter#7884

Merged
francislavoie merged 1 commit into
caddyserver:masterfrom
PichuChen:fix/query-filter-hash-value
Jul 15, 2026
Merged

logging: hash query parameter values in QueryFilter#7884
francislavoie merged 1 commit into
caddyserver:masterfrom
PichuChen:fix/query-filter-hash-value

Conversation

@PichuChen

Copy link
Copy Markdown
Contributor

Fixes #7883.

Summary

The query log filter currently passes the hash action's Value field to hash. Because a hash action does not populate that field, every query parameter value is replaced with the hash of an empty string (e3b0c442).

This change:

  • hashes each actual query parameter value;
  • updates the existing single-value test to expect the hash of its input;
  • uses distinct inputs in the multi-value test to verify that different values produce different hashes.

The behavior is now consistent with the query filter documentation and with the cookie filter, which already hashes the actual cookie value.

Testing

The updated tests failed against the original implementation with e3b0c442, then passed after the production-code change.

The following commands completed successfully:

go test ./modules/logging \
  -run 'TestQueryFilter(SingleValue|MultiValue)$' \
  -count=1

go test ./modules/logging -count=1

go test -race ./modules/logging -count=1

go test \
  -coverprofile=/tmp/caddy-cover-profile.out \
  -short \
  -race \
  ./... \
  -count=1

Assistance Disclosure

AI-assisted using OpenAI Codex (GPT-5).

The issue was initially identified with AI assistance while reviewing a downstream Caddy configuration. I independently reproduced the behavior against unmodified v2.11.4 and current master checkouts, inspected and understood the relevant implementation, verified the SHA-256 results, and performed a red-green regression-test workflow.

AI assisted with the initial analysis, test planning, and wording. I reviewed and understand the code and tests in this pull request.

Copilot AI review requested due to automatic review settings July 15, 2026 10:17
@CLAassistant

CLAassistant commented Jul 15, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

Pull request overview

Agent review by GitHub Copilot.

This pull request fixes QueryFilter’s hash action so it hashes each actual query parameter value (instead of always hashing an empty string), aligning behavior with the documentation and the existing cookie filter.

Changes:

  • Update QueryFilter.processQueryString to hash q[a.Parameter][i] (the actual per-value input) rather than a.Value.
  • Update the single-value query filter test to expect the SHA-256 prefix of the real input.
  • Strengthen the multi-value test by using distinct inputs (alpha/beta) and asserting distinct expected hashes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
modules/logging/filters.go Fixes query parameter hashing to use the real parameter value.
modules/logging/filters_test.go Updates/strengthens tests to validate correct per-value hashing behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@francislavoie francislavoie added the bug 🐞 Something isn't working label Jul 15, 2026
@francislavoie francislavoie added this to the v2.11.5 milestone Jul 15, 2026
@francislavoie francislavoie enabled auto-merge (squash) July 15, 2026 16:30
@francislavoie francislavoie merged commit 986753a into caddyserver:master Jul 15, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐞 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

QueryFilter hash action hashes an empty value instead of the query parameter value

4 participants