New ignore functionality + error to warning

dev
Ice3man543 2021-04-02 18:40:58 +05:30
parent 8233efe921
commit 6804bd79e8
3 changed files with 17 additions and 14 deletions

View File

@ -1,14 +1,14 @@
package runner package runner
import ( import (
"bufio"
"os" "os"
"path" "path"
"regexp" "regexp"
"strings"
"time" "time"
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
"github.com/projectdiscovery/gologger"
"gopkg.in/yaml.v2"
) )
// nucleiConfig contains some configuration options for nuclei // nucleiConfig contains some configuration options for nuclei
@ -83,25 +83,29 @@ func (r *Runner) writeConfiguration(config *nucleiConfig) error {
const nucleiIgnoreFile = ".nuclei-ignore" 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 // readNucleiIgnoreFile reads the nuclei ignore file marking it in map
func (r *Runner) readNucleiIgnoreFile() { func (r *Runner) readNucleiIgnoreFile() {
file, err := os.Open(r.getIgnoreFilePath()) file, err := os.Open(r.getIgnoreFilePath())
if err != nil { if err != nil {
gologger.Error().Msgf("Could not read nuclei-ignore file: %s\n", err)
return return
} }
defer file.Close() defer file.Close()
scanner := bufio.NewScanner(file) ignore := &ignoreFile{}
for scanner.Scan() { if err := yaml.NewDecoder(file).Decode(ignore); err != nil {
text := scanner.Text() gologger.Error().Msgf("Could not parse nuclei-ignore file: %s\n", err)
if text == "" { return
continue
}
if strings.HasPrefix(text, "#") {
continue
}
r.templatesConfig.IgnorePaths = append(r.templatesConfig.IgnorePaths, text)
} }
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 // getIgnoreFilePath returns the ignore file path for the runner

View File

@ -25,7 +25,6 @@ func ParseOptions(options *types.Options) {
// Show the user the banner // Show the user the banner
showBanner() showBanner()
options.ExcludeTags = append(options.ExcludeTags, "dos")
if options.Version { if options.Version {
gologger.Info().Msgf("Current Version: %s\n", Version) gologger.Info().Msgf("Current Version: %s\n", Version)
os.Exit(0) os.Exit(0)

View File

@ -25,7 +25,7 @@ func (c *Catalog) checkIfInNucleiIgnore(item string) bool {
} }
} }
if matched { 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 true
} }
return false return false