redact

package
v0.2.1 Latest Latest
Warning

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

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

Package redact holds the credential-scrubbing primitives: the patterns that recognise a credential in arbitrary text, and the key-name test that recognises one by the name it is stored under.

It lives here, below everything, because there are now TWO consumers with the same requirement and they must not drift: `dash` scrubs before writing a captured request to disk, and `internal/logging` scrubs before writing a log record to stderr or to Loki. A second copy of these patterns would be a second thing to keep current, and the first one forgotten is a leak. `dash` is the historical home (dash/redact.go) and keeps its allowlists — those are about the dashboard's own data shapes; only the credential vocabulary moved.

The reasoning for each mechanism is documented where it is used: see dash/redact.go for why config keys are allowlisted by name, and why content — arbitrary agent output — can only get pattern-based scrubbing plus a size cap.

Index

Constants

View Source
const Redacted = "«redacted»"

Redacted is the placeholder written in place of any redacted value. It is deliberately visible: a blank would read as "the field was empty".

Variables

This section is empty.

Functions

func Content

func Content(s string, cap int) string

Content scrubs credential-shaped substrings from arbitrary text and caps its length. cap<=0 means no cap. The cap is applied AFTER scrubbing so a secret near the end cannot survive by being truncated into place.

func IsSecretKey

func IsSecretKey(k string) bool

IsSecretKey reports whether a key NAME says "the value under me is a credential". Case-insensitive; callers need not normalise.

func URLCredentials

func URLCredentials(s string) string

URLCredentials replaces only the password in a `scheme://user:pass@host` URL, leaving the scheme, the user and the host visible — a wholly redacted URL would make an upstream field useless for the thing it exists to answer ("where is this pointing?").

Types

This section is empty.

Jump to

Keyboard shortcuts

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