diff --git a/pkg/tools/integration/web.go b/pkg/tools/integration/web.go index f013c89b..77065793 100644 --- a/pkg/tools/integration/web.go +++ b/pkg/tools/integration/web.go @@ -2324,16 +2324,6 @@ func newPrivateHostWhitelist(entries []string) (*utils.PrivateHostWhitelist, err return utils.NewPrivateHostWhitelist(entries) } -func isObviousPrivateHost(host string, whitelist *utils.PrivateHostWhitelist) bool { - return utils.IsObviousPrivateHost(host, whitelist, func() bool { - return allowPrivateWebFetchHosts.Load() - }) -} - func isPrivateOrRestrictedIP(ip net.IP) bool { return utils.IsPrivateOrRestrictedIP(ip) } - -func allowConfiguredProxyFirstHop(req *http.Request, rt http.RoundTripper) { - utils.AllowConfiguredProxyFirstHop(req, rt) -} diff --git a/pkg/utils/http_guard_test.go b/pkg/utils/http_guard_test.go index 038cf91d..bd6d255d 100644 --- a/pkg/utils/http_guard_test.go +++ b/pkg/utils/http_guard_test.go @@ -60,7 +60,10 @@ func TestCreateSafeHTTPClient_BlocksPrivateRedirect(t *testing.T) { } allowPrivateHosts = false - _, err = client.Get(server.URL) + resp, err := client.Get(server.URL) + if resp != nil && resp.Body != nil { + resp.Body.Close() + } if err == nil { t.Fatal("expected redirect to private host to fail") } diff --git a/pkg/utils/media.go b/pkg/utils/media.go index b30277b8..e52c7e13 100644 --- a/pkg/utils/media.go +++ b/pkg/utils/media.go @@ -97,9 +97,10 @@ func DownloadFile(urlStr, filename string, opts DownloadOptions) string { var client *http.Client var err error if opts.BlockPrivateTargets { - if err := ValidateSafeHTTPURL(urlStr, nil, nil); err != nil { + validateErr := ValidateSafeHTTPURL(urlStr, nil, nil) + if validateErr != nil { logger.ErrorCF(opts.LoggerPrefix, "Blocked unsafe download URL", map[string]any{ - "error": err.Error(), + "error": validateErr.Error(), "url": urlStr, }) return ""