Skip to main content

Module redact

Module redact 

Source
Expand description

Redaction of credentials embedded in provider URLs. L1 RPC providers put the API key in the path or query (https://host/v2/KEY), so the host is kept and everything after it dropped. A credential in the hostname is not redactable.

scrub works on already-rendered text, which is the only handle available when the URL is baked into someone elseโ€™s Debug/Display (reqwest prints the full request URL in both). redact_url takes a Url directly.

It handles two shapes that share no common substring. Urlโ€™s own Debug is field-wise, with the host and path: "/v2/KEY" as separate fields and no :// between them, so URL-shaped matching misses it entirely. Structs holding a Url redact that field themselves; scrub_url_debug is the net for one that does not.

Constantsยง

REDACTED ๐Ÿ”’
URL_DEBUG_PREFIX ๐Ÿ”’

Functionsยง

ends_url_token ๐Ÿ”’
Characters Url::as_str() percent-encodes in every component, so they cannot occur inside a rendered URL. Nothing may be added here without that guarantee: ), ,, | and ^ are legal in a path, and `, { and } are legal in a query or fragment; ending a URL on any of them would leave the tail after it in the output.
redact_url
scheme://host[:port], with /*** appended when anything was removed.
redact_urls
scrub
scrub_url_debug ๐Ÿ”’
Collapses the body of every url::Url field-wise Debug in text, host included. Reaching this means a struct failed to redact a Url field, so Url { *** } is a signal to fix that struct rather than output to read a host out of.
scrub_urls ๐Ÿ”’
Replaces everything after the host of every URL in text with ***.