Skip to main content

Module redact

Module redact 

Source
Expand description

Redact credentials from JSON before it is displayed or logged.

Startup parameters and actions are echoed in two places an operator reads: the open_client / open_server summary pushed to the dashboard and MCP status stream, and the executor’s per-action DEBUG line in netget.log. Both printed the RADIUS client’s shared secret, the MQTT client’s password and anything else of that kind verbatim. The protocol still receives the real value; only what is shown is replaced.

Matching is by key name, case-insensitively, on a substring, so secret, shared_secret, password, bind_password and api_key are all caught. A false positive costs a line of display; a false negative prints a credential.

Constants§

DISPLAY_ONLY_KEY_PARTS
Substrings of a key name whose value is masked wherever it is displayed, without making the request that carries it private.
MAX_REDACT_DEPTH
Deepest nesting walked. serde_json refuses to parse past 128 levels, so a parsed value never reaches this; a value built in code might, and past it the subtree is shown as REDACTED whole rather than walked on a shrinking stack.
REDACTED
What a redacted value is shown as.
SENSITIVE_KEY_PARTS
Substrings of a key name that mark its value as a credential.

Functions§

actions_have_credentials
Whether this request offers an action that can carry credentials. Such model replies can be malformed or plain text, so hiding whole payloads is safer than trying to recover credential fields from an unparseable response.
contains_credentials
Detect credential-bearing structured input without cloning or recursive traversal. A budget-exceeding input is private because its remaining keys cannot be proven safe. Null credential fields do not contain a value. Bounds apply to node count, depth and retained string/key content; no request-wide or global privacy state is retained.
hide_error_details
Remove untyped context from a private request’s error while preserving the numeric overload category that protocols use to choose a retryable wire reply.
is_sensitive_entry
Whether a key/value pair holds a credential.
is_sensitive_key
Whether a key names a credential.
is_shown_redacted
Whether a key/value pair is shown as REDACTED: every is_sensitive_entry, plus the DISPLAY_ONLY_KEY_PARTS.
redact_sensitive
A copy of value with every credential-named key’s value replaced by REDACTED, at any depth up to MAX_REDACT_DEPTH.