Expand description
Structural masking of JSON that a released document carries: the whole value of a member with a credential’s name, at any depth, whatever its shape.
The text rules of super::redaction_rules read a secret by the name in
front of it ("token":"…"), so they only see a STRING right after the
name. A secret one level further down ({"token":["S"]},
{"auth":{"value":"S"}}) or kept as a number or a boolean passed every
text rule unmasked. Here a member whose name reads as a credential
(is_secret_key) has its whole value replaced by SECRET_MEMBER_MARKER:
arrays, objects, numbers and booleans alike, the names inside included.
Only null, "" and a value that is already a mask stay as they are
(allowlist; every other shape is masked).
A string value at any depth that is itself a JSON object or array (a fact whose value is a serialized document) is masked the same way, and the masked JSON stands in the string. The value detectors (provider tokens, key/value rules) still run on every string leaf where the caller releases the document; this pass only adds what they cannot see.
Structs§
- Masked
- A masked text and the masked string values that are worth looking for
elsewhere in the delivered text (benign literals such as
noneare masked but not listed: finding them elsewhere proves nothing).
Enums§
- Uninspectable
- Why a text could not be inspected; the caller withholds it.
Constants§
- SECRET_
MEMBER_ MARKER - What stands in place of the whole value of a credential member. It starts
with
[REDACTEDlike every marker of the text rules, so callers that locate masked spans by that prefix see it as a mask.
Functions§
- is_
secret_ key - Whether a JSON member name reads as a credential: its last word is one
(
token,password,auth,client_secret,accessToken), or it ends inkeywith a credential qualifier (api_key,private_key). Counts and metadata (tokens,max_tokens,token_type,secret_count), a barekeyandpublic_keyare not. - mask_
secret_ members - Mask, in place, the whole value of every member of
valuewhose name is a credential (is_secret_key), at any depth, and every JSON document kept as a string value. Returns whether anything changed; the masked string values worth looking for elsewhere are appended tooriginals. - mask_
structured_ text mask_secret_membersfor a text: a text that is one JSON document is masked as a value and written back in its own layout (pretty when it spans lines); any other text has every embedded JSON object or array masked where it stands.Ok(None): nothing to mask, the text keeps its bytes.