Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Patterns []Pattern `json:"patterns"`
}
Config represents the redaction configuration
type Pattern ¶
type Pattern struct {
Name string `json:"name"`
Pattern string `json:"pattern,omitempty"`
Type string `json:"type"`
CaptureGroup int `json:"capture_group,omitempty"`
// FieldPattern is a regex that matches JSON field names. When set, only
// values of matching fields are considered for redaction.
FieldPattern string `json:"field_pattern,omitempty"`
}
Pattern represents a single redaction pattern.
There are two modes of operation:
- Value-based (FieldPattern empty): The Pattern regex is applied to all string values in the JSON. Use this for secrets with distinctive formats that can appear anywhere (API keys, tokens, etc.).
- Field-based (FieldPattern set): Only values of fields whose names match FieldPattern are redacted. The Pattern regex (if set) is applied to the field value; if Pattern is empty, the entire value is redacted.
type Redactor ¶
type Redactor struct {
// contains filtered or unexported fields
}
Redactor handles redaction of sensitive data
func NewFromConfig ¶
func NewFromConfig(cfg *config.RedactionConfig) (*Redactor, error)
NewFromConfig creates a new Redactor from a config.RedactionConfig. Returns nil if cfg is nil or if no patterns are configured. Note: This function does NOT check cfg.Enabled - callers should check that. If UseDefaultPatterns is true (default), default patterns are included. Custom patterns from cfg.Patterns are added after default patterns.
func NewRedactor ¶
NewRedactor creates a new Redactor from a config
func (*Redactor) Redact ¶
Redact redacts sensitive data from a string using value-based patterns only. Field-based patterns are skipped since plain text has no field context.
func (*Redactor) RedactJSONL ¶
RedactJSONL redacts sensitive data from JSONL content by parsing each line, recursively redacting string values, and re-serializing. This ensures JSON structure is never corrupted by redaction patterns.
func (*Redactor) RedactJSONLine ¶
RedactJSONLine redacts a single JSON line, parsing it and applying redaction to string values only. Returns the redacted JSON. If the input is not valid JSON, falls back to text-based redaction.