Skip to content

Commit

Permalink
Try to read ignore file from current working directory
Browse files Browse the repository at this point in the history
Implements #350
  • Loading branch information
vzamanillo committed Oct 11, 2020
1 parent 9ff0ce8 commit c50a57e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion v2/internal/runner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const nucleiIgnoreFile = ".nuclei-ignore"

// readNucleiIgnoreFile reads the nuclei ignore file marking it in map
func (r *Runner) readNucleiIgnoreFile() {
file, err := os.Open(path.Join(r.templatesConfig.TemplatesDirectory, nucleiIgnoreFile))
file, err := os.Open(r.getIgnoreFilePath())
if err != nil {
return
}
Expand Down Expand Up @@ -116,3 +116,21 @@ func (r *Runner) checkIfInNucleiIgnore(item string) bool {

return false
}

func (r *Runner) getIgnoreFilePath() string {
defIgnoreFilePath := path.Join(r.templatesConfig.TemplatesDirectory, nucleiIgnoreFile)

cwd, err := os.Getwd()
if err != nil {
return defIgnoreFilePath
}

cwdIgnoreFilePath := path.Join(cwd, nucleiIgnoreFile)

cwdIfpInfo, err := os.Stat(cwdIgnoreFilePath)
if os.IsNotExist(err) || cwdIfpInfo.IsDir() {
return defIgnoreFilePath
}

return cwdIgnoreFilePath
}

0 comments on commit c50a57e

Please sign in to comment.