redaction

package
v0.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package redaction handles secret redaction

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Custom patterns to redact (e.g. "INT-[A-Z0-9]{16}")
	Patterns []string
	// JSON paths to always redact (e.g. "config.password")
	Paths []string
	// If true, replace with hash instead of [REDACTED]
	HashMode bool
	// Salt for hashing (prevents rainbow tables). If empty, hash is deterministic but unsalted.
	Salt string
	// If true, disable gitleaks detector and use only custom patterns
	// Default: false (gitleaks enabled for comprehensive 222+ pattern coverage)
	DisableGitleaks bool
}

Config holds the configuration for the Redactor.

type Redactor

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

Redactor handles sanitization of sensitive data. All fields are read-only after construction, making it safe for concurrent use.

func New

func New(cfg Config) (*Redactor, error)

New creates a new Redactor with the given configuration.

func (*Redactor) Redact

func (r *Redactor) Redact(data interface{}) interface{}

Redact sanitizes the given data structure. It modifies the data in-place if it's a pointer, or returns a new copy. Supported types: string, []interface{}, map[string]interface{}, and pointers to them.

func (*Redactor) ScrubString

func (r *Redactor) ScrubString(input string) string

ScrubString replaces sensitive patterns in a string. Uses gitleaks detector (222+ patterns) first, then falls back to regex patterns.

type Writer

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

Writer wraps an io.Writer and redacts all data before writing. Thread-safe: can be used concurrently by multiple goroutines.

func NewWriter

func NewWriter(w io.Writer, r *Redactor) *Writer

NewWriter creates a redacting writer that scrubs sensitive patterns.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Write implements io.Writer, redacting data before passing to underlying writer.

Jump to

Keyboard shortcuts

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