Insider.Redaction.Credentials (Insider v0.1.0)

Copy Markdown View Source

Credential masking for values that leave the node.

Development data is anonymized before it reaches a developer machine, but a development node still holds real provider credentials from its environment. Every value an observer can read therefore passes this mask, whatever else its disclosure profile allows:

  • a non-empty value under a credential-named key (password, secret, token, api_key, authorization, cookie, private_key, and similar, matched case-insensitively within the key) becomes "[REDACTED:credential_key]", whatever its type;
  • a secret-shaped span inside a string (an HTTP Bearer or Basic credential, a JWT, a PEM block, a well-known provider key format such as sk_live_…, the password in a URL, the value of a password=… style assignment, or a long high-entropy token) becomes "[REDACTED:<reason>]" and the rest of the string stays readable.

mask/1 returns one manifest record per masked path and reason, with a count and never the value.

Summary

Functions

Whether key names a credential. Binary and atom keys are checked; any other term is not a credential name.

Masks a plain, JSON-compatible value (string-keyed maps, lists, and scalars) and returns it with its manifest records.

Replaces every secret-shaped span of text with "[REDACTED:<reason>]".

The masking policy id carried by every mask record.

Every reason a mask record or marker can carry.

Compiles the masking patterns once for this module version, so a later caller with a time budget does not pay for it.

Functions

credential_key?(key)

@spec credential_key?(term()) :: boolean()

Whether key names a credential. Binary and atom keys are checked; any other term is not a credential name.

mask(value)

@spec mask(term()) :: {term(), [map()]}

Masks a plain, JSON-compatible value (string-keyed maps, lists, and scalars) and returns it with its manifest records.

Each record is %{"action" => "mask", "count", "path", "policy_id", "reason"}. path uses key: and index: segments, at most eight. A marker already present in a string (from masking at capture) is reported as well. At most 32 records are returned: beyond that, paths are cut short and counts summed, so every reason stays visible.

mask_text(text)

@spec mask_text(String.t()) :: String.t()

Replaces every secret-shaped span of text with "[REDACTED:<reason>]".

policy_id()

@spec policy_id() :: String.t()

The masking policy id carried by every mask record.

reasons()

@spec reasons() :: [String.t()]

Every reason a mask record or marker can carry.

warm()

@spec warm() :: :ok

Compiles the masking patterns once for this module version, so a later caller with a time budget does not pay for it.