Repository navigation
Conversation
manugarg
force-pushed
the
http-strip-proxy-url-credentials
branch
from
September 9, 2026 00:45
5f791fb to
587aee4
Compare
net/http replaces a URL's password with *** before putting it in an error; net/url does not -- url.Parse embeds the string it was handed, password and all. So a URL we parse but never fetch keeps its credentials all the way into the log. Hide the password in redactErrMsg alongside the query, so one helper makes any URL in a message safe to log. It works on the raw string because the URL that reaches us is often one Parse rejected, and it leaves a bare username alone -- that is not the secret.
The message included the proxy URL twice -- once from the config value,
once from url.Parse, which embeds the string it was handed -- so a proxy
URL with credentials logged the password.
Now that redactErrMsg hides passwords, the generic helper covers this:
the message keeps the reason and the rest of the URL, and only the
password goes.
before: error parsing proxy URL (http://user:hunter2@proxy:notaport/):
parse "http://user:hunter2@proxy:notaport/": invalid port ...
after: parse "http://user:***@proxy:notaport/": invalid port ...
manugarg
force-pushed
the
http-strip-proxy-url-credentials
branch
from
September 9, 2026 01:07
587aee4 to
8163b56
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
net/httpreplaces a URL's password with***before putting it in an error.net/urldoes not —url.Parseembeds the string it was handed, password andall. So a URL we parse but never fetch keeps its credentials all the way into
the log.
proxy_urlis the case that hits: the message included the URL twice, once fromthe config value and once from
url.Parse.Change
Rather than a one-off, this teaches the existing helper from #1410/#1477 to hide
passwords alongside queries, so
redactErrMsgnow makes any URL in a messagesafe to log — and
proxy_urljust calls it. The reason and the rest of the URLsurvive, which the earlier version of this PR lost by dropping the error
entirely.
It works on the raw string, because the URL that reaches us is often one
url.Parserejected, and it leaves a bare username alone — that isn't thesecret.
Testing
TestStripURLPasswordcovers userinfo, bare username,@in the path, a portmistaken for a password, and unparseable URLs.
TestProxyURLParseErrorHidesPasswordasserts the password is gone whileinvalid portand the host remain.go build ./...,go vet,go test -race ./probes/http/...,gofmtclean.