From e0a2e5d2921e94f2d8499dca2e4240b5a2d3ea7f Mon Sep 17 00:00:00 2001 From: sandeep Date: Wed, 1 Sep 2021 01:09:16 +0530 Subject: [PATCH] misc flag update --- v2/cmd/nuclei/main.go | 2 +- v2/internal/runner/runner.go | 4 ++-- v2/pkg/catalog/config/config.go | 2 +- .../protocols/common/hosterrorscache/hosterrorscache.go | 8 ++++---- v2/pkg/types/types.go | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/v2/cmd/nuclei/main.go b/v2/cmd/nuclei/main.go index a82fc83e..7bd84689 100644 --- a/v2/cmd/nuclei/main.go +++ b/v2/cmd/nuclei/main.go @@ -127,7 +127,7 @@ on extensive configurability, massive extensibility and ease of use.`) createGroup(flagSet, "optimization", "Optimizations", flagSet.IntVar(&options.Timeout, "timeout", 5, "time to wait in seconds before timeout"), flagSet.IntVar(&options.Retries, "retries", 1, "number of times to retry a failed request"), - flagSet.IntVar(&options.HostMaxErrors, "host-max-error", 30, "max errors for a host before skipping from scan"), + flagSet.IntVar(&options.MaxHostError, "max-host-error", 30, "max errors for a host before skipping from scan"), flagSet.BoolVar(&options.Project, "project", false, "use a project folder to avoid sending same request multiple times"), flagSet.StringVar(&options.ProjectPath, "project-path", os.TempDir(), "set a specific project path"), diff --git a/v2/internal/runner/runner.go b/v2/internal/runner/runner.go index bdd21faf..3b235f86 100644 --- a/v2/internal/runner/runner.go +++ b/v2/internal/runner/runner.go @@ -297,8 +297,8 @@ func (r *Runner) RunEnumeration() error { r.options.ExcludedTemplates = append(r.options.ExcludedTemplates, ignoreFile.Files...) var cache *hosterrorscache.Cache - if r.options.HostMaxErrors > 0 { - cache = hosterrorscache.New(r.options.HostMaxErrors, hosterrorscache.DefaultMaxHostsCount).SetVerbose(r.options.Verbose) + if r.options.MaxHostError > 0 { + cache = hosterrorscache.New(r.options.MaxHostError, hosterrorscache.DefaultMaxHostsCount).SetVerbose(r.options.Verbose) } r.hostErrors = cache executerOpts := protocols.ExecuterOptions{ diff --git a/v2/pkg/catalog/config/config.go b/v2/pkg/catalog/config/config.go index e1d7924d..503aa681 100644 --- a/v2/pkg/catalog/config/config.go +++ b/v2/pkg/catalog/config/config.go @@ -28,7 +28,7 @@ type Config struct { const nucleiConfigFilename = ".templates-config.json" // Version is the current version of nuclei -const Version = `2.4.4-dev` +const Version = `2.5.0` func getConfigDetails() (string, error) { homeDir, err := os.UserHomeDir() diff --git a/v2/pkg/protocols/common/hosterrorscache/hosterrorscache.go b/v2/pkg/protocols/common/hosterrorscache/hosterrorscache.go index ae6f5bc2..14aefff8 100644 --- a/v2/pkg/protocols/common/hosterrorscache/hosterrorscache.go +++ b/v2/pkg/protocols/common/hosterrorscache/hosterrorscache.go @@ -16,7 +16,7 @@ import ( // It uses an LRU cache internally for skipping unresponsive hosts // that remain so for a duration. type Cache struct { - hostMaxErrors int + MaxHostError int verbose bool failedTargets gcache.Cache } @@ -24,11 +24,11 @@ type Cache struct { const DefaultMaxHostsCount = 10000 // New returns a new host max errors cache -func New(hostMaxErrors, maxHostsCount int) *Cache { +func New(MaxHostError, maxHostsCount int) *Cache { gc := gcache.New(maxHostsCount). ARC(). Build() - return &Cache{failedTargets: gc, hostMaxErrors: hostMaxErrors} + return &Cache{failedTargets: gc, MaxHostError: MaxHostError} } // SetVerbose sets the cache to log at verbose level @@ -88,7 +88,7 @@ func (c *Cache) Check(value string) bool { if numberOfErrors == -1 { return true } - if numberOfErrorsValue >= c.hostMaxErrors { + if numberOfErrorsValue >= c.MaxHostError { _ = c.failedTargets.Set(finalValue, -1) if c.verbose { gologger.Verbose().Msgf("Skipping %s as previously unresponsive %d times", finalValue, numberOfErrorsValue) diff --git a/v2/pkg/types/types.go b/v2/pkg/types/types.go index 45441bcb..d10199ff 100644 --- a/v2/pkg/types/types.go +++ b/v2/pkg/types/types.go @@ -65,8 +65,8 @@ type Options struct { StatsInterval int // MetricsPort is the port to show metrics on MetricsPort int - // HostMaxErrors is the maximum number of errors allowed for a host - HostMaxErrors int + // MaxHostError is the maximum number of errors allowed for a host + MaxHostError int // BulkSize is the of targets analyzed in parallel for each template BulkSize int // TemplateThreads is the number of templates executed in parallel