Skip to main content

redact_string

Function
This function is defined in the redact module.
Redact potential secrets from a string. This is a best-effort function that looks for common patterns like “api_key=xxx” or “password: xxx” in strings, plus secrets carried in URLs (scheme://user:pass@host userinfo, ?token=xxx query params and /bot<id>:<token>/ path segments).

Signature

Parameters

str
required
String to redact
bool
default:"True"
If False, returns text unchanged

Returns

str
String with potential secrets redacted

Uses

  • _URL_USERINFO_PATTERN.sub
  • _URL_BOT_TOKEN_PATTERN.sub
  • _REDACT_KV_PATTERN.sub

Used By

Source

View on GitHub

praisonaiagents/trace/redact.py at line 233