MCPcopy Create free account
hub / github.com/coder/coder / RedactHeaders

Function RedactHeaders

coderd/x/chatd/chatdebug/redaction.go:75–89  ·  view source on GitHub ↗

RedactHeaders returns a flattened copy of h with sensitive values redacted.

(h http.Header)

Source from the content-addressed store, hash-verified

73
74// RedactHeaders returns a flattened copy of h with sensitive values redacted.
75func RedactHeaders(h http.Header) map[string]string {
76 if h == nil {
77 return nil
78 }
79
80 redacted := make(map[string]string, len(h))
81 for name, values := range h {
82 if isSensitiveName(name) {
83 redacted[name] = RedactedValue
84 continue
85 }
86 redacted[name] = strings.Join(values, ", ")
87 }
88 return redacted
89}
90
91// RedactJSONSecrets redacts sensitive JSON values by key name. When
92// the input is not valid JSON (truncated body, HTML error page, etc.)

Callers 2

TestRedactHeadersFunction · 0.92
RoundTripMethod · 0.85

Calls 1

isSensitiveNameFunction · 0.85

Tested by 1

TestRedactHeadersFunction · 0.74