redact

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package redact handles regex-based field redaction for Keep's redact action.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyMutations

func ApplyMutations(params map[string]any, mutations []Mutation) map[string]any

ApplyMutations returns a new params map with mutations applied. The original map is not modified. Deep-copies the map structure.

Types

type CompiledPattern

type CompiledPattern struct {
	Regex   *regexp.Regexp
	Replace string
}

CompiledPattern is a pre-compiled redact pattern.

func CompilePatterns

func CompilePatterns(patterns []config.RedactPattern) ([]CompiledPattern, error)

CompilePatterns compiles a list of config redact patterns into CompiledPatterns.

type Mutation

type Mutation struct {
	Path string
	// Original holds the pre-redaction value. It is populated for audit
	// purposes but MUST NOT be returned to the calling agent or exposed
	// externally. Callers should strip this field before serializing
	// the result outside the engine.
	Original string `json:"-"`
	Replaced string
}

Mutation describes a single field change.

func Apply

func Apply(params map[string]any, target string, patterns []CompiledPattern) []Mutation

Apply runs compiled patterns against the string value at the given field path in params. Returns the list of mutations (empty if no patterns matched). Does not modify params.

The target path uses the form "params.field" or "params.nested.field". The "params." prefix is stripped before navigating the map.

Jump to

Keyboard shortcuts

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