Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 11, 08:30 UTC
logging: hash query parameter values in QueryFilter (#7884)
Pichu Chen committed
Jul 16, 2026 at 00:38 UTC
986753a7c6ec25bb676997a5a0ea2356406cb9aa
2 files changed
+6
-6
modules/logging/filters.go
+1
-1
@@ -421,7 +421,7 @@ func (m QueryFilter) processQueryString(s string) string {
421
422
case hashAction:
423
for i := range q[a.Parameter] {
424
- q[a.Parameter][i] = hash(a.Value)
424
+ q[a.Parameter][i] = hash(q[a.Parameter][i])
425
}
426
427
case deleteAction:
modules/logging/filters_test.go
+5
-5
@@ -100,7 +100,7 @@ func TestQueryFilterSingleValue(t *testing.T) {
100
}
101
102
out := f.Filter(zapcore.Field{String: "/path?foo=a&foo=b&bar=c&bar=d&baz=e&hash=hashed"})
103
- if out.String != "/path?baz=e&foo=REDACTED&foo=REDACTED&hash=e3b0c442" {
103
+ if out.String != "/path?baz=e&foo=REDACTED&foo=REDACTED&hash=1a06df82" {
104
t.Fatalf("query parameters have not been filtered: %s", out.String)
105
}
106
}
@@ -121,16 +121,16 @@ func TestQueryFilterMultiValue(t *testing.T) {
121
}
122
123
out := f.Filter(zapcore.Field{Interface: internal.LoggableStringArray{
124
- "/path1?foo=a&foo=b&bar=c&bar=d&baz=e&hash=hashed",
125
- "/path2?foo=c&foo=d&bar=e&bar=f&baz=g&hash=hashed",
124
+ "/path1?foo=a&foo=b&bar=c&bar=d&baz=e&hash=alpha",
125
+ "/path2?foo=c&foo=d&bar=e&bar=f&baz=g&hash=beta",
126
}})
127
arr, ok := out.Interface.(internal.LoggableStringArray)
128
if !ok {
129
t.Fatalf("field is wrong type: %T", out.Interface)
130
}
131
132
- expected1 := "/path1?baz=e&foo=REDACTED&foo=REDACTED&hash=e3b0c442"
133
- expected2 := "/path2?baz=g&foo=REDACTED&foo=REDACTED&hash=e3b0c442"
132
+ expected1 := "/path1?baz=e&foo=REDACTED&foo=REDACTED&hash=8ed3f6ad"
133
+ expected2 := "/path2?baz=g&foo=REDACTED&foo=REDACTED&hash=f44e64e7"
134
if arr[0] != expected1 {
135
t.Fatalf("query parameters in entry 0 have not been filtered correctly: got %s, expected %s", arr[0], expected1)
136
}