Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/secureenv/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ func anyProxyKeyPresent(present map[string]struct{}, group []string) bool {
// proxy host/port so the proxy remains functional. Non-URL values (e.g. the
// host list in NO_PROXY) and unparseable values are returned unchanged.
func redactProxyCredentials(value string) string {
// Surrounding whitespace would make url.Parse error (leading space) or
// otherwise fall through, forwarding a credentialed value verbatim. Trim it
// first; whitespace is never meaningful in a proxy URL.
value = strings.TrimSpace(value)
if value == "" {
return value
}
Expand Down
5 changes: 5 additions & 0 deletions internal/secureenv/proxy_forward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func TestRedactProxyCredentials(t *testing.T) {
{"schemeless user only", "user@proxy.example.com:3128", "proxy.example.com:3128"},
{"schemeless no userinfo", "proxy.example.com:8080", "proxy.example.com:8080"},
{"schemeless at-in-path not stripped", "proxy.example.com:8080/path@x", "proxy.example.com:8080/path@x"},
// Whitespace-wrapped credentialed URLs would otherwise make url.Parse
// error and fall through, forwarding creds verbatim (PR #704 non-blocking
// review note). Surrounding whitespace is trimmed before redaction.
{"whitespace-wrapped scheme creds", " http://user:pass@proxy.example.com:8080 ", "http://proxy.example.com:8080"},
{"whitespace-wrapped schemeless creds", "\tuser:pass@proxy.example.com:8080\n", "proxy.example.com:8080"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
Expand Down
Loading