mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 14:05:28 +00:00
Cancel http requests if the host keeps erroring
This commit is contained in:
parent
dd6f9bbc61
commit
b800e2cce2
@ -1,6 +1,8 @@
|
|||||||
package runner
|
package runner
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/projectdiscovery/gologger"
|
"github.com/projectdiscovery/gologger"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/templates"
|
"github.com/projectdiscovery/nuclei/v2/pkg/templates"
|
||||||
"github.com/remeh/sizedwaitgroup"
|
"github.com/remeh/sizedwaitgroup"
|
||||||
@ -22,6 +24,7 @@ func (r *Runner) processTemplateWithList(template *templates.Template) bool {
|
|||||||
go func(URL string) {
|
go func(URL string) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
|
fmt.Printf("%v %v\n", URL, template.Info)
|
||||||
match, err := template.Executer.Execute(URL)
|
match, err := template.Executer.Execute(URL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
gologger.Warning().Msgf("[%s] Could not execute step: %s\n", r.colorizer.BrightBlue(template.ID), err)
|
gologger.Warning().Msgf("[%s] Could not execute step: %s\n", r.colorizer.BrightBlue(template.ID), err)
|
||||||
|
|||||||
@ -216,6 +216,10 @@ func (r *Request) ExecuteWithResults(reqURL string, dynamicValues, previous outp
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if hosts just keep erroring
|
||||||
|
if r.options.HostErrorsCache != nil && r.options.HostErrorsCache.Check(reqURL) {
|
||||||
|
break
|
||||||
|
}
|
||||||
var gotOutput bool
|
var gotOutput bool
|
||||||
r.options.RateLimiter.Take()
|
r.options.RateLimiter.Take()
|
||||||
err = r.executeRequest(reqURL, request, previous, func(event *output.InternalWrappedEvent) {
|
err = r.executeRequest(reqURL, request, previous, func(event *output.InternalWrappedEvent) {
|
||||||
@ -237,7 +241,10 @@ func (r *Request) ExecuteWithResults(reqURL string, dynamicValues, previous outp
|
|||||||
}
|
}
|
||||||
}, requestCount)
|
}, requestCount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
requestErr = multierr.Append(requestErr, err)
|
if r.options.HostErrorsCache != nil && r.options.HostErrorsCache.CheckError(err) {
|
||||||
|
r.options.HostErrorsCache.MarkFailed(reqURL)
|
||||||
|
}
|
||||||
|
requestErr = err
|
||||||
}
|
}
|
||||||
requestCount++
|
requestCount++
|
||||||
r.options.Progress.IncrementRequests()
|
r.options.Progress.IncrementRequests()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user