redact

package
v0.3.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package redact provides the process-wide canonical secret redactor.

Index

Constants

View Source
const Marker = "[REDACTED]"

Marker is the canonical replacement for secret material in public text.

Variables

This section is empty.

Functions

func ClaimTokens

func ClaimTokens(value string) string

ClaimTokens removes raw task-claim bearer tokens without applying other redaction rules.

func ContainsRawClaimToken

func ContainsRawClaimToken(value string) bool

ContainsRawClaimToken reports whether value contains a concrete task-claim bearer token.

func Enabled

func Enabled() bool

Enabled reports the process-snapshotted additive heuristic setting.

func IsSensitiveKey

func IsSensitiveKey(key string) bool

IsSensitiveKey reports whether a field name belongs to the shared secret taxonomy.

func RegisterDynamicSecret

func RegisterDynamicSecret(value string) func()

RegisterDynamicSecret includes runtime-resolved material in subsequent redaction calls. The returned cleanup is idempotent and removes one registration reference.

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.

func String

func String(value string) string

String removes canonical, heuristic, and runtime-registered secret shapes from text.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine applies exact protections and optional conservative heuristics.

func New

func New(opts Options) *Engine

New constructs an independent redaction engine.

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) RedactLogAttrs

func (e *Engine) RedactLogAttrs(attrs []slog.Attr) []slog.Attr

RedactLogAttrs applies field-aware redaction while preserving correlation, numeric, boolean, duration, time, and other structured envelope values.

func (*Engine) RedactString

func (e *Engine) RedactString(value string) string

RedactString removes secret material from free text.

type Options

type Options struct {
	// Disabled turns off additive provider-prefix and entropy heuristics. Exact
	// claim, assignment, reference, and registered-secret protection remains active.
	Disabled bool
}

Options configures one independent redaction engine.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL