redact

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package redact provides log redaction functionality to prevent secret leakage in CI logs.

Index

Constants

This section is empty.

Variables

View Source
var DefaultMode = func() Mode {
	if isCI() {
		return ModeBasic
	}
	return ModeOff
}()

DefaultMode is the default redaction mode when running in CI. It's "basic" when CI is detected, "off" otherwise.

Functions

This section is empty.

Types

type Config

type Config struct {
	Mode        Mode   // Redaction mode: off, basic, aggressive
	CustomKeys  string // Comma-separated list of custom key patterns (e.g., "MY_API_KEY,SECRET_TOKEN")
	Replacement string // Replacement string (default: "***REDACTED***")
}

Config holds configuration for a Redactor.

type Mode

type Mode string

Mode represents the redaction mode.

const (
	// ModeOff disables redaction.
	ModeOff Mode = "off"
	// ModeBasic enables basic redaction (default in CI).
	ModeBasic Mode = "basic"
	// ModeAggressive enables aggressive redaction with high-entropy detection.
	ModeAggressive Mode = "aggressive"
)

type Redactor

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

Redactor handles log redaction.

func New

func New(cfg Config) *Redactor

New creates a new Redactor with the given configuration.

func RedactFromEnv

func RedactFromEnv() *Redactor

RedactFromEnv creates a Redactor from environment variables. Uses HOLON_LOG_REDACT for mode and HOLON_LOG_REDACT_KEYS for custom keys.

func (*Redactor) Redact

func (r *Redactor) Redact(data []byte) ([]byte, error)

Redact redacts sensitive content from the input data.

func (*Redactor) RedactFile

func (r *Redactor) RedactFile(path string) error

RedactFile reads a file, redacts sensitive content, and writes it back.

Jump to

Keyboard shortcuts

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