mirror of https://github.com/daffainfo/nuclei.git
Merge pull request #1489 from projectdiscovery/workflow-validation-fix
update validation logic to validate workflow templates and subtemplatesdev
commit
eb6a1b263d
|
@ -13,6 +13,7 @@ import (
|
|||
templateTypes "github.com/projectdiscovery/nuclei/v2/pkg/templates/types"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/utils/stats"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/workflows"
|
||||
)
|
||||
|
||||
// Config contains the configuration options for the loader
|
||||
|
@ -196,10 +197,31 @@ func areWorkflowOrTemplatesValid(store *Store, filteredTemplatePaths map[string]
|
|||
return true
|
||||
}
|
||||
}
|
||||
if isWorkflow {
|
||||
if !areWorkflowTemplatesValid(store, template.Workflows) {
|
||||
areTemplatesValid = false
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
return areTemplatesValid
|
||||
}
|
||||
|
||||
func areWorkflowTemplatesValid(store *Store, workflows []*workflows.WorkflowTemplate) bool {
|
||||
for _, workflow := range workflows {
|
||||
if !areWorkflowTemplatesValid(store, workflow.Subtemplates) {
|
||||
return false
|
||||
}
|
||||
_, err := store.config.Catalog.GetTemplatePath(workflow.Template)
|
||||
if err != nil {
|
||||
if isParsingError("Error occurred loading template %s: %s\n", workflow.Template, err) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func isParsingError(message string, template string, err error) bool {
|
||||
if err == templates.ErrCreateTemplateExecutor {
|
||||
return false
|
||||
|
|
Loading…
Reference in New Issue