Skip to content

Commit 7c28fe8

Browse files
authored
Disable validating transport if INSECURE_DISABLE_URL_VALIDATION is set (#1471)
1 parent ac326ef commit 7c28fe8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/networking/http_client.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const HttpTimeout = 30 * time.Second
2222

2323
// Dialer control function for validating addresses prior to connection
2424
func protectedDialerControl(_, address string, _ syscall.RawConn) error {
25-
2625
err := AddressReferencesPrivateIp(address)
2726
if err != nil {
2827
return err
@@ -38,10 +37,14 @@ type ValidatingTransport struct {
3837

3938
// RoundTrip validates the request URL prior to forwarding
4039
func (t *ValidatingTransport) RoundTrip(req *http.Request) (*http.Response, error) {
40+
// Skip validation if INSECURE_DISABLE_URL_VALIDATION is set
41+
if strings.EqualFold(os.Getenv("INSECURE_DISABLE_URL_VALIDATION"), "true") {
42+
return t.Transport.RoundTrip(req)
43+
}
44+
4145
// Check for valid URL specification
4246
parsedUrl, err := url.Parse(req.URL.String())
4347
if err != nil {
44-
fmt.Print(err)
4548
return nil, fmt.Errorf("the supplied URL %s is malformed", req.URL.String())
4649
}
4750

0 commit comments

Comments
 (0)