mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 05:05:23 +00:00
Show errors when validate flag is passed for syntax
This commit is contained in:
parent
96adaf5257
commit
44700e6c60
@ -72,6 +72,9 @@ func New(options *types.Options) (*Runner, error) {
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
if options.Validate {
|
||||
parsers.ShouldValidate = true
|
||||
}
|
||||
if err := runner.updateTemplates(); err != nil {
|
||||
gologger.Warning().Msgf("Could not update templates: %s\n", err)
|
||||
}
|
||||
|
||||
@ -86,11 +86,14 @@ func validateMandatoryInfoFields(info *model.Info) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var parsedTemplatesCache *cache.Templates
|
||||
|
||||
var fieldErrorRegexp = regexp.MustCompile(`not found in`)
|
||||
var (
|
||||
parsedTemplatesCache *cache.Templates
|
||||
ShouldValidate bool
|
||||
fieldErrorRegexp = regexp.MustCompile(`not found in`)
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
parsedTemplatesCache = cache.New()
|
||||
|
||||
stats.NewEntry("syntax-warnings", "Got %d syntax warnings for the loaded templates")
|
||||
@ -123,7 +126,11 @@ func ParseTemplate(templatePath string) (*templates.Template, error) {
|
||||
return nil, err
|
||||
}
|
||||
stats.Increment("syntax-warnings")
|
||||
gologger.Warning().Msgf("Syntax warnings for template %s: %s", templatePath, err)
|
||||
if ShouldValidate {
|
||||
gologger.Error().Msgf("Syntax warnings for template %s: %s", templatePath, err)
|
||||
} else {
|
||||
gologger.Warning().Msgf("Syntax warnings for template %s: %s", templatePath, err)
|
||||
}
|
||||
}
|
||||
parsedTemplatesCache.Store(templatePath, template, nil)
|
||||
return template, nil
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user