DefaultRedactor

The default Redactor applied at capture time.

Redacts:

  • Header values to [REDACTED] for Authorization, Proxy-Authorization, Cookie, Set-Cookie, and any header whose NAME contains a sensitive token (e.g. X-Api-Key, X-Auth-Token), so custom auth headers are covered too. Well-known PUBLIC headers whose names merely resemble a secret (Access-Control-Allow-Credentials, WWW-Authenticate, Proxy-Authenticate) are exempt — they carry CORS metadata / server challenges, not credentials.

  • URL query parameters, JSON object fields, and form fields whose name contains a sensitive token (token, key, secret, password, passwd, pwd, auth, access_token, refresh_token, api_key, apikey, client_secret, session, credential, bearer, signature, sig). A name is split into words, at separators and camelCase humps, and the token must be in a word that isn't an ordinary one that happens to contain it, in any of its forms: author_name, authors, design, assignments, and keywords are kept, while authorization, accessToken, and presigned_url are masked. Names that hold no secret although they have a sensitive word are kept too, in any spelling: Idempotency-Key, public_key, and vapid_key; a token count or limit, where token or tokens sits next to a word such as max, total, count, remaining, prompt, or input, as in prompt_tokens, max_tokens, totalTokenCount, and x-ratelimit-remaining-tokens; a key that names a column, such as primary_key and partitionKey; and a yes-or-no flag about a secret, whose first word is is, has, can, or should, whose last word is exist, exists, enabled, disabled, enforced, required, or protected, or that asks for one, as in is_password_protected, passwordEnforced, and ask_for_password. This name check is SensitiveKeys.isSensitive, which other tabs use too.

  • The parts of a multipart/form-data body: a part whose field name is sensitive is masked whole, and any other part is redacted as a body of its own type, so a JSON part is redacted as JSON. A part's own headers are masked like a request's.

  • Sensitive values in any other captured text body — SSE, XML, plain text, and JSON that does not parse as a single object/array (NDJSON / concatenated frames) — via a framing-agnostic, key-name-based fallback. As on the structured path, a sensitive key's whole value is masked, whether a string, a number, or a nested object or array, and so is everything inside a sensitive XML element.

A captured body can end partway through a value, when it's cut off at the capture cap or captured while a stream is still arriving. A sensitive value cut off that way is masked through to the end of the body.

What it masks is never stored. Every rule above keys off a NAME, though, so this is a reduction of exposure and not a guarantee: a credential that no sensitive name points at is stored as it arrived. Known gaps are listed under "Capture-time redaction" in SECURITY.md; consumers whose traffic needs more pass their own Redactor to NetworkDebugTab.create(...).

Functions

Link copied to clipboard
open override fun redactBody(body: String, contentType: MediaType?): String

Returns body with sensitive values redacted. EVERY captured text body is covered (the capture layer only retains text-like bodies): the structured JSON/form paths are the precise fast paths, and anything else — including JSON that fails to parse (NDJSON / concatenated frames), SSE (text/event-stream), XML, and text/plain — falls through to the key-name-based redactTextually. Every path keys off a NAME, so a value no sensitive name points at is returned as it arrived; see the class KDoc.

Link copied to clipboard
open override fun redactHeaderValue(name: String, value: String): String

Returns the header value, or [REDACTED] when name is a well-known sensitive header OR its name matches a sensitive key fragment — so custom auth headers (X-Api-Key, X-Auth-Token, …) are masked, not just the standard Authorization / Cookie set. Well-known public headers that merely resemble a secret by name (NON_SENSITIVE_HEADERS) pass through.

Link copied to clipboard
open override fun redactUrl(url: String): String

Returns url with sensitive query parameters redacted.

Link copied to clipboard
Link copied to clipboard