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

Function isSensitiveName

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

isSensitiveName reports whether a name (header or query parameter) looks like a credential-carrying key. Exact-match headers are checked first, then the rate-limit allowlist, then substring patterns for API keys and auth tokens.

(name string)

Source from the content-addressed store, hash-verified

207// checked first, then the rate-limit allowlist, then substring
208// patterns for API keys and auth tokens.
209func isSensitiveName(name string) bool {
210 lowerName := strings.ToLower(name)
211 if _, ok := sensitiveHeaderNames[lowerName]; ok {
212 return true
213 }
214 if _, ok := safeRateLimitHeaderNames[lowerName]; ok {
215 return false
216 }
217 if strings.Contains(lowerName, "api-key") ||
218 strings.Contains(lowerName, "api_key") ||
219 strings.Contains(lowerName, "apikey") {
220 return true
221 }
222 // Catch any header containing "token" (e.g. Token, X-Token,
223 // X-Auth-Token). Safe rate-limit headers like
224 // x-ratelimit-remaining-tokens are already allowlisted above
225 // and will not reach this point.
226 if strings.Contains(lowerName, "token") {
227 return true
228 }
229 return strings.Contains(lowerName, "secret") ||
230 strings.Contains(lowerName, "bearer")
231}
232
233func isSensitiveJSONKey(key string) bool {
234 lowerKey := strings.ToLower(key)

Callers 2

RedactHeadersFunction · 0.85
redactURLFunction · 0.85

Calls 1

ContainsMethod · 0.45

Tested by

no test coverage detected