Documentation
¶
Overview ¶
Package redact is THE ONE secret redactor: what looks like a credential in a line of text an agent or a page will be shown is replaced by Mark.
🔴 ONE COPY, EVERY CALLER. It was internal/mirrorhost's (the pending-action summary a waiting session sends, below) and moved here unchanged when the chief's sessions_overview began quoting session transcripts (internal/api's sessions_overview.go); the host also runs every field of a rendered view's transcript stream through it (internal/mirrorhost's redact_stream.go). A second redactor would drift from this one — the shapes it knows are a list that grows — so all of them call this.
Index ¶
Constants ¶
const Mark = "«redacted»"
Mark replaces each secret.
Variables ¶
This section is empty.
Functions ¶
func HasSecretLiteralIn ¶ added in v0.156.0
HasSecretLiteralIn is HasSecretValueIn without the env pair rule: the value and key rules, each judging one line (or a block scalar's start). It is the test for lines that are NOT a whole text, such as a diff's added lines spliced together: there the lines between them are missing, so items cannot be told apart, and the pair rule must run on each hunk's post-image instead (HasSecretPairIn with changed).
func HasSecretPairIn ¶ added in v0.156.0
HasSecretPairIn reports whether lines (a manifest's lines, in order) hold one YAML mapping whose credential-like `name:` (credKey: `name: DB_PASSWORD`) has a sibling `value:` holding a literal: the shape of a Kubernetes env entry, which the key rule cannot see because the name and the literal sit on different lines. A mapping is
- a block list item: its keys sit at the column after its `- `, and it ends at the next line left of or at its dash (the next `- ` item);
- a block mapping nested under a key, or at the top of a document (a kustomize JSON6902 patch's `value:` holding `name:` and `value:`): its keys share one column, and it ends at a line left of it or at `---`;
- a one-line flow mapping, anywhere on a line (`- {name: X, value: y}`, `value: {name: X, value: y}`, `env: [{name: X, value: y}]`), each one its own mapping.
A pair is never made across two mappings. `name:` and `value:` may come in either order. The literal rules are the key rule's (isLiteral), except that a QUOTED boolean or number is not a literal either (an env value must be a string: "true", "5432"); a quoted name or value may carry a comment after it. The pair is judged when either of its lines is marked in changed (nil: every line), so a diff's unchanged name line counts as context. A source file (sourceExts) is code: false.
Not seen (best effort): multi-line JSON, a dash alone on its line, a flow mapping that nests another, an alias whose anchor sits on another key.
func HasSecretValue ¶ added in v0.156.0
HasSecretValue reports whether s holds a secret-shaped VALUE: THE secret-shape test for a refusal of an officer's SHIP content (its pull request diff, title, body and comments; internal/officership's draft gate).
It refuses on EITHER of two rules:
- THE VALUE (Secrets, with one narrowing). Every shape Secrets knows by its VALUE (a token prefix, a PEM block, a JWT, a Stripe, age, Google, Hugging Face or Discord key, an AWS secret) refuses as it redacts. A shape Secrets knows only by a credential NAME (a header, "the password is …", a URL query parameter, and the key forms below) refuses on this rule when the value is itself secret-shaped (literalSecret). A URL's userinfo refuses when it holds a password that is not a reference.
- 🔴 THE KEY (keyLiteral). A credential-like KEY (one ending in password, passwd, passphrase, pwd, secret, token, api_key/apikey, private_key, secret_key, secret_access_key, credential or credentials; not access_key_id, an identifier) holding a LITERAL refuses, whatever the literal looks like: `password: hunter2`, a diceware passphrase, a letters-only word, a block scalar. Not a literal: an empty or null value, a boolean, a number, a reference (${…}, $(…), $VAR, {{…}}, valueFrom, a flow mapping, an alias, a <placeholder>), a SOPS ENC[…] value, a path or a URL — and a key that itself NAMES a reference (existingSecret…, passwordSecret, tokenSecret, …SecretName, …SecretRef, …secretKeyRef). So `automountServiceAccountToken: false`, `existingSecret: x`, `passwordSecret: x` and `password: ${DB_PASSWORD}` pass.
func HasSecretValueIn ¶ added in v0.156.0
HasSecretValueIn is HasSecretValue for content of the file at path. In a SOURCE file (sourceExts: Go, TypeScript, Python, …) an unquoted value is an expression (`Password: cfg.Password,`), so the key rule judges only a QUOTED string literal there; anywhere else (YAML, JSON, shell, .env, prose) every value is. s is a WHOLE text (a file, a title, a body): its lines are in order, so the env pair rule (HasSecretPairIn) runs on it too.
Types ¶
This section is empty.