Documentation
¶
Overview ¶
Package urlredact keeps a secret that a URL carries (a token in the path, credentials in the user info or the query) out of an error or a log line.
Index ¶
Constants ¶
const RedactedURL = "[REDACTED]"
RedactedURL replaces the URL of an error that must not leak it.
Variables ¶
This section is empty.
Functions ¶
func RedactURL ¶
RedactURL returns a URL that is safe to put in an error or a log: only the scheme and the host are kept. The user info, the path (tokens are sometimes carried by it), the query string and the fragment may carry credentials, so they are dropped. A value that can not be parsed is replaced entirely, because its content is unknown.
func RedactURLError ¶
RedactURLError removes the URLs from the errors returned by net/http and net/url.
Those errors embed the full request URL, but the URL of a webhook (Slack, Discord, ...) or of an endpoint may carry a secret (token in the path, credentials in the user info or in the query string). The operation and the root cause are kept so the error stays actionable. When the cause itself quotes a URL (for example a malformed redirect Location header), the cause is rewritten without it. The cause of a parse error is always replaced, because it quotes the unparsable input.
Types ¶
This section is empty.