Documentation
¶
Overview ¶
Package redact provides the process-wide canonical secret redactor.
Index ¶
- Constants
- func ClaimTokens(value string) string
- func ClaimTokensJSON(raw json.RawMessage) json.RawMessage
- func ContainsRawClaimToken(value string) bool
- func ContainsRegisteredSecret(value string) bool
- func CrossScopeJSON(raw json.RawMessage) json.RawMessage
- func CrossScopeString(value string) string
- func Enabled() bool
- func ExactBinaryJSON(raw json.RawMessage) (json.RawMessage, error)
- func ExactBinaryString(value string) string
- func ExactBytes(value []byte) []byte
- func ExactJSON(raw json.RawMessage) (json.RawMessage, error)
- func ExactString(value string) string
- func IsSensitiveKey(key string) bool
- func RegisterDynamicSecret(value string) func()
- func RegisterRequiredSecret(value string) func()
- func SnapshotEnabled(enabled bool)
- func String(value string) string
- type Engine
- func (e *Engine) RedactJSON(raw json.RawMessage, fields []string) json.RawMessage
- func (e *Engine) RedactJSONEverywhere(raw json.RawMessage) json.RawMessage
- func (e *Engine) RedactJSONWithProtectedStrings(raw json.RawMessage, fields []string, ...) json.RawMessage
- func (e *Engine) RedactJSONWithProtection(raw json.RawMessage, fields []string, ...) json.RawMessage
- func (e *Engine) RedactLogAttrs(attrs []slog.Attr) []slog.Attr
- func (e *Engine) RedactString(value string) string
- type Options
Constants ¶
const Marker = "[REDACTED]"
Marker is the canonical replacement for secret material in public text.
Variables ¶
This section is empty.
Functions ¶
func ClaimTokens ¶
ClaimTokens removes raw task-claim bearer tokens without applying other redaction rules.
func ClaimTokensJSON ¶
func ClaimTokensJSON(raw json.RawMessage) json.RawMessage
ClaimTokensJSON removes raw claim-token fields and values from a JSON payload. Invalid input is materialized as a JSON string so wire callers never emit malformed JSON.
func ContainsRawClaimToken ¶
ContainsRawClaimToken reports whether value contains a concrete task-claim bearer token.
func ContainsRegisteredSecret ¶
ContainsRegisteredSecret reports whether value contains runtime-registered secret material.
func CrossScopeJSON ¶
func CrossScopeJSON(raw json.RawMessage) json.RawMessage
CrossScopeJSON redacts every string of a JSON document read across a workspace or profile boundary. Structural identifiers (`*_id`, hashes, cursors) stay readable; sensitive field names are blanked wholesale.
func CrossScopeString ¶
CrossScopeString redacts free text read across a workspace or profile boundary.
func Enabled ¶
func Enabled() bool
Enabled reports the process-snapshotted additive heuristic setting.
func ExactBinaryJSON ¶
func ExactBinaryJSON(raw json.RawMessage) (json.RawMessage, error)
ExactBinaryJSON removes literal secrets and whole JSON strings whose decoded bytes contain a registered secret.
func ExactBinaryString ¶
ExactBinaryString removes literal and reversibly encoded registered secrets from text.
func ExactBytes ¶
ExactBytes removes registered secrets from an opaque byte payload.
func ExactJSON ¶
func ExactJSON(raw json.RawMessage) (json.RawMessage, error)
ExactJSON removes canonical and registered secrets from JSON keys and string values.
func ExactString ¶
ExactString removes canonical and registered secrets without additive heuristics.
func IsSensitiveKey ¶
IsSensitiveKey reports whether a field name belongs to the shared secret taxonomy.
func RegisterDynamicSecret ¶
func RegisterDynamicSecret(value string) func()
RegisterDynamicSecret registers heuristic runtime material and returns an idempotent cleanup.
func RegisterRequiredSecret ¶
func RegisterRequiredSecret(value string) func()
RegisterRequiredSecret registers nonblank caller-classified secret material and returns an idempotent cleanup.
func SnapshotEnabled ¶
func SnapshotEnabled(enabled bool)
SnapshotEnabled freezes the process-wide additive heuristic setting. Later calls cannot change it; configuration changes therefore require a restart.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine applies exact protections and optional conservative heuristics.
func (*Engine) RedactJSON ¶
func (e *Engine) RedactJSON(raw json.RawMessage, fields []string) json.RawMessage
RedactJSON applies exact protection throughout a JSON document and additive heuristics only within the named free-text fields.
func (*Engine) RedactJSONEverywhere ¶
func (e *Engine) RedactJSONEverywhere(raw json.RawMessage) json.RawMessage
RedactJSONEverywhere applies exact protection and the additive heuristics to every string in a JSON document, keeping only structural identifier fields.
func (*Engine) RedactJSONWithProtectedStrings ¶
func (e *Engine) RedactJSONWithProtectedStrings( raw json.RawMessage, fields []string, protect func(path []string, value string) bool, ) json.RawMessage
RedactJSONWithProtectedStrings applies RedactJSON while preserving scalar strings that the caller identifies as public structural handles. The predicate is evaluated only after key-based secret protection, so a sensitive field name can never opt out of redaction. Paths contain object keys; array elements inherit the enclosing field's path.
func (*Engine) RedactJSONWithProtection ¶
func (e *Engine) RedactJSONWithProtection( raw json.RawMessage, fields []string, protectString func(path []string, value string) bool, protectObject func(path []string, value any) bool, ) json.RawMessage
RedactJSONWithProtection extends RedactJSONWithProtectedStrings with a structural predicate. It is consulted only for a sensitive field name, with that field's path; an accepted value is traversed normally instead of being replaced wholesale, so its strings still get exact secret redaction.
func (*Engine) RedactLogAttrs ¶
RedactLogAttrs applies field-aware redaction while preserving correlation, numeric, boolean, duration, time, and other structured envelope values.
func (*Engine) RedactString ¶
RedactString removes secret material from free text.