redact

package
v0.6.96 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package redact hides the secret fields of payloads before the console sees them: the input and output of hooks, activities and workflows and the payloads of events, by the schemas their manifests declare, and the inputs of binding steps by the schemas the compiler derives from what their expressions read.

Masking is for display. It changes JSON text going to the console and nothing stored: Temporal history, NATS streams and the services' own logs hold the payloads as they were.

Index

Constants

View Source
const Hidden = "***"

Hidden replaces a secret value.

Variables

This section is empty.

Functions

func All

func All(data []byte) []byte

All is data hidden whole: Hidden as a JSON string. Empty stays empty: there was nothing to show.

func EventSchema

func EventSchema(cat Catalog, full string) *sp.Schema

EventSchema is the schema of an event, nil when the catalog has none.

func Mask

func Mask(schema *sp.Schema, data []byte) []byte

Mask is data (JSON) with every field schema marks secret replaced by Hidden, through objects, refs, lists, maps and one-ofs. Without a schema, or when data is not a JSON object, data returns as is: nothing says what is secret. The result is JSON with sorted keys.

func MaskString

func MaskString(schema *sp.Schema, text string) string

MaskString is Mask over JSON text.

Types

type Catalog

type Catalog interface {
	Hook(full string) (*backplanev1.Hook, bool)
	Activity(full string) (*backplanev1.Activity, bool)
	Event(full string) (*backplanev1.Event, bool)
	Workflow(full string) (*backplanev1.Workflow, bool)
}

Catalog resolves full names ("<service>.<Name>") to what the manifests declare: the schemas payloads are masked by.

type History

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

History masks the payloads of one run's history as it is read, in order: the start tells what the run is — a binding or rule run with its program, a hook call, an activity run, a declared workflow — and each scheduled call what its result is masked by. Payloads come and go as the console's JSON text: envelopes (HookCall, ActivityCall and their results) with their payload unwrapped to the JSON it carries.

func NewHistory

func NewHistory(cat Catalog) *History

NewHistory is the masker of one run; cat may be nil when only binding runs are read.

func (*History) Completed

func (h *History) Completed(id int64, result string) string

Completed takes the result of the call scheduled by id and is it masked.

func (*History) Nexus

func (h *History) Nexus(id int64, input string) string

Nexus takes the input of a Nexus operation event id schedules — a hook call from a service's workflow — and is it masked.

func (*History) Result

func (h *History) Result(result string) string

Result is the run's result masked: a HookResult or ActivityResult envelope's payload, or a declared workflow's own JSON.

func (*History) Scheduled

func (h *History) Scheduled(id int64, input string) string

Scheduled takes the input of the call event id schedules — an activity task or a child workflow — and is it masked. In a binding run the program's step masks it (a label seen before is the step's undo); else the activity the envelope names.

func (*History) Started

func (h *History) Started(workflowType, service, input string) string

Started takes the run's input — the workflow type, the service of its task queue and the input's JSON text — and is the text masked.

type Manifests

type Manifests func(service string) *backplanev1.Manifest

Manifests is a Catalog over the latest manifest of each service (nil: none).

func (Manifests) Activity

func (m Manifests) Activity(full string) (*backplanev1.Activity, bool)

Activity implements Catalog.

func (Manifests) Event

func (m Manifests) Event(full string) (*backplanev1.Event, bool)

Event implements Catalog.

func (Manifests) Hook

func (m Manifests) Hook(full string) (*backplanev1.Hook, bool)

Hook implements Catalog.

func (Manifests) Workflow

func (m Manifests) Workflow(full string) (*backplanev1.Workflow, bool)

Workflow implements Catalog.

type Program

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

Program is what the console needs of a compiled binding or rule to mask its run: the schemas the compiler derived for the input, every step's calls and the result. It reads the program's serialized form (the workflow's input), so a run masks by the definition it ran, whatever the manifests say now.

func ParseProgram

func ParseProgram(data []byte) *Program

ParseProgram reads a marshaled program; a program that does not read has no steps and masks nothing.

func (*Program) MaskInput

func (p *Program) MaskInput(data []byte) []byte

MaskInput is the hook's input or the event's payload masked.

func (*Program) MaskResult

func (p *Program) MaskResult(data []byte) []byte

MaskResult is the hook's answer masked.

func (*Program) Step

func (p *Program) Step(label string) (*Step, bool)

Step is the step a call label names: segments "<step>" or "<step>[<item>]" joined by "." from the outermost for-each step in.

func (*Program) Steps

func (p *Program) Steps() []Step

Steps are the program's top-level steps in order.

type Step

type Step struct {
	Name     string
	Activity string
	Kind     backplanev1.ActivityKind
	// Parent is the path of the for-each steps the step is in, "a/b"; ""
	// at the top.
	Parent string
	// contains filtered or unexported fields
}

Step is one step of a program with its masks.

func (*Step) MaskInput

func (s *Step) MaskInput(data []byte) []byte

MaskInput is the step's activity input masked.

func (*Step) MaskOutput

func (s *Step) MaskOutput(data []byte) []byte

MaskOutput is the step's activity output masked.

func (*Step) MaskUndo

func (s *Step) MaskUndo(data []byte) []byte

MaskUndo is the step's undo input masked: by its own undo input's schema, else — the undo runs on the step's output — by the output's.

Jump to

Keyboard shortcuts

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