Skip to content

Commit

Permalink
New ignore functionality + error to warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Ice3man543 committed Apr 2, 2021
1 parent 8233efe commit 6804bd7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
28 changes: 16 additions & 12 deletions v2/internal/runner/config.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion v2/internal/runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion v2/pkg/catalog/ignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6804bd7

Please sign in to comment.