Skip to main content

Module secret_redaction

Module secret_redaction 

Source
Expand description

Redaction of referenced and declared credential values in diagnostics.

Terms:

  • A reference names a secret in a configuration, such as ${secret:kubernetes:pg/uri}.
  • The value of a secret is its plaintext, which the pipeline reads from the secret store.
  • The resolver replaces each reference in a configuration with its value.
  • The registry, SecretRedactor, holds each resolved value with its reference.
  • A declared credential is the value of a configuration field that the schema of a connector marks as a credential. It can have no reference.

The resolver registers each value it resolves. Error responses, connector error lists, the panic hook and the pipeline log pass through the registry, so a value that a message copies by mistake leaves the process as its reference. This is a safety net: code that builds a diagnostic must not rely on it.

What replaces a registered value:

The text holdsIt becomes
the value, as resolved or trimmedthe reference
a form derived from the value: percent-encoded, percent-decoded, debug-escaped or JSON-escaped, or the password of a value that is a URL[REDACTED <reference>]
a declared credential with no reference, or a form derived from it[REDACTED]

The registry is process-wide and never logged or serialized. A value registered twice keeps its first reference; references take precedence over supplemental credential markers. Unit tests share it, so a test registers a value that no other message can contain.

Structs§

SecretRedactor
Registry of resolved secret values and the text that replaces each one.

Constants§

MIN_REDACTED_LEN
Shortest value the registry redacts, measured once the value is trimmed. A shorter value, such as 5432 or admin, also occurs in ordinary text, so it is not registered. Neither is a derived form shorter than this.

Functions§

secret_redactor
The registry of this process.