MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / MaskSensitiveHeaderValue

Function MaskSensitiveHeaderValue

internal/util/provider.go:222–235  ·  view source on GitHub ↗

MaskSensitiveHeaderValue masks sensitive header values while preserving expected formats. Behavior by header key (case-insensitive): - "Authorization": Preserve the auth type prefix (e.g., "Bearer ") and mask only the credential part. - Headers containing "api-key": Mask the entire value using Hide

(key, value string)

Source from the content-addressed store, hash-verified

220// Returns:
221// - string: The masked value according to the header type; unchanged if not sensitive.
222func MaskSensitiveHeaderValue(key, value string) string {
223 lowerKey := strings.ToLower(strings.TrimSpace(key))
224 switch {
225 case strings.Contains(lowerKey, "authorization"):
226 return MaskAuthorizationHeader(value)
227 case strings.Contains(lowerKey, "api-key"),
228 strings.Contains(lowerKey, "apikey"),
229 strings.Contains(lowerKey, "token"),
230 strings.Contains(lowerKey, "secret"):
231 return HideAPIKey(value)
232 default:
233 return value
234 }
235}
236
237// MaskSensitiveQuery masks sensitive query parameters, e.g. auth_token, within the raw query string.
238func MaskSensitiveQuery(raw string) string {

Callers 3

writeRequestInfoWithBodyFunction · 0.92
formatRequestInfoMethod · 0.92
writeHeadersFunction · 0.92

Calls 2

MaskAuthorizationHeaderFunction · 0.85
HideAPIKeyFunction · 0.85

Tested by

no test coverage detected