Stop echoing header names in header value errors
CI / ci (push) Successful in 1m30s
Independent review Codex gpt-6-sol high: CHANGES_REQUIRED (1 high)
CI / ci (pull_request) Successful in 1m28s

Canonicalising a header name changes its case, so a key embedded in the
name survived exact-match redaction. A bad header value now gets a fixed
message; only managed header names, which are fixed known strings, are
named. assertNoSecret now matches case-insensitively.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 16:46:52 -04:00
co-authored by Claude Opus 5.5
parent 3ddc18fa0d
commit 095c03f112
2 changed files with 9 additions and 7 deletions
+2 -2
View File
@@ -373,7 +373,7 @@ func TestVerify(t *testing.T) {
func assertNoSecret(t *testing.T, err error) {
t.Helper()
for _, secret := range []string{testKey, "Bearer " + testKey, testKey[:12]} {
if strings.Contains(err.Error(), secret) {
if strings.Contains(strings.ToLower(err.Error()), strings.ToLower(secret)) {
t.Fatalf("error leaks %q: %v", secret, err)
}
}
@@ -633,7 +633,7 @@ func TestNewConfigErrorsNeverLeakKey(t *testing.T) {
cases := map[string]Config{
"key in invalid header name": {Headers: map[string]string{"Bearer " + testKey: "a"}},
"key as invalid header name": {Headers: map[string]string{testKey + ":": "a"}},
"key in name, bad value": {Headers: map[string]string{"X-" + testKey: "a\nb"}},
"key in name, bad value": {Headers: map[string]string{"x-" + testKey: "a\nb"}},
"key in structured output": {StructuredOutput: StructuredOutput("Bearer " + testKey)},
"key with quote in mode": {StructuredOutput: StructuredOutput(testKey + "\"\x00")},
}