redact

package
v0.20.7 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package redact applies provider-declared redaction rules to resource AttributesJSON at the store boundary.

Provider packages register per-type rules in their init() blocks alongside scanner registration. Store.UpsertResources calls Apply once per row before insert — providers must not pre-sanitize.

Index

Constants

View Source
const Placeholder = "[REDACTED]"

Placeholder replaces redacted scalar values.

Variables

This section is empty.

Functions

func Apply

func Apply(resourceType, attributesJSON string) string

Apply walks attributesJSON under every rule registered for resourceType. Returns the input unchanged when no rules exist or JSON parse fails.

func HasRules

func HasRules(resourceType string) bool

HasRules reports whether any rule is registered for resourceType.

func Register

func Register(r TypeRules)

Register installs r in the registry. Subsequent Register calls for the same Type append rules — useful when scanner + resolver files in the same package each declare their own Rules.

Types

type Mode

type Mode int

Mode picks how a terminal value is redacted.

const (
	// RedactScalar replaces a scalar leaf with Placeholder. Object/array
	// values at the terminal pass through untouched.
	RedactScalar Mode = iota
	// RedactSubtree wholesale-redacts every scalar descendant of the
	// terminal node.
	RedactSubtree
)

type Rule

type Rule struct {
	Path string
	Mode Mode
}

Rule names a path inside AttributesJSON and the redaction mode.

type TypeRules

type TypeRules struct {
	Type       string
	Attributes []Rule
}

TypeRules bundles every Rule for one resource type.

Jump to

Keyboard shortcuts

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