Documentation
¶
Overview ¶
Package redact finds secrets in text and replaces them with markers. It is used by seeders, which report where a secret is but never its value, and by the provider wrapper, which redacts everything sent to a model.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Hash ¶
Hash returns the 8 hex digit fingerprint used in markers and matches. It is keyed with a random value made when the process starts and kept only in memory, so the same secret gets the same marker within a run, which is all a reader needs to tell two secrets apart, but a marker cannot be checked against guesses offline, nor linked to the same secret in another run or repository.
func IsPlaceholder ¶
IsPlaceholder is isPlaceholder for seeders that find secret-looking values by structure and need the same notion of "obviously not real".
func KeepLines ¶ added in v0.2.0
KeepLines is Apply that keeps every line where it was: a secret that spans lines is replaced by its marker followed by the same number of newlines.
func Marker ¶
Marker returns the replacement text for a secret found by rule whose value hashes to hash. Seeders that redact a value they located by structure (a YAML node, an ENV instruction) use it so every redaction in Spackle looks the same and is skipped by a later Apply.
Types ¶
type Match ¶
type Match struct {
Rule string // rule name, see Rules
Start int // byte offset of the secret in the scanned text
End int // byte offset just past the secret
Line int // 1-based line of Start
Hash string // 8 hex digits of a keyed hash of the value, see Hash
}
Match is one secret found in a text. It deliberately has no field for the value: the hash is enough to tell two secrets apart and to recognize the same secret in two places without ever storing it.
func Apply ¶
Apply replaces each secret in text with "[REDACTED:<rule>:<hash>]" and returns the new text with the matches, whose offsets refer to the input.