sandeep 2022-07-24 15:00:44 +05:30
commit 3052d8a7f6
1 changed files with 2 additions and 13 deletions

View File

@ -7,7 +7,6 @@ import (
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/loader/filter" "github.com/projectdiscovery/nuclei/v2/pkg/catalog/loader/filter"
"github.com/projectdiscovery/nuclei/v2/pkg/model" "github.com/projectdiscovery/nuclei/v2/pkg/model"
"github.com/projectdiscovery/nuclei/v2/pkg/templates" "github.com/projectdiscovery/nuclei/v2/pkg/templates"
@ -104,7 +103,6 @@ var (
parsedTemplatesCache *cache.Templates parsedTemplatesCache *cache.Templates
ShouldValidate bool ShouldValidate bool
NoStrictSyntax bool NoStrictSyntax bool
fieldErrorRegexp = regexp.MustCompile(`not found in`)
templateIDRegexp = regexp.MustCompile(`^([a-zA-Z0-9]+[-_])*[a-zA-Z0-9]+$`) templateIDRegexp = regexp.MustCompile(`^([a-zA-Z0-9]+[-_])*[a-zA-Z0-9]+$`)
) )
@ -140,17 +138,8 @@ func ParseTemplate(templatePath string) (*templates.Template, error) {
err = yaml.UnmarshalStrict(data, template) err = yaml.UnmarshalStrict(data, template)
} }
if err != nil { if err != nil {
errString := err.Error() stats.Increment(SyntaxErrorStats)
if !fieldErrorRegexp.MatchString(errString) { return nil, err
stats.Increment(SyntaxErrorStats)
return nil, err
}
stats.Increment(SyntaxWarningStats)
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) parsedTemplatesCache.Store(templatePath, template, nil)
return template, nil return template, nil