mirror of https://github.com/daffainfo/nuclei.git
Cancel http requests if the host keeps erroring
parent
dd6f9bbc61
commit
b800e2cce2
|
@ -1,6 +1,8 @@
|
|||
package runner
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/projectdiscovery/gologger"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/templates"
|
||||
"github.com/remeh/sizedwaitgroup"
|
||||
|
@ -22,6 +24,7 @@ func (r *Runner) processTemplateWithList(template *templates.Template) bool {
|
|||
go func(URL string) {
|
||||
defer wg.Done()
|
||||
|
||||
fmt.Printf("%v %v\n", URL, template.Info)
|
||||
match, err := template.Executer.Execute(URL)
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
// Check if hosts just keep erroring
|
||||
if r.options.HostErrorsCache != nil && r.options.HostErrorsCache.Check(reqURL) {
|
||||
break
|
||||
}
|
||||
var gotOutput bool
|
||||
r.options.RateLimiter.Take()
|
||||
err = r.executeRequest(reqURL, request, previous, func(event *output.InternalWrappedEvent) {
|
||||
|
@ -237,7 +241,10 @@ func (r *Request) ExecuteWithResults(reqURL string, dynamicValues, previous outp
|
|||
}
|
||||
}, requestCount)
|
||||
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++
|
||||
r.options.Progress.IncrementRequests()
|
||||
|
|
Loading…
Reference in New Issue