Documentation
¶
Overview ¶
Package secret keeps secret values (GitLab tokens, API keys) out of logs, errors, and any user-facing output.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogHandler ¶
type LogHandler struct {
// contains filtered or unexported fields
}
LogHandler wraps a slog.Handler so every message and attribute value is redacted before it reaches the underlying handler.
func NewLogHandler ¶
func NewLogHandler(inner slog.Handler, r *Redactor) *LogHandler
NewLogHandler wraps inner with redaction from r.
type Redactor ¶
type Redactor struct {
// contains filtered or unexported fields
}
Redactor replaces registered secret values with a placeholder wherever they appear in strings, errors, or log records. It is safe for concurrent use.
func NewRedactor ¶
NewRedactor returns a Redactor for the given values. Empty values are ignored.
func (*Redactor) Add ¶
Add registers another secret value to redact. Empty and very short values are ignored: redacting them would mangle unrelated text.
func (*Redactor) RedactError ¶
RedactError returns an error whose message has secrets redacted. The original error chain is preserved via %w only when nothing was redacted; otherwise the sanitized message replaces the chain so the secret cannot be recovered through Unwrap.