Redacts credentials and sensitive data from text logs and activity trails.
// Source: https://github.com/Untrivial-ai/agent-orchestrator | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package activity
import (
"regexp"
"strings"
"unicode/utf8"
)
// redactedMarker replaces anything that looks like a credential.
const redactedMarker = "[REDACTED]"
type redaction struct {
pattern *regexp.Regexp
replacement string
}
var redactions = []redaction{
// Whole header values: "Authorization: Worker abc", "Cookie: a=b; c=d".
{regexp.MustCompile(`(?i)\b((?:proxy-)?authorization|cookie|set-cookie)(\s*[:=]\s*)[^\n]*`), "${1}${2}" + redactedMarker},
// Bearer and basic credentials anywhere in text.
{regexp.MustCompile(`(?i)\b(bearer|basic)\s+[A-Za-z0-9
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key