redact

package
v0.2.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0, Apache-2.0 Imports: 7 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

Vendored from bot-agent internal/agent/redact (Apache-2.0, see ../NOTICE). DD changes: encoding/json replaces bot-agent's protocol.Marshal; Values and Empty are added.

Package redact applies the contract's cmdline rule before a value is sent.

Vendored from bot-agent internal/agent/redact (Apache-2.0, see ../NOTICE).

Index

Constants

View Source
const (
	// CmdlineMax is bot-agent's protocol.CmdlineMax (DD: kept local).
	CmdlineMax = 1024
	// JournalLineMax is the per-line cap for program logs (v1.3).
	JournalLineMax = 2048
	// JournalBytes is the total cap for one program log result.
	JournalBytes = 64 * 1024
)

Variables

This section is empty.

Functions

func Cmdline

func Cmdline(s string) string

Cmdline replaces URL userinfo and secret assignments, then truncates to 1024 characters. Invalid UTF-8 is dropped so the frame stays valid JSON.

func Journal

func Journal(lines []string) ([]string, bool)

Journal redacts each line, caps each line at 2048 characters, and keeps the newest lines that fit in 64 KiB. truncated is set when a line or the total was cut. journalctl prints the oldest of the window first, so lines dropped from the front are the older ones.

func JournalTask

func JournalTask(lines []string, ex Exact) ([]string, bool)

JournalTask is Journal with this set applied to each line before the caps.

func SecretPreview

func SecretPreview(v string) string

SecretPreview is copied verbatim from bot-api-server/internal/catalog/preview.go. SecretPreview is the v1.13 preview of one secret value. Sixteen or more runes show the first four runes and an ellipsis (U+2026). Fewer runes show four bullets (U+2022). The value itself is never returned.

Types

type Exact

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

Exact is the per-task set of secret values. It replaces each value of at least 6 bytes, plus its base64 and JSON-escaped forms, before the v1.0.1 regex. NewExact uses [REDACTED]. NewExactEnv uses the preview of the raw value. The set is not a secrecy boundary: a value can still be printed in some other encoding.

func Merge

func Merge(parts ...Exact) Exact

Merge joins sets. Forms are longest first. The same form keeps [REDACTED] when either set uses it; otherwise the earlier set wins.

func NewExact

func NewExact(values ...string) Exact

NewExact builds the set. Values shorter than 6 bytes are left out. The same bytes are also stored as standard and URL base64, padded and raw, and as a JSON string body with HTML escaping off and on. Every form is replaced with [REDACTED].

func NewExactEnv

func NewExactEnv(values ...string) Exact

NewExactEnv is NewExact for env secret values. Every form of a value is replaced with SecretPreview of that raw value.

func (*Exact) Clear

func (e *Exact) Clear()

Clear drops the set. Go strings cannot be overwritten in place; the caller also has to drop every other copy of the values.

func (Exact) Empty

func (e Exact) Empty() bool

Empty reports whether the set holds no value.

func (Exact) Payload

func (e Exact) Payload(v map[string]any) map[string]any

Payload redacts free text and leaves object keys alone. outcome, digest, exit_code, and every status field are copied through, so the exact set and the v1.0.1 regex do not run on them. Numbers stay integers when they were integers.

func (Exact) Text

func (e Exact) Text(s string) string

Text applies this set and then the regex.

func (Exact) Values

func (e Exact) Values(s string) string

Values applies only this set (no keyword regex). DD's job logs keep words such as "token" readable; only the host's actual secret values go.

Jump to

Keyboard shortcuts

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