From 6804bd79e8f6f410ba504282a5198a0934bad4a2 Mon Sep 17 00:00:00 2001 From: Ice3man543 Date: Fri, 2 Apr 2021 18:40:58 +0530 Subject: [PATCH] New ignore functionality + error to warning --- v2/internal/runner/config.go | 28 ++++++++++++++++------------ v2/internal/runner/options.go | 1 - v2/pkg/catalog/ignore.go | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/v2/internal/runner/config.go b/v2/internal/runner/config.go index c68b7d594e..ac5109685f 100644 --- a/v2/internal/runner/config.go +++ b/v2/internal/runner/config.go @@ -1,14 +1,14 @@ package runner import ( - "bufio" "os" "path" "regexp" - "strings" "time" jsoniter "github.com/json-iterator/go" + "github.com/projectdiscovery/gologger" + "gopkg.in/yaml.v2" ) // nucleiConfig contains some configuration options for nuclei @@ -83,25 +83,29 @@ func (r *Runner) writeConfiguration(config *nucleiConfig) error { const nucleiIgnoreFile = ".nuclei-ignore" +type ignoreFile struct { + Tags []string `yaml:"tags"` + Files []string `yaml:"files"` +} + // readNucleiIgnoreFile reads the nuclei ignore file marking it in map func (r *Runner) readNucleiIgnoreFile() { file, err := os.Open(r.getIgnoreFilePath()) if err != nil { + gologger.Error().Msgf("Could not read nuclei-ignore file: %s\n", err) return } defer file.Close() - scanner := bufio.NewScanner(file) - for scanner.Scan() { - text := scanner.Text() - if text == "" { - continue - } - if strings.HasPrefix(text, "#") { - continue - } - r.templatesConfig.IgnorePaths = append(r.templatesConfig.IgnorePaths, text) + ignore := &ignoreFile{} + if err := yaml.NewDecoder(file).Decode(ignore); err != nil { + gologger.Error().Msgf("Could not parse nuclei-ignore file: %s\n", err) + return + } + for _, file := range ignore.Files { + r.templatesConfig.IgnorePaths = append(r.templatesConfig.IgnorePaths, file) } + r.options.ExcludeTags = append(r.options.ExcludeTags, ignore.Tags...) } // getIgnoreFilePath returns the ignore file path for the runner diff --git a/v2/internal/runner/options.go b/v2/internal/runner/options.go index f47c4f111c..61864cbfcd 100644 --- a/v2/internal/runner/options.go +++ b/v2/internal/runner/options.go @@ -25,7 +25,6 @@ func ParseOptions(options *types.Options) { // Show the user the banner showBanner() - options.ExcludeTags = append(options.ExcludeTags, "dos") if options.Version { gologger.Info().Msgf("Current Version: %s\n", Version) os.Exit(0) diff --git a/v2/pkg/catalog/ignore.go b/v2/pkg/catalog/ignore.go index 77e94525d7..c3ecb99104 100644 --- a/v2/pkg/catalog/ignore.go +++ b/v2/pkg/catalog/ignore.go @@ -25,7 +25,7 @@ func (c *Catalog) checkIfInNucleiIgnore(item string) bool { } } if matched { - gologger.Error().Msgf("Excluding %s due to nuclei-ignore filter", item) + gologger.Warning().Msgf("Excluding %s due to nuclei-ignore filter", item) return true } return false