RedactionEngine

class RedactionEngine(headerPredicates: List<(String) -> Boolean> = emptyList(), propertyPredicates: List<(String) -> Boolean> = emptyList(), queryParamPredicates: List<(String) -> Boolean> = emptyList(), bodyTransforms: List<(String) -> String> = emptyList(), placeholder: String = DEFAULT_PLACEHOLDER)

Replaces sensitive header/property values with a visible placeholder so the reader can see that a field exists without exposing its value, and runs the host's body transforms. Predicates are offered the name as captured and, when it differs, its lowercase form — HTTP/2 sends header names lowercase, so a rule written either way still matches. Defaults cover the usual auth headers and query parameters; the host adds more via the config DSL. A throwing predicate counts as a match (fail closed) — a broken host lambda must never leak a value.

Constructors

Link copied to clipboard
constructor(headerPredicates: List<(String) -> Boolean> = emptyList(), propertyPredicates: List<(String) -> Boolean> = emptyList(), queryParamPredicates: List<(String) -> Boolean> = emptyList(), bodyTransforms: List<(String) -> String> = emptyList(), placeholder: String = DEFAULT_PLACEHOLDER)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

Rewrite a captured body preview through the host's transforms, in registration order. A throwing transform replaces the whole text instead of leaking the unsanitized original.

Link copied to clipboard

Redact a name=value&… form body with the same rules redactUrl applies to a query string — a POST of password=…&client_secret=… is exactly as sensitive as the same pair in a URL. Pure string transform, so names are matched as sent: a percent-encoded name doesn't match.

Link copied to clipboard
fun redactHeader(name: String, value: String): KeyValue
Link copied to clipboard
Link copied to clipboard

Redact sensitive parameter values in url — in the query string and in the fragment alike. An OAuth implicit-flow redirect carries its token only in #access_token=…, often with no query string at all. A fragment that isn't a name=value list (#section, #/route) has nothing to match and passes through. Pure string transform — no URL parsing dependency — so malformed URLs pass through untouched.