Redaction

class Redaction(keepQueryParams: Set<String> = emptySet(), extraSensitiveQueryParams: Set<String> = emptySet(), secrets: List<String> = emptyList(), val placeholder: String = DEFAULT_PLACEHOLDER)(source)

What a FixtureRecorder hides: sensitive query names (by token, see the recorder's KDoc) less the keepQueryParams, plus the extraSensitiveQueryParams; and caller-supplied secrets, each replaced by placeholder wherever it appears in the whole serialised file (comment and body included) as raw text, as addQueryParameter encodes it and as java.net.URLEncoder encodes it. After the replacement the file is searched again for those forms, their lower-case-hex variants and the full percent-escape of the secret's bytes; a file in which one survives is refused. That search is a backstop over the exact forms, not a decoder of transformed ones: a secret echoed as base64, hashed, truncated, or percent-escaped only in part (e.g. SECRET%2dCANARY for SECRET-CANARY) is neither replaced nor detected.

Stable Core, source compatibility only. Immutable and safe to share. Equality is identity. toString() prints the three list sizes and never a name or a secret; the require messages never hold a secret.

Parameters

keepQueryParams

query names that are never redacted even when their tokens look sensitive (for example sort_key); compared ASCII case-insensitively.

extraSensitiveQueryParams

query names redacted in addition to the token rule; compared ASCII case-insensitively.

secrets

exact values to replace wherever they appear; each at least MIN_SECRET_LENGTH characters and well-formed Unicode.

placeholder

the replacement text; DEFAULT_PLACEHOLDER by default.

Throws

if placeholder is empty or holds CR, LF or NUL; if a secret is shorter than MIN_SECRET_LENGTH or holds an unpaired surrogate; or if a secret contains or is contained in placeholder (every write would then be refused).

Constructors

Link copied to clipboard
constructor(keepQueryParams: Set<String> = emptySet(), extraSensitiveQueryParams: Set<String> = emptySet(), secrets: List<String> = emptyList(), placeholder: String = DEFAULT_PLACEHOLDER)

Types

Link copied to clipboard
object Companion

The defaults.

Properties

Link copied to clipboard

The text that replaces a redacted value.

Functions

Link copied to clipboard
open override fun toString(): String

A diagnostic string for logs: the three list sizes, never a name or a secret. Its format is not part of the API and may change.