diff --git a/pkg/templates/templates.go b/pkg/templates/templates.go index 6403c2767a..045f947c68 100644 --- a/pkg/templates/templates.go +++ b/pkg/templates/templates.go @@ -23,6 +23,7 @@ import ( "github.com/projectdiscovery/nuclei/v3/pkg/protocols/websocket" "github.com/projectdiscovery/nuclei/v3/pkg/protocols/whois" "github.com/projectdiscovery/nuclei/v3/pkg/templates/types" + "github.com/projectdiscovery/nuclei/v3/pkg/utils" "github.com/projectdiscovery/nuclei/v3/pkg/workflows" errorutil "github.com/projectdiscovery/utils/errors" fileutil "github.com/projectdiscovery/utils/file" @@ -326,6 +327,17 @@ func (template *Template) UnmarshalYAML(unmarshal func(interface{}) error) error } *template = Template(*alias) + if !ReTemplateID.MatchString(template.ID) { + return errorutil.New("template id must match expression %v", ReTemplateID).WithTag("invalid template") + } + info := template.Info + if utils.IsBlank(info.Name) { + return errorutil.New("no template name field provided").WithTag("invalid template") + } + if info.Authors.IsEmpty() { + return errorutil.New("no template author field provided").WithTag("invalid template") + } + if len(template.RequestsHTTP) > 0 || len(template.RequestsNetwork) > 0 { _ = deprecatedProtocolNameTemplates.Set(template.ID, true) }