diff --git a/v2/cmd/cve-annotate/main.go b/v2/cmd/cve-annotate/main.go index e4f0bb24f..2c17030c1 100644 --- a/v2/cmd/cve-annotate/main.go +++ b/v2/cmd/cve-annotate/main.go @@ -6,7 +6,6 @@ import ( "flag" "fmt" "log" - "net/http" "net/url" "os" "regexp" @@ -15,6 +14,7 @@ import ( "github.com/pkg/errors" "github.com/projectdiscovery/nuclei/v2/pkg/catalog/disk" "github.com/projectdiscovery/nvd" + "github.com/projectdiscovery/retryablehttp-go" sliceutil "github.com/projectdiscovery/utils/slice" stringsutil "github.com/projectdiscovery/utils/strings" "gopkg.in/yaml.v3" @@ -275,7 +275,7 @@ type cisaKEVData struct { func fetchCISAKnownExploitedVulnerabilities() error { data := &cisaKEVData{} - resp, err := http.Get("https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json") + resp, err := retryablehttp.DefaultClient().Get("https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json") if err != nil { return errors.Wrap(err, "could not get cisa kev catalog") } diff --git a/v2/cmd/tools/fuzzplayground/main.go b/v2/cmd/tools/fuzzplayground/main.go index 4b870e0bb..4298b12a5 100644 --- a/v2/cmd/tools/fuzzplayground/main.go +++ b/v2/cmd/tools/fuzzplayground/main.go @@ -3,13 +3,13 @@ package main import ( "fmt" "io" - "net/http" "os/exec" "strconv" "strings" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" + "github.com/projectdiscovery/retryablehttp-go" ) func main() { @@ -60,7 +60,7 @@ func redirectHandler(ctx echo.Context) error { func requestHandler(ctx echo.Context) error { url := ctx.QueryParam("url") - data, err := http.Get(url) + data, err := retryablehttp.DefaultClient().Get(url) if err != nil { return ctx.HTML(500, err.Error()) } diff --git a/v2/internal/runner/update.go b/v2/internal/runner/update.go index 4942753e1..4564e2836 100644 --- a/v2/internal/runner/update.go +++ b/v2/internal/runner/update.go @@ -29,6 +29,7 @@ import ( "github.com/projectdiscovery/nuclei/v2/pkg/external/customtemplates" client "github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/updatecheck" "github.com/projectdiscovery/nuclei/v2/pkg/utils" + "github.com/projectdiscovery/retryablehttp-go" fileutil "github.com/projectdiscovery/utils/file" folderutil "github.com/projectdiscovery/utils/folder" @@ -308,7 +309,7 @@ func (r *Runner) downloadReleaseAndUnzip(ctx context.Context, version, downloadU return nil, fmt.Errorf("failed to create HTTP request to %s: %w", downloadURL, err) } - res, err := http.DefaultClient.Do(req) + res, err := retryablehttp.DefaultClient().Do(req) if err != nil { return nil, fmt.Errorf("failed to download a release file from %s: %w", downloadURL, err) } diff --git a/v2/pkg/catalog/loader/remote_loader.go b/v2/pkg/catalog/loader/remote_loader.go index 7bb87cb6e..531417aeb 100644 --- a/v2/pkg/catalog/loader/remote_loader.go +++ b/v2/pkg/catalog/loader/remote_loader.go @@ -3,13 +3,13 @@ package loader import ( "bufio" "fmt" - "net/http" "net/url" "strings" "github.com/pkg/errors" "github.com/projectdiscovery/nuclei/v2/pkg/utils" + "github.com/projectdiscovery/retryablehttp-go" ) type ContentType string @@ -72,7 +72,7 @@ func getRemoteContent(URL string, remoteTemplateDomainList []string, remoteConte } return } - response, err := http.Get(URL) + response, err := retryablehttp.DefaultClient().Get(URL) if err != nil { remoteContentChannel <- RemoteContent{ Error: err, diff --git a/v2/pkg/utils/utils.go b/v2/pkg/utils/utils.go index 0db1e6b3a..ba04589a2 100644 --- a/v2/pkg/utils/utils.go +++ b/v2/pkg/utils/utils.go @@ -3,12 +3,12 @@ package utils import ( "errors" "io" - "net/http" "net/url" "strings" "github.com/projectdiscovery/nuclei/v2/pkg/catalog" "github.com/projectdiscovery/nuclei/v2/pkg/utils/yaml" + "github.com/projectdiscovery/retryablehttp-go" fileutil "github.com/projectdiscovery/utils/file" ) @@ -37,7 +37,7 @@ func IsURL(input string) bool { func ReadFromPathOrURL(templatePath string, catalog catalog.Catalog) (data []byte, err error) { var reader io.Reader if IsURL(templatePath) { - resp, err := http.Get(templatePath) + resp, err := retryablehttp.DefaultClient().Get(templatePath) if err != nil { return nil, err }