Documentation
¶
Overview ¶
Package redact removes secrets before anything reaches the log (SP2 §4, T8). It uses gitleaks' default rules; the test pins the four the design names.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrKeyCollision = errors.New("redact: two object keys are the same once redacted")
ErrKeyCollision reports two object keys that are one once NULs and secrets are removed. Keeping either would drop the other's value, and which one depends on map order, so the payload is refused. The error never quotes a key.
Functions ¶
This section is empty.
Types ¶
type Redactor ¶
type Redactor struct {
// contains filtered or unexported fields
}
Redactor applies gitleaks' default rules to text and JSON payloads.
func New ¶
New parses gitleaks' default configuration once. It also silences gitleaks' own global logger, which logs each finding's secret at Trace to stderr, outside slog: call it at startup, before any scan runs.
func (*Redactor) Payload ¶
func (r *Redactor) Payload(ctx context.Context, raw json.RawMessage) (json.RawMessage, []string, error)
Payload redacts every string of a JSON document, object keys included, and keeps its shape. Each string is scanned alone: a secret split across sibling fields is not detected, so callers must not split tokens.
It honours ctx between strings, and an ended ctx fails the whole payload: it is never returned partly scanned. One string's scan is not interruptible: gitleaks' ctx-aware entry point takes its deprecated Fragment type, and the caller's body limit bounds a string anyway.