redact

package
v0.78.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package redact masks the values of secret flow inputs and secret node outputs in everything the runner reports back — node results, the flow result, and progress events. It is applied once, at the boundary where results leave the runner, so the engine keeps working with the real values while a flow runs.

Index

Constants

View Source
const Mask = "***"

Mask is what a secret value is replaced with.

Variables

This section is empty.

Functions

func Learn added in v0.77.0

func Learn(ctx context.Context, value any)

Learn adds value to the Redactor ctx carries, and does nothing when ctx carries none.

func WithLearner added in v0.77.0

func WithLearner(ctx context.Context, r *Redactor) context.Context

WithLearner returns ctx carrying r, so code running anywhere under it, including nested module, loop and poll bodies, can add secret values to the run's redaction with Learn.

Types

type Redactor

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

Redactor masks a set of secret values. A nil or zero Redactor is a valid no-op. Learn grows the set while a run executes, so a value a node extracts into a secret output is masked in everything reported after it.

func New

func New(inputs map[string]any, secretKeys []string) *Redactor

New returns a Redactor for the values of the inputs named by secretKeys, or nil when none of them holds a non-empty value.

func NewFromSources added in v0.52.0

func NewFromSources(sources ...Source) *Redactor

NewFromSources returns one Redactor for secret values drawn from multiple independent input maps. Duplicate values are kept only once.

func (*Redactor) Error

func (r *Redactor) Error(err error) error

Error returns err with its message masked, preserving a UserError's code so the engine's user-fault classification survives.

func (*Redactor) FlowResult

func (r *Redactor) FlowResult(result *spi.FlowExecutionResult) *spi.FlowExecutionResult

FlowResult returns a masked copy of the flow result and of every node result it carries.

func (*Redactor) Learn added in v0.77.0

func (r *Redactor) Learn(value any)

Learn adds the text of value to the masked set. A map or slice contributes each of its leaves. Empty text is ignored, as is a value already masked.

func (*Redactor) Map

func (r *Redactor) Map(values map[string]any) map[string]any

Map is Value for a map, keeping the map type. A value that cannot be normalized yields an empty map rather than the original.

func (*Redactor) Result

func (r *Redactor) Result(result spi.AnyResult) spi.AnyResult

Result returns a masked copy of result. The original is left untouched: while a flow runs it is still the engine's live value, feeding downstream nodes.

func (*Redactor) Text

func (r *Redactor) Text(s string) string

Text masks every secret occurrence in s.

func (*Redactor) Value

func (r *Redactor) Value(v any) any

Value returns a masked copy of v.

v is first normalized to the JSON shape it reports on the wire, then every string leaf of that tree is masked. Scanning the decoded tree rather than the encoded text is what makes the scan sound: json.Marshal escapes &, <, >, " and \, so a secret holding any of them has no literal form in the encoded bytes. Object keys are left alone, so no contract field can be renamed or dropped, and the result is always valid JSON.

A value that cannot be normalized is replaced by the mask. This is a security seam: it fails closed.

type Source added in v0.52.0

type Source struct {
	Inputs     map[string]any
	SecretKeys []string
}

Source identifies secret-bearing values by key. Callers may provide one source for root inputs and additional sources for referenced-flow overrides.

Jump to

Keyboard shortcuts

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