Expand description
Credential redaction for URL-ish strings shared across the binaries.
Two related invariants live here, both keyed on the rule that a URL can carry a secret no log or operator-facing error may echo:
- Userinfo — relay/origin URLs can carry
user:pass@userinfo. When such a string is named in a parse error or log (config-validate time,crate::config; node bring-up, thedecdn-noderuntime), the credentials are scrubbed byredact_userinfo, which preserves the host and path so the offending entry is still identifiable. - Whole URL — a chain
rpc_urlsecret commonly lives in the path or query (Infura/Alchemy keys), which userinfo redaction would NOT scrub. So when anrpc_urlreaches a transport/chain error,strip_urlsremoves the URL entirely. The failure class (timeout, connection refused, DNS, TLS) usually lives in the error’ssource()chain, not in its top-level Display.sanitize_err_chain(for ananyhow::Error) andsanitize_error_sources(for a typedstd::error::Error) render that chain, so the class survives the strip.sanitize_rpc_displayrenders only the top-level Display, so it suits a plainDisplayvalue such as aStringreason.
Routing every gate through this single module keeps each invariant from drifting between copies.
Functions§
- redact_
userinfo - Replace any
user:pass@userinfo in a URL-ish string with***@so a parse-failure log/error can name the offending entry without leaking credentials. - sanitize_
err_ chain - Render an
anyhowerror’s fullcontext: cause: causechain with URL fragments stripped, throughsanitize_error_sources: the context layers and the wrapped error’ssource()chain share one walk, so a repeated layer is printed once and each layer is stripped on its own. - sanitize_
error_ sources - Render a typed error and each layer of its
source()chain asouter: cause: cause, with URL fragments stripped. - sanitize_
rpc_ display - Render a plain
Displayvalue, with URL fragments stripped, for a single log/error line. Use for a value with nosource()chain, such as aStringreason. - strip_
urls - Strip URL-bearing fragments from an error’s rendered text so an
rpc_urlsecret never reaches a log or operator-facing error. Any failure class in the input text (timeout / connection refused / DNS / TLS) is kept; to include thesource()chain, callsanitize_error_sourcesorsanitize_err_chain.