started move to retryablehttp

This commit is contained in:
xm1k3 2023-03-02 14:54:01 +01:00
parent ffd758dcb1
commit 886fdcf0a9
5 changed files with 10 additions and 9 deletions

View File

@ -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")
}

View File

@ -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())
}

View File

@ -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)
}

View File

@ -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,

View File

@ -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
}