Documentation
¶
Overview ¶
Package redact masks secrets in text before it is written to disk.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Formats = []Format{ {"private key", regexp.MustCompile(`-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----`)}, {"AWS access key", regexp.MustCompile(`\b(?:AKIA|ASIA)[0-9A-Z]{16}\b`)}, {"Anthropic API key", regexp.MustCompile(`\bsk-ant-[A-Za-z0-9_\-]{20,}`)}, {"OpenAI API key", regexp.MustCompile(`\bsk-(?:proj-|svcacct-)?[A-Za-z0-9_\-]{20,}`)}, {"Google API key", regexp.MustCompile(`\bAIza[0-9A-Za-z_\-]{35}\b`)}, {"GitHub token", regexp.MustCompile(`\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{36,}\b`)}, {"GitHub token", regexp.MustCompile(`\bgithub_pat_[A-Za-z0-9_]{60,}\b`)}, {"GitLab token", regexp.MustCompile(`\bglpat-[A-Za-z0-9_\-]{20,}\b`)}, {"Slack token", regexp.MustCompile(`\bxox[abprs]-[A-Za-z0-9\-]{10,}`)}, {"Stripe key", regexp.MustCompile(`\b(?:sk|rk)_live_[A-Za-z0-9]{20,}\b`)}, {"Hugging Face token", regexp.MustCompile(`\bhf_[A-Za-z0-9]{30,}\b`)}, {"JWT", regexp.MustCompile(`\beyJ[A-Za-z0-9_\-]{8,}\.[A-Za-z0-9_\-]{8,}\.[A-Za-z0-9_\-]{8,}`)}, }
Formats are the credential formats Blitz knows, the one table the redactor, the secrets guardrail's description and the secret scan (pkg/secretscan, its hook's pattern too) read.
Functions ¶
func Mask ¶ added in v0.7.1
Mask masks only the remembered values in s (not the patterns): for text shown as it is, such as a model's answer.
Types ¶
type Format ¶ added in v0.9.1
Format is a credential format: what it is, and a pattern that matches one whole.
type Redactor ¶
type Redactor struct {
// contains filtered or unexported fields
}
Redactor masks known secret formats plus specific secret values.
func FromEnv ¶
FromEnv returns a redactor for the values of environment variables whose names match any of the glob patterns (case-insensitive), e.g. "*_API_KEY".
func New ¶
New returns a redactor that also masks the given literal values (ignoring ones shorter than 8 characters, which would cause false positives).
func (*Redactor) Longest ¶ added in v0.9.1
Longest is the length of the longest value r masks, its own or remembered (0 for none): text streamed in pieces is held at least this long so a value is whole when it's checked. A nil Redactor has the remembered ones.