mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2026-02-01 00:03:15 +08:00
Show skipped hosts
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/bluele/gcache"
|
||||
"github.com/projectdiscovery/gologger"
|
||||
)
|
||||
|
||||
// Cache is a cache for host based errors. It allows skipping
|
||||
@@ -16,6 +17,7 @@ import (
|
||||
// that remain so for a duration.
|
||||
type Cache struct {
|
||||
hostMaxErrors int
|
||||
verbose bool
|
||||
failedTargets gcache.Cache
|
||||
}
|
||||
|
||||
@@ -29,6 +31,12 @@ func New(hostMaxErrors, maxHostsCount int) *Cache {
|
||||
return &Cache{failedTargets: gc, hostMaxErrors: hostMaxErrors}
|
||||
}
|
||||
|
||||
// SetVerbose sets the cache to log at verbose level
|
||||
func (c *Cache) SetVerbose(verbose bool) *Cache {
|
||||
c.verbose = verbose
|
||||
return c
|
||||
}
|
||||
|
||||
// Close closes the host errors cache
|
||||
func (c *Cache) Close() {
|
||||
c.failedTargets.Purge()
|
||||
@@ -76,7 +84,18 @@ func (c *Cache) Check(value string) bool {
|
||||
return false
|
||||
}
|
||||
numberOfErrorsValue := numberOfErrors.(int)
|
||||
return numberOfErrorsValue >= c.hostMaxErrors
|
||||
|
||||
if numberOfErrors == -1 {
|
||||
return true
|
||||
}
|
||||
if numberOfErrorsValue >= c.hostMaxErrors {
|
||||
_ = c.failedTargets.Set(finalValue, -1)
|
||||
if c.verbose {
|
||||
gologger.Verbose().Msgf("Skipping %s as it has failed %d times", finalValue, numberOfErrorsValue)
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// MarkFailed marks a host as failed previously
|
||||
|
||||
Reference in New Issue
Block a user