redact

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package redact masks credentials in text that leaves the process. It is a stdlib-only leaf so that config, which may import nothing internal, masks what it renders for a page with the same rule shell uses for an error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Command

func Command(command string) string

Command masks the credentials a URL in command carries, for any copy of a command that leaves the process as text: an error, a log line, a run event, a page. A source: is routinely rendered into a command as https://user:token@host, and errors are persisted and shown in the browser. The command that is EXECUTED is never redacted.

func WithSecrets added in v0.3.0

func WithSecrets(ctx context.Context, s *Secrets) context.Context

WithSecrets carries a run's values to everything that records its output.

Types

type Scrubber added in v0.3.0

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

Scrubber holds back a tail that is the start of a value, so a value split across two writes is still whole when it is masked.

func (*Scrubber) Flush added in v0.3.0

func (sc *Scrubber) Flush() error

Flush writes what Write held back; call it once the stream has ended.

func (*Scrubber) Write added in v0.3.0

func (sc *Scrubber) Write(p []byte) (int, error)

type Secrets added in v0.3.0

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

Secrets is one run's resolved values, growing as the run resolves more; a nil *Secrets scrubs nothing.

func SecretsFrom added in v0.3.0

func SecretsFrom(ctx context.Context) *Secrets

SecretsFrom is the run's values, nil when the run resolves none.

func (*Secrets) Add added in v0.3.0

func (s *Secrets) Add(value string)

Add keeps each line of a multi-line value as its own entry because a PEM key is usually printed a line at a time.

func (*Secrets) Empty added in v0.3.0

func (s *Secrets) Empty() bool

Empty is whether there is nothing to mask, so a caller can skip copying through a scrubber.

func (*Secrets) Error added in v0.3.0

func (s *Secrets) Error(err error) error

Error masks err's text and keeps its chain, so errors.Is and errors.As still classify it; nil and an error with nothing to mask pass through.

func (*Secrets) String added in v0.3.0

func (s *Secrets) String(text string) string

String masks every registered value in text.

func (*Secrets) Writer added in v0.3.0

func (s *Secrets) Writer(w io.Writer) *Scrubber

Writer scrubs a stream before it reaches w; Flush hands over the bytes it holds back.

Jump to

Keyboard shortcuts

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