mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 23:25:27 +00:00
started move to retryablehttp
This commit is contained in:
parent
ffd758dcb1
commit
886fdcf0a9
@ -6,7 +6,6 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -15,6 +14,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/disk"
|
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/disk"
|
||||||
"github.com/projectdiscovery/nvd"
|
"github.com/projectdiscovery/nvd"
|
||||||
|
"github.com/projectdiscovery/retryablehttp-go"
|
||||||
sliceutil "github.com/projectdiscovery/utils/slice"
|
sliceutil "github.com/projectdiscovery/utils/slice"
|
||||||
stringsutil "github.com/projectdiscovery/utils/strings"
|
stringsutil "github.com/projectdiscovery/utils/strings"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
@ -275,7 +275,7 @@ type cisaKEVData struct {
|
|||||||
func fetchCISAKnownExploitedVulnerabilities() error {
|
func fetchCISAKnownExploitedVulnerabilities() error {
|
||||||
data := &cisaKEVData{}
|
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 {
|
if err != nil {
|
||||||
return errors.Wrap(err, "could not get cisa kev catalog")
|
return errors.Wrap(err, "could not get cisa kev catalog")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,13 +3,13 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/labstack/echo/v4/middleware"
|
"github.com/labstack/echo/v4/middleware"
|
||||||
|
"github.com/projectdiscovery/retryablehttp-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -60,7 +60,7 @@ func redirectHandler(ctx echo.Context) error {
|
|||||||
|
|
||||||
func requestHandler(ctx echo.Context) error {
|
func requestHandler(ctx echo.Context) error {
|
||||||
url := ctx.QueryParam("url")
|
url := ctx.QueryParam("url")
|
||||||
data, err := http.Get(url)
|
data, err := retryablehttp.DefaultClient().Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.HTML(500, err.Error())
|
return ctx.HTML(500, err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import (
|
|||||||
"github.com/projectdiscovery/nuclei/v2/pkg/external/customtemplates"
|
"github.com/projectdiscovery/nuclei/v2/pkg/external/customtemplates"
|
||||||
client "github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/updatecheck"
|
client "github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/updatecheck"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/utils"
|
"github.com/projectdiscovery/nuclei/v2/pkg/utils"
|
||||||
|
"github.com/projectdiscovery/retryablehttp-go"
|
||||||
fileutil "github.com/projectdiscovery/utils/file"
|
fileutil "github.com/projectdiscovery/utils/file"
|
||||||
folderutil "github.com/projectdiscovery/utils/folder"
|
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)
|
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 {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to download a release file from %s: %w", downloadURL, err)
|
return nil, fmt.Errorf("failed to download a release file from %s: %w", downloadURL, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,13 +3,13 @@ package loader
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/utils"
|
"github.com/projectdiscovery/nuclei/v2/pkg/utils"
|
||||||
|
"github.com/projectdiscovery/retryablehttp-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ContentType string
|
type ContentType string
|
||||||
@ -72,7 +72,7 @@ func getRemoteContent(URL string, remoteTemplateDomainList []string, remoteConte
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
response, err := http.Get(URL)
|
response, err := retryablehttp.DefaultClient().Get(URL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
remoteContentChannel <- RemoteContent{
|
remoteContentChannel <- RemoteContent{
|
||||||
Error: err,
|
Error: err,
|
||||||
|
|||||||
@ -3,12 +3,12 @@ package utils
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/catalog"
|
"github.com/projectdiscovery/nuclei/v2/pkg/catalog"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/utils/yaml"
|
"github.com/projectdiscovery/nuclei/v2/pkg/utils/yaml"
|
||||||
|
"github.com/projectdiscovery/retryablehttp-go"
|
||||||
fileutil "github.com/projectdiscovery/utils/file"
|
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) {
|
func ReadFromPathOrURL(templatePath string, catalog catalog.Catalog) (data []byte, err error) {
|
||||||
var reader io.Reader
|
var reader io.Reader
|
||||||
if IsURL(templatePath) {
|
if IsURL(templatePath) {
|
||||||
resp, err := http.Get(templatePath)
|
resp, err := retryablehttp.DefaultClient().Get(templatePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user