mirror of https://github.com/daffainfo/nuclei.git
Refactor template resolution logic for reusability
parent
a7fbf5c9e0
commit
c6df7fbd43
|
@ -189,15 +189,14 @@ func isNewPath(path string, pathMap map[string]bool) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunEnumeration sets up the input layer for giving input nuclei.
|
// getTemplatesFor parses the specified input template definitions and returns a list of unique, absolute template paths.
|
||||||
// binary and runs the actual enumeration
|
func (r *Runner) getTemplatesFor(definitions []string) []string {
|
||||||
func (r *Runner) RunEnumeration() {
|
|
||||||
// keeps track of processed dirs and files
|
// keeps track of processed dirs and files
|
||||||
processed := make(map[string]bool)
|
processed := make(map[string]bool)
|
||||||
allTemplates := []string{}
|
allTemplates := []string{}
|
||||||
|
|
||||||
// parses user input, handle file/directory cases and produce a list of unique templates
|
// parses user input, handle file/directory cases and produce a list of unique templates
|
||||||
for _, t := range r.options.Templates {
|
for _, t := range definitions {
|
||||||
var absPath string
|
var absPath string
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
@ -293,6 +292,15 @@ func (r *Runner) RunEnumeration() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return allTemplates
|
||||||
|
}
|
||||||
|
|
||||||
|
// RunEnumeration sets up the input layer for giving input nuclei.
|
||||||
|
// binary and runs the actual enumeration
|
||||||
|
func (r *Runner) RunEnumeration() {
|
||||||
|
// resolves input templates
|
||||||
|
allTemplates := r.getTemplatesFor(r.options.Templates)
|
||||||
|
|
||||||
// 0 matches means no templates were found in directory
|
// 0 matches means no templates were found in directory
|
||||||
if len(allTemplates) == 0 {
|
if len(allTemplates) == 0 {
|
||||||
gologger.Fatalf("Error, no templates were found.\n")
|
gologger.Fatalf("Error, no templates were found.\n")
|
||||||
|
|
Loading…
Reference in New Issue