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, 12:15 UTC
admin: Redact sensitive request headers in API logs (#7578)
* admin: Redact sensitive request headers in API logs * Fix govulncheck and typed atomic lint failures * Sync Go module metadata after dependency downgrade
Zen Dodd committed
Apr 18, 2026 at 06:56 UTC
4430756d5c3047564c4d5d72793de6685ba3efda
9 files changed
+192
-125
admin.go
+3
-1
@@ -45,6 +45,8 @@ import (
45
"github.com/prometheus/client_golang/prometheus"
46
"go.uber.org/zap"
47
"go.uber.org/zap/zapcore"
48
+
49
+ "github.com/caddyserver/caddy/v2/internal"
50
)
51
52
// testCertMagicStorageOverride is a package-level test hook. Tests may set
@@ -800,7 +802,7 @@ func (h adminHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
802
zap.String("uri", r.RequestURI),
803
zap.String("remote_ip", ip),
804
zap.String("remote_port", port),
803
- zap.Reflect("headers", r.Header),
805
+ zap.Object("headers", internal.LoggableHTTPHeader{Header: r.Header}),
806
)
807
if r.TLS != nil {
808
log = log.With(
admin_test.go
+47
@@ -31,6 +31,8 @@ import (
31
"github.com/caddyserver/certmagic"
32
"github.com/prometheus/client_golang/prometheus"
33
dto "github.com/prometheus/client_model/go"
34
+ "go.uber.org/zap"
35
+ "go.uber.org/zap/zaptest/observer"
36
)
37
38
var testCfg = []byte(`{
@@ -242,6 +244,51 @@ func TestAdminHandlerErrorHandling(t *testing.T) {
244
}
245
}
246
247
+func TestAdminHandlerServeHTTPRedactsSensitiveHeadersInLogs(t *testing.T) {
248
+ core, logs := observer.New(zap.InfoLevel)
249
+
250
+ defaultLoggerMu.Lock()
251
+ origLogger := defaultLogger.logger
252
+ defaultLogger.logger = zap.New(core)
253
+ defaultLoggerMu.Unlock()
254
+ t.Cleanup(func() {
255
+ defaultLoggerMu.Lock()
256
+ defaultLogger.logger = origLogger
257
+ defaultLoggerMu.Unlock()
258
+ })
259
+
260
+ handler := adminHandler{
261
+ mux: http.NewServeMux(),
262
+ }
263
+ req := httptest.NewRequest(http.MethodGet, "/", nil)
264
+ req.Header.Set("Authorization", "Bearer secret")
265
+ req.Header.Set("Cookie", "session=secret")
266
+ req.Header.Set("X-Test", "ok")
267
+ rr := httptest.NewRecorder()
268
+
269
+ handler.ServeHTTP(rr, req)
270
+
271
+ if logs.Len() == 0 {
272
+ t.Fatal("expected request log entry")
273
+ }
274
+
275
+ ctx := logs.All()[0].ContextMap()
276
+ headers, ok := ctx["headers"].(map[string]any)
277
+ if !ok {
278
+ t.Fatalf("expected headers field in log context, got %T", ctx["headers"])
279
+ }
280
+
281
+ if got := headers["Authorization"]; !reflect.DeepEqual(got, []any{"REDACTED"}) {
282
+ t.Fatalf("expected redacted Authorization header, got %#v", got)
283
+ }
284
+ if got := headers["Cookie"]; !reflect.DeepEqual(got, []any{"REDACTED"}) {
285
+ t.Fatalf("expected redacted Cookie header, got %#v", got)
286
+ }
287
+ if got := headers["X-Test"]; !reflect.DeepEqual(got, []any{"ok"}) {
288
+ t.Fatalf("expected X-Test header to remain visible, got %#v", got)
289
+ }
290
+}
291
+
292
func initAdminMetrics() {
293
if adminMetrics.requestErrors != nil {
294
prometheus.Unregister(adminMetrics.requestErrors)
go.mod
+16
-16
@@ -30,20 +30,20 @@ require (
30
github.com/tailscale/tscert v0.0.0-20251216020129-aea342f6d747
31
github.com/yuin/goldmark v1.8.2
32
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
33
- go.opentelemetry.io/contrib/exporters/autoexport v0.68.0
34
- go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0
35
- go.opentelemetry.io/contrib/propagators/autoprop v0.68.0
33
+ go.opentelemetry.io/contrib/exporters/autoexport v0.65.0
34
+ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.65.0
35
+ go.opentelemetry.io/contrib/propagators/autoprop v0.65.0
36
go.opentelemetry.io/otel v1.43.0
37
go.opentelemetry.io/otel/sdk v1.43.0
38
- go.step.sm/crypto v0.77.2
38
+ go.step.sm/crypto v0.77.1
39
go.uber.org/automaxprocs v1.6.0
40
go.uber.org/zap v1.27.1
41
go.uber.org/zap/exp v0.3.0
42
- golang.org/x/crypto v0.50.0
43
- golang.org/x/crypto/x509roots/fallback v0.0.0-20260323153451-8400f4a93807
44
- golang.org/x/net v0.53.0
42
+ golang.org/x/crypto v0.49.0
43
+ golang.org/x/crypto/x509roots/fallback v0.0.0-20260213171211-a408498e5541
44
+ golang.org/x/net v0.52.0
45
golang.org/x/sync v0.20.0
46
- golang.org/x/term v0.42.0
46
+ golang.org/x/term v0.41.0
47
golang.org/x/time v0.15.0
48
gopkg.in/yaml.v3 v3.0.1
49
)
@@ -68,7 +68,7 @@ require (
68
github.com/google/go-tspi v0.3.0 // indirect
69
github.com/google/s2a-go v0.1.9 // indirect
70
github.com/googleapis/enterprise-certificate-proxy v0.3.14 // indirect
71
- github.com/googleapis/gax-go/v2 v2.19.0 // indirect
71
+ github.com/googleapis/gax-go/v2 v2.18.0 // indirect
72
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirect
73
github.com/jackc/pgx/v5 v5.9.0 // indirect
74
github.com/jackc/puddle/v2 v2.2.2 // indirect
@@ -109,9 +109,9 @@ require (
109
go.yaml.in/yaml/v3 v3.0.4 // indirect
110
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect
111
golang.org/x/oauth2 v0.36.0 // indirect
112
- google.golang.org/api v0.272.0 // indirect
113
- google.golang.org/genproto/googleapis/api v0.0.0-20260406210006-6f92a3bedf2d // indirect
114
- google.golang.org/genproto/googleapis/rpc v0.0.0-20260406210006-6f92a3bedf2d // indirect
112
+ google.golang.org/api v0.271.0 // indirect
113
+ google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 // indirect
114
+ google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 // indirect
115
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 // indirect
116
)
117
@@ -168,10 +168,10 @@ require (
168
go.opentelemetry.io/otel/trace v1.43.0
169
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
170
go.uber.org/multierr v1.11.0 // indirect
171
- golang.org/x/mod v0.34.0 // indirect
172
- golang.org/x/sys v0.43.0
173
- golang.org/x/text v0.36.0
174
- golang.org/x/tools v0.43.0 // indirect
171
+ golang.org/x/mod v0.33.0 // indirect
172
+ golang.org/x/sys v0.42.0
173
+ golang.org/x/text v0.35.0
174
+ golang.org/x/tools v0.42.0 // indirect
175
google.golang.org/grpc v1.80.0 // indirect
176
google.golang.org/protobuf v1.36.11 // indirect
177
howett.net/plist v1.0.0 // indirect
go.sum
+36
-36
@@ -179,8 +179,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
179
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
180
github.com/google/go-tpm v0.9.8 h1:slArAR9Ft+1ybZu0lBwpSmpwhRXaa85hWtMinMyRAWo=
181
github.com/google/go-tpm v0.9.8/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY=
182
-github.com/google/go-tpm-tools v0.4.8 h1:V4oIYyAD3BykOycwYQzO29WefDouQMTsYZqmG3HxOfM=
183
-github.com/google/go-tpm-tools v0.4.8/go.mod h1:4DfiOtiS1KppJjwf1+tqtW4K3PrCJjAAqFKj/TYTJKg=
182
+github.com/google/go-tpm-tools v0.4.7 h1:J3ycC8umYxM9A4eF73EofRZu4BxY0jjQnUnkhIBbvws=
183
+github.com/google/go-tpm-tools v0.4.7/go.mod h1:gSyXTZHe3fgbzb6WEGd90QucmsnT1SRdlye82gH8QjQ=
184
github.com/google/go-tspi v0.3.0 h1:ADtq8RKfP+jrTyIWIZDIYcKOMecRqNJFOew2IT0Inus=
185
github.com/google/go-tspi v0.3.0/go.mod h1:xfMGI3G0PhxCdNVcYr1C4C+EizojDg/TXuX5by8CiHI=
186
github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0=
@@ -189,8 +189,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
189
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
190
github.com/googleapis/enterprise-certificate-proxy v0.3.14 h1:yh8ncqsbUY4shRD5dA6RlzjJaT4hi3kII+zYw8wmLb8=
191
github.com/googleapis/enterprise-certificate-proxy v0.3.14/go.mod h1:vqVt9yG9480NtzREnTlmGSBmFrA+bzb0yl0TxoBQXOg=
192
-github.com/googleapis/gax-go/v2 v2.19.0 h1:fYQaUOiGwll0cGj7jmHT/0nPlcrZDFPrZRhTsoCr8hE=
193
-github.com/googleapis/gax-go/v2 v2.19.0/go.mod h1:w2ROXVdfGEVFXzmlciUU4EdjHgWvB5h2n6x/8XSTTJA=
192
+github.com/googleapis/gax-go/v2 v2.18.0 h1:jxP5Uuo3bxm3M6gGtV94P4lliVetoCB4Wk2x8QA86LI=
193
+github.com/googleapis/gax-go/v2 v2.18.0/go.mod h1:uSzZN4a356eRG985CzJ3WfbFSpqkLTjsnhWGJR6EwrE=
194
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 h1:HWRh5R2+9EifMyIHV7ZV+MIZqgz+PMpZ14Jynv3O2Zs=
195
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0/go.mod h1:JfhWUomR1baixubs02l85lZYYOm7LV6om4ceouMv45c=
196
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
@@ -375,14 +375,14 @@ go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ
375
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
376
go.opentelemetry.io/contrib/bridges/prometheus v0.68.0 h1:w3zlHYETbDwXyWHZlyyR58ZC39XGi8rAhkBgUgJ9d5w=
377
go.opentelemetry.io/contrib/bridges/prometheus v0.68.0/go.mod h1:GR/mClR2nn7vE8RLwxKjoBNg+QtgdDhRzxVa93koy5o=
378
-go.opentelemetry.io/contrib/exporters/autoexport v0.68.0 h1:0D3GFvELGIwQGfC6agLsbrEYSGWZTRTxIXxcQUqrOuk=
379
-go.opentelemetry.io/contrib/exporters/autoexport v0.68.0/go.mod h1:DM2NV7Zb8CcGeVPt6glouY0FAiwZQ/iqgcWExhgWeN8=
378
+go.opentelemetry.io/contrib/exporters/autoexport v0.65.0 h1:2gApdml7SznX9szEKFjKjM4qGcGSvAybYLBY319XG3g=
379
+go.opentelemetry.io/contrib/exporters/autoexport v0.65.0/go.mod h1:0QqAGlbHXhmPYACG3n5hNzO5DnEqqtg4VcK5pr22RI0=
380
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 h1:q4XOmH/0opmeuJtPsbFNivyl7bCt7yRBbeEm2sC/XtQ=
381
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0/go.mod h1:snMWehoOh2wsEwnvvwtDyFCxVeDAODenXHtn5vzrKjo=
382
-go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0 h1:CqXxU8VOmDefoh0+ztfGaymYbhdB/tT3zs79QaZTNGY=
383
-go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0/go.mod h1:BuhAPThV8PBHBvg8ZzZ/Ok3idOdhWIodywz2xEcRbJo=
384
-go.opentelemetry.io/contrib/propagators/autoprop v0.68.0 h1:wLGFvNBPqQhzBn0QRBZjrriH8lZ9gqtTz8ufHEjLg7k=
385
-go.opentelemetry.io/contrib/propagators/autoprop v0.68.0/go.mod h1:evWK9nCqCzH8nhclTlpkdUzmxrmJQ2mrWCdKIvyOYec=
382
+go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.65.0 h1:7iP2uCb7sGddAr30RRS6xjKy7AZ2JtTOPA3oolgVSw8=
383
+go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.65.0/go.mod h1:c7hN3ddxs/z6q9xwvfLPk+UHlWRQyaeR1LdgfL/66l0=
384
+go.opentelemetry.io/contrib/propagators/autoprop v0.65.0 h1:kTaCycF9Xkm8VBBvH0rJ4wFeRjtIV55Erk3uuVsIs5s=
385
+go.opentelemetry.io/contrib/propagators/autoprop v0.65.0/go.mod h1:rooPzAbXfxMX9fsPJjmOBg2SN4RhFEV8D7cfGK+N3tE=
386
go.opentelemetry.io/contrib/propagators/aws v1.43.0 h1:EwnsB3cXRLAh7/Nr/9rMuGw73nfb3z6uAvVDjRrbeUg=
387
go.opentelemetry.io/contrib/propagators/aws v1.43.0/go.mod h1:CJjTym6F87tEdm61Qvnz5xrV8vKlH4C92djiqcn62k8=
388
go.opentelemetry.io/contrib/propagators/b3 v1.43.0 h1:CETqV3QLLPTy5yNrqyMr41VnAOOD4lsRved7n4QG00A=
@@ -431,8 +431,8 @@ go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09
431
go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0=
432
go.opentelemetry.io/proto/otlp v1.10.0 h1:IQRWgT5srOCYfiWnpqUYz9CVmbO8bFmKcwYxpuCSL2g=
433
go.opentelemetry.io/proto/otlp v1.10.0/go.mod h1:/CV4QoCR/S9yaPj8utp3lvQPoqMtxXdzn7ozvvozVqk=
434
-go.step.sm/crypto v0.77.2 h1:qFjjei+RHc5kP5R7NW9OUWT7SqWIuAOvOkXqg4fNWj8=
435
-go.step.sm/crypto v0.77.2/go.mod h1:W0YJb9onM5l78qgkXIJ2Up6grnwW8EtpCKIza/NCg0o=
434
+go.step.sm/crypto v0.77.1 h1:4EEqfKdv0egQ1lqz2RhnU8Jv6QgXZfrgoxWMqJF9aDs=
435
+go.step.sm/crypto v0.77.1/go.mod h1:U/SsmEm80mNnfD5WIkbhuW/B1eFp3fgFvdXyDLpU1AQ=
436
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
437
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
438
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
@@ -456,10 +456,10 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
456
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
457
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
458
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
459
-golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI=
460
-golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q=
461
-golang.org/x/crypto/x509roots/fallback v0.0.0-20260323153451-8400f4a93807 h1:sQVhWLXbNsa8CTzHOX3IHc7C4Q2JyxI5AweuMQZ/5H0=
462
-golang.org/x/crypto/x509roots/fallback v0.0.0-20260323153451-8400f4a93807/go.mod h1:+UoQFNBq2p2wO+Q6ddVtYc25GZ6VNdOMyyrd4nrqrKs=
459
+golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
460
+golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
461
+golang.org/x/crypto/x509roots/fallback v0.0.0-20260213171211-a408498e5541 h1:FmKxj9ocLKn45jiR2jQMwCVhDvaK7fKQFzfuT9GvyK8=
462
+golang.org/x/crypto/x509roots/fallback v0.0.0-20260213171211-a408498e5541/go.mod h1:+UoQFNBq2p2wO+Q6ddVtYc25GZ6VNdOMyyrd4nrqrKs=
463
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY=
464
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
465
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
@@ -467,8 +467,8 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
467
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
468
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
469
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
470
-golang.org/x/mod v0.34.0 h1:xIHgNUUnW6sYkcM5Jleh05DvLOtwc6RitGHbDk4akRI=
471
-golang.org/x/mod v0.34.0/go.mod h1:ykgH52iCZe79kzLLMhyCUzhMci+nQj+0XkbXpNYtVjY=
470
+golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
471
+golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
472
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
473
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
474
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
@@ -477,8 +477,8 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
477
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
478
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
479
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
480
-golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
481
-golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
480
+golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
481
+golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
482
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
483
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
484
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -506,8 +506,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
506
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
507
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
508
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
509
-golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
510
-golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
509
+golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
510
+golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
511
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
512
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
513
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -517,8 +517,8 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
517
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
518
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
519
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
520
-golang.org/x/term v0.42.0 h1:UiKe+zDFmJobeJ5ggPwOshJIVt6/Ft0rcfrXZDLWAWY=
521
-golang.org/x/term v0.42.0/go.mod h1:Dq/D+snpsbazcBG5+F9Q1n2rXV8Ma+71xEjTRufARgY=
520
+golang.org/x/term v0.41.0 h1:QCgPso/Q3RTJx2Th4bDLqML4W6iJiaXFq2/ftQF13YU=
521
+golang.org/x/term v0.41.0/go.mod h1:3pfBgksrReYfZ5lvYM0kSO0LIkAl4Yl2bXOkKP7Ec2A=
522
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
523
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
524
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
@@ -528,8 +528,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
528
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
529
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
530
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
531
-golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
532
-golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
531
+golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=
532
+golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=
533
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
534
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
535
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -538,19 +538,19 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
538
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
539
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
540
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
541
-golang.org/x/tools v0.43.0 h1:12BdW9CeB3Z+J/I/wj34VMl8X+fEXBxVR90JeMX5E7s=
542
-golang.org/x/tools v0.43.0/go.mod h1:uHkMso649BX2cZK6+RpuIPXS3ho2hZo4FVwfoy1vIk0=
541
+golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
542
+golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=
543
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
544
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
545
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
546
-google.golang.org/api v0.272.0 h1:eLUQZGnAS3OHn31URRf9sAmRk3w2JjMx37d2k8AjJmA=
547
-google.golang.org/api v0.272.0/go.mod h1:wKjowi5LNJc5qarNvDCvNQBn3rVK8nSy6jg2SwRwzIA=
548
-google.golang.org/genproto v0.0.0-20260316180232-0b37fe3546d5 h1:JNfk58HZ8lfmXbYK2vx/UvsqIL59TzByCxPIX4TDmsE=
549
-google.golang.org/genproto v0.0.0-20260316180232-0b37fe3546d5/go.mod h1:x5julN69+ED4PcFk/XWayw35O0lf/nGa4aNgODCmNmw=
550
-google.golang.org/genproto/googleapis/api v0.0.0-20260406210006-6f92a3bedf2d h1:/aDRtSZJjyLQzm75d+a1wOJaqyKBMvIAfeQmoa3ORiI=
551
-google.golang.org/genproto/googleapis/api v0.0.0-20260406210006-6f92a3bedf2d/go.mod h1:etfGUgejTiadZAUaEP14NP97xi1RGeawqkjDARA/UOs=
552
-google.golang.org/genproto/googleapis/rpc v0.0.0-20260406210006-6f92a3bedf2d h1:wT2n40TBqFY6wiwazVK9/iTWbsQrgk5ZfCSVFLO9LQA=
553
-google.golang.org/genproto/googleapis/rpc v0.0.0-20260406210006-6f92a3bedf2d/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
546
+google.golang.org/api v0.271.0 h1:cIPN4qcUc61jlh7oXu6pwOQqbJW2GqYh5PS6rB2C/JY=
547
+google.golang.org/api v0.271.0/go.mod h1:CGT29bhwkbF+i11qkRUJb2KMKqcJ1hdFceEIRd9u64Q=
548
+google.golang.org/genproto v0.0.0-20260217215200-42d3e9bedb6d h1:vsOm753cOAMkt76efriTCDKjpCbK18XGHMJHo0JUKhc=
549
+google.golang.org/genproto v0.0.0-20260217215200-42d3e9bedb6d/go.mod h1:0oz9d7g9QLSdv9/lgbIjowW1JoxMbxmBVNe8i6tORJI=
550
+google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 h1:VPWxll4HlMw1Vs/qXtN7BvhZqsS9cdAittCNvVENElA=
551
+google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:7QBABkRtR8z+TEnmXTqIqwJLlzrZKVfAUm7tY3yGv0M=
552
+google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 h1:m8qni9SQFH0tJc1X0vmnpw/0t+AImlSvp30sEupozUg=
553
+google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
554
google.golang.org/grpc v1.80.0 h1:Xr6m2WmWZLETvUNvIUmeD5OAagMw3FiKmMlTdViWsHM=
555
google.golang.org/grpc v1.80.0/go.mod h1:ho/dLnxwi3EDJA4Zghp7k2Ec1+c2jqup0bFkw07bwF4=
556
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 h1:F29+wU6Ee6qgu9TddPgooOdaqsxTMunOoj8KA5yuS5A=
internal/logmarshalers.go
new
+54
@@ -0,0 +1,54 @@
1
+package internal
2
+
3
+import (
4
+ "net/http"
5
+ "strings"
6
+
7
+ "go.uber.org/zap/zapcore"
8
+)
9
+
10
+// LoggableHTTPHeader makes an HTTP header loggable with zap.Object().
11
+// Headers with potentially sensitive information (Cookie, Set-Cookie,
12
+// Authorization, and Proxy-Authorization) are logged with empty values.
13
+type LoggableHTTPHeader struct {
14
+ http.Header
15
+
16
+ ShouldLogCredentials bool
17
+}
18
+
19
+// MarshalLogObject satisfies the zapcore.ObjectMarshaler interface.
20
+func (h LoggableHTTPHeader) MarshalLogObject(enc zapcore.ObjectEncoder) error {
21
+ if h.Header == nil {
22
+ return nil
23
+ }
24
+ for key, val := range h.Header {
25
+ if !h.ShouldLogCredentials {
26
+ switch strings.ToLower(key) {
27
+ case "cookie", "set-cookie", "authorization", "proxy-authorization":
28
+ val = []string{"REDACTED"} // see #5669. I still think ▒▒▒▒ would be cool.
29
+ }
30
+ }
31
+ enc.AddArray(key, LoggableStringArray(val))
32
+ }
33
+ return nil
34
+}
35
+
36
+// LoggableStringArray makes a slice of strings marshalable for logging.
37
+type LoggableStringArray []string
38
+
39
+// MarshalLogArray satisfies the zapcore.ArrayMarshaler interface.
40
+func (sa LoggableStringArray) MarshalLogArray(enc zapcore.ArrayEncoder) error {
41
+ if sa == nil {
42
+ return nil
43
+ }
44
+ for _, s := range sa {
45
+ enc.AppendString(s)
46
+ }
47
+ return nil
48
+}
49
+
50
+// Interface guards
51
+var (
52
+ _ zapcore.ObjectMarshaler = (*LoggableHTTPHeader)(nil)
53
+ _ zapcore.ArrayMarshaler = (*LoggableStringArray)(nil)
54
+)
modules/caddyhttp/marshalers.go
+6
-41
@@ -18,9 +18,10 @@ import (
18
"crypto/tls"
19
"net"
20
"net/http"
21
- "strings"
21
22
"go.uber.org/zap/zapcore"
23
+
24
+ "github.com/caddyserver/caddy/v2/internal"
25
)
26
27
// LoggableHTTPRequest makes an HTTP request loggable with zap.Object().
@@ -47,12 +48,12 @@ func (r LoggableHTTPRequest) MarshalLogObject(enc zapcore.ObjectEncoder) error {
48
enc.AddString("method", r.Method)
49
enc.AddString("host", r.Host)
50
enc.AddString("uri", r.RequestURI)
50
- enc.AddObject("headers", LoggableHTTPHeader{
51
+ enc.AddObject("headers", internal.LoggableHTTPHeader{
52
Header: r.Header,
53
ShouldLogCredentials: r.ShouldLogCredentials,
54
})
55
if r.TransferEncoding != nil {
55
- enc.AddArray("transfer_encoding", LoggableStringArray(r.TransferEncoding))
56
+ enc.AddArray("transfer_encoding", internal.LoggableStringArray(r.TransferEncoding))
57
}
58
if r.TLS != nil {
59
enc.AddObject("tls", LoggableTLSConnState(*r.TLS))
@@ -61,44 +62,10 @@ func (r LoggableHTTPRequest) MarshalLogObject(enc zapcore.ObjectEncoder) error {
62
}
63
64
// LoggableHTTPHeader makes an HTTP header loggable with zap.Object().
64
-// Headers with potentially sensitive information (Cookie, Set-Cookie,
65
-// Authorization, and Proxy-Authorization) are logged with empty values.
66
-type LoggableHTTPHeader struct {
67
- http.Header
68
-
69
- ShouldLogCredentials bool
70
-}
71
-
72
-// MarshalLogObject satisfies the zapcore.ObjectMarshaler interface.
73
-func (h LoggableHTTPHeader) MarshalLogObject(enc zapcore.ObjectEncoder) error {
74
- if h.Header == nil {
75
- return nil
76
- }
77
- for key, val := range h.Header {
78
- if !h.ShouldLogCredentials {
79
- switch strings.ToLower(key) {
80
- case "cookie", "set-cookie", "authorization", "proxy-authorization":
81
- val = []string{"REDACTED"} // see #5669. I still think ▒▒▒▒ would be cool.
82
- }
83
- }
84
- enc.AddArray(key, LoggableStringArray(val))
85
- }
86
- return nil
87
-}
65
+type LoggableHTTPHeader = internal.LoggableHTTPHeader
66
67
// LoggableStringArray makes a slice of strings marshalable for logging.
90
-type LoggableStringArray []string
91
-
92
-// MarshalLogArray satisfies the zapcore.ArrayMarshaler interface.
93
-func (sa LoggableStringArray) MarshalLogArray(enc zapcore.ArrayEncoder) error {
94
- if sa == nil {
95
- return nil
96
- }
97
- for _, s := range sa {
98
- enc.AppendString(s)
99
- }
100
- return nil
101
-}
68
+type LoggableStringArray = internal.LoggableStringArray
69
70
// LoggableTLSConnState makes a TLS connection state loggable with zap.Object().
71
type LoggableTLSConnState tls.ConnectionState
@@ -121,7 +88,5 @@ func (t LoggableTLSConnState) MarshalLogObject(enc zapcore.ObjectEncoder) error
88
// Interface guards
89
var (
90
_ zapcore.ObjectMarshaler = (*LoggableHTTPRequest)(nil)
124
- _ zapcore.ObjectMarshaler = (*LoggableHTTPHeader)(nil)
125
- _ zapcore.ArrayMarshaler = (*LoggableStringArray)(nil)
91
_ zapcore.ObjectMarshaler = (*LoggableTLSConnState)(nil)
92
)
modules/caddyhttp/reverseproxy/hosts.go
+1
-2
@@ -174,7 +174,7 @@ func (u *Upstream) fillDynamicHost() {
174
// Host is the basic, in-memory representation of the state of a remote host.
175
// Its fields are accessed atomically and Host values must not be copied.
176
type Host struct {
177
- numRequests atomic.Int64 // atomic.Int64 is automatically aligned for us (see https://golang.org/pkg/sync/atomic/#pkg-note-BUG)
177
+ numRequests atomic.Int64
178
fails atomic.Int64
179
activePasses atomic.Int64
180
activeFails atomic.Int64
@@ -250,7 +250,6 @@ func (h *Host) resetHealth() {
250
// (This returns the status only from the "active" health checks.)
251
func (u *Upstream) healthy() bool {
252
return u.unhealthy.Load() == 0
253
- // return atomic.LoadInt32(&u.unhealthy) == 0
253
}
254
255
// SetHealthy sets the upstream has healthy or unhealthy
modules/logging/filters.go
+13
-13
@@ -29,7 +29,7 @@ import (
29
30
"github.com/caddyserver/caddy/v2"
31
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
32
- "github.com/caddyserver/caddy/v2/modules/caddyhttp"
32
+ "github.com/caddyserver/caddy/v2/internal"
33
)
34
35
func init() {
@@ -100,8 +100,8 @@ func (f *HashFilter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
100
101
// Filter filters the input field with the replacement value.
102
func (f *HashFilter) Filter(in zapcore.Field) zapcore.Field {
103
- if array, ok := in.Interface.(caddyhttp.LoggableStringArray); ok {
104
- newArray := make(caddyhttp.LoggableStringArray, len(array))
103
+ if array, ok := in.Interface.(internal.LoggableStringArray); ok {
104
+ newArray := make(internal.LoggableStringArray, len(array))
105
for i, s := range array {
106
newArray[i] = hash(s)
107
}
@@ -241,8 +241,8 @@ func (m *IPMaskFilter) Provision(ctx caddy.Context) error {
241
242
// Filter filters the input field.
243
func (m IPMaskFilter) Filter(in zapcore.Field) zapcore.Field {
244
- if array, ok := in.Interface.(caddyhttp.LoggableStringArray); ok {
245
- newArray := make(caddyhttp.LoggableStringArray, len(array))
244
+ if array, ok := in.Interface.(internal.LoggableStringArray); ok {
245
+ newArray := make(internal.LoggableStringArray, len(array))
246
for i, s := range array {
247
newArray[i] = m.mask(s)
248
}
@@ -392,8 +392,8 @@ func (m *QueryFilter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
392
393
// Filter filters the input field.
394
func (m QueryFilter) Filter(in zapcore.Field) zapcore.Field {
395
- if array, ok := in.Interface.(caddyhttp.LoggableStringArray); ok {
396
- newArray := make(caddyhttp.LoggableStringArray, len(array))
395
+ if array, ok := in.Interface.(internal.LoggableStringArray); ok {
396
+ newArray := make(internal.LoggableStringArray, len(array))
397
for i, s := range array {
398
newArray[i] = m.processQueryString(s)
399
}
@@ -523,7 +523,7 @@ func (m *CookieFilter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
523
524
// Filter filters the input field.
525
func (m CookieFilter) Filter(in zapcore.Field) zapcore.Field {
526
- cookiesSlice, ok := in.Interface.(caddyhttp.LoggableStringArray)
526
+ cookiesSlice, ok := in.Interface.(internal.LoggableStringArray)
527
if !ok {
528
return in
529
}
@@ -559,7 +559,7 @@ OUTER:
559
transformedRequest.AddCookie(c)
560
}
561
562
- in.Interface = caddyhttp.LoggableStringArray(transformedRequest.Header["Cookie"])
562
+ in.Interface = internal.LoggableStringArray(transformedRequest.Header["Cookie"])
563
564
return in
565
}
@@ -613,8 +613,8 @@ func (m *RegexpFilter) Provision(ctx caddy.Context) error {
613
614
// Filter filters the input field with the replacement value if it matches the regexp.
615
func (f *RegexpFilter) Filter(in zapcore.Field) zapcore.Field {
616
- if array, ok := in.Interface.(caddyhttp.LoggableStringArray); ok {
617
- newArray := make(caddyhttp.LoggableStringArray, len(array))
616
+ if array, ok := in.Interface.(internal.LoggableStringArray); ok {
617
+ newArray := make(internal.LoggableStringArray, len(array))
618
for i, s := range array {
619
newArray[i] = f.regexp.ReplaceAllString(s, f.Value)
620
}
@@ -783,8 +783,8 @@ func (f *MultiRegexpFilter) Validate() error {
783
// Filter applies all regexp operations sequentially to the input field.
784
// Input is sanitized and validated for security.
785
func (f *MultiRegexpFilter) Filter(in zapcore.Field) zapcore.Field {
786
- if array, ok := in.Interface.(caddyhttp.LoggableStringArray); ok {
787
- newArray := make(caddyhttp.LoggableStringArray, len(array))
786
+ if array, ok := in.Interface.(internal.LoggableStringArray); ok {
787
+ newArray := make(internal.LoggableStringArray, len(array))
788
for i, s := range array {
789
newArray[i] = f.processString(s)
790
}
modules/logging/filters_test.go
+16
-16
@@ -8,7 +8,7 @@ import (
8
"go.uber.org/zap/zapcore"
9
10
"github.com/caddyserver/caddy/v2"
11
- "github.com/caddyserver/caddy/v2/modules/caddyhttp"
11
+ "github.com/caddyserver/caddy/v2/internal"
12
)
13
14
func TestIPMaskSingleValue(t *testing.T) {
@@ -55,11 +55,11 @@ func TestIPMaskMultiValue(t *testing.T) {
55
f := IPMaskFilter{IPv4MaskRaw: 16, IPv6MaskRaw: 32}
56
f.Provision(caddy.Context{})
57
58
- out := f.Filter(zapcore.Field{Interface: caddyhttp.LoggableStringArray{
58
+ out := f.Filter(zapcore.Field{Interface: internal.LoggableStringArray{
59
"255.255.255.255",
60
"244.244.244.244",
61
}})
62
- arr, ok := out.Interface.(caddyhttp.LoggableStringArray)
62
+ arr, ok := out.Interface.(internal.LoggableStringArray)
63
if !ok {
64
t.Fatalf("field is wrong type: %T", out.Integer)
65
}
@@ -70,11 +70,11 @@ func TestIPMaskMultiValue(t *testing.T) {
70
t.Fatalf("field entry 1 has not been filtered: %s", arr[1])
71
}
72
73
- out = f.Filter(zapcore.Field{Interface: caddyhttp.LoggableStringArray{
73
+ out = f.Filter(zapcore.Field{Interface: internal.LoggableStringArray{
74
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
75
"ff00:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
76
}})
77
- arr, ok = out.Interface.(caddyhttp.LoggableStringArray)
77
+ arr, ok = out.Interface.(internal.LoggableStringArray)
78
if !ok {
79
t.Fatalf("field is wrong type: %T", out.Integer)
80
}
@@ -120,11 +120,11 @@ func TestQueryFilterMultiValue(t *testing.T) {
120
t.Fatalf("the filter must be valid")
121
}
122
123
- out := f.Filter(zapcore.Field{Interface: caddyhttp.LoggableStringArray{
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",
126
}})
127
- arr, ok := out.Interface.(caddyhttp.LoggableStringArray)
127
+ arr, ok := out.Interface.(internal.LoggableStringArray)
128
if !ok {
129
t.Fatalf("field is wrong type: %T", out.Interface)
130
}
@@ -162,11 +162,11 @@ func TestCookieFilter(t *testing.T) {
162
{hashAction, "hash", ""},
163
}}
164
165
- out := f.Filter(zapcore.Field{Interface: caddyhttp.LoggableStringArray{
165
+ out := f.Filter(zapcore.Field{Interface: internal.LoggableStringArray{
166
"foo=a; foo=b; bar=c; bar=d; baz=e; hash=hashed",
167
}})
168
- outval := out.Interface.(caddyhttp.LoggableStringArray)
169
- expected := caddyhttp.LoggableStringArray{
168
+ outval := out.Interface.(internal.LoggableStringArray)
169
+ expected := internal.LoggableStringArray{
170
"foo=REDACTED; foo=REDACTED; baz=e; hash=1a06df82",
171
}
172
if outval[0] != expected[0] {
@@ -204,8 +204,8 @@ func TestRegexpFilterMultiValue(t *testing.T) {
204
f := RegexpFilter{RawRegexp: `secret`, Value: "REDACTED"}
205
f.Provision(caddy.Context{})
206
207
- out := f.Filter(zapcore.Field{Interface: caddyhttp.LoggableStringArray{"foo-secret-bar", "bar-secret-foo"}})
208
- arr, ok := out.Interface.(caddyhttp.LoggableStringArray)
207
+ out := f.Filter(zapcore.Field{Interface: internal.LoggableStringArray{"foo-secret-bar", "bar-secret-foo"}})
208
+ arr, ok := out.Interface.(internal.LoggableStringArray)
209
if !ok {
210
t.Fatalf("field is wrong type: %T", out.Integer)
211
}
@@ -229,8 +229,8 @@ func TestHashFilterSingleValue(t *testing.T) {
229
func TestHashFilterMultiValue(t *testing.T) {
230
f := HashFilter{}
231
232
- out := f.Filter(zapcore.Field{Interface: caddyhttp.LoggableStringArray{"foo", "bar"}})
233
- arr, ok := out.Interface.(caddyhttp.LoggableStringArray)
232
+ out := f.Filter(zapcore.Field{Interface: internal.LoggableStringArray{"foo", "bar"}})
233
+ arr, ok := out.Interface.(internal.LoggableStringArray)
234
if !ok {
235
t.Fatalf("field is wrong type: %T", out.Integer)
236
}
@@ -292,11 +292,11 @@ func TestMultiRegexpFilterMultiValue(t *testing.T) {
292
t.Fatalf("unexpected error provisioning: %v", err)
293
}
294
295
- out := f.Filter(zapcore.Field{Interface: caddyhttp.LoggableStringArray{
295
+ out := f.Filter(zapcore.Field{Interface: internal.LoggableStringArray{
296
"foo-secret-123",
297
"bar-secret-456",
298
}})
299
- arr, ok := out.Interface.(caddyhttp.LoggableStringArray)
299
+ arr, ok := out.Interface.(internal.LoggableStringArray)
300
if !ok {
301
t.Fatalf("field is wrong type: %T", out.Interface)
302
}