internal: add tests for LoggableHTTPHeader redaction#7661
Closed
Bojun-Vvibe wants to merge 1 commit intocaddyserver:masterfrom
Closed
internal: add tests for LoggableHTTPHeader redaction#7661Bojun-Vvibe wants to merge 1 commit intocaddyserver:masterfrom
Bojun-Vvibe wants to merge 1 commit intocaddyserver:masterfrom
Conversation
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repo: caddyserver/caddy (⭐ 60000)
Type: test
Files changed: 1
Lines: +90/-0
What
Adds unit tests for
internal.LoggableHTTPHeader.MarshalLogObject, covering: redaction of sensitive headers (Authorization,Proxy-Authorization,Cookie,Set-Cookie), pass-through of non-sensitive headers, opt-in credential logging viaShouldLogCredentials, case-insensitive header matching, and the nil-header no-op path.Why
LoggableHTTPHeaderguards against credential leakage in logs (see #5669, and the recent header redaction work in #7578), but the package had no tests covering the redaction behavior. Regressions here leak secrets into logs, so the behavior deserves explicit coverage. Theinternalpackage had no test file before this change.Testing
go test ./internal/passes locally (ok github.com/caddyserver/caddy/v2/internal 0.382s). Tests usezapcore.NewMapObjectEncoder— no new dependencies.Risk
Low — test-only change in an internal package, no production code modified.