redact

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package redact removes credential shapes and personal paths from text that leaves the process: a bug report, a log line, an error string sent to telemetry.

It is pattern-based, so it is a backstop, not a guarantee: it catches the shapes credentials are usually written in (URL userinfo, key=value pairs with a credential-named key, bearer and basic schemes, JWTs, the key prefixes of the common providers, long opaque runs) and home directories, which name the person. Text that must never leave the process must not be handed to anything that sends it, redacted or not.

The credential patterns are the ones reliant redacts its agent bug reports with (reliant internal/telemetry), held here so forge, reliant and the control plane share one bar.

Index

Constants

View Source
const (
	// Marker replaces a redacted credential.
	Marker = "[redacted]"
	// TruncatedMarker ends text Bounded cut.
	TruncatedMarker = " [truncated]"
)

Variables

This section is empty.

Functions

func Bounded

func Bounded(s string, maxBytes int) string

Bounded is Text, cut to at most maxBytes UTF-8 bytes, including TruncatedMarker. Invalid UTF-8 is replaced before measuring; cuts never split a rune. A bound smaller than the marker retains only its ASCII prefix. maxBytes <= 0 means no bound. JSON escaping may expand the encoded representation; this bounds the decoded text, not the enclosing JSON.

func HomeDirs

func HomeDirs(s string) string

HomeDirs replaces every home directory in s (/home/<user>, /Users/<user>, C:\Users\<user>) with "~", keeping the rest of each path, so text still says which file without saying whose.

func Secrets

func Secrets(s string) string

Secrets replaces every credential shape in s with Marker.

func Text

func Text(s string) string

Text is Secrets and HomeDirs: what text bound for someone else's eyes needs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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