From 68ce2979726755061286eaa83ba1d217addd5de8 Mon Sep 17 00:00:00 2001 From: Ramana Reddy Date: Wed, 5 Jun 2024 13:32:41 +0530 Subject: [PATCH] Add checks to mandatory fields --- pkg/templates/templates.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/templates/templates.go b/pkg/templates/templates.go index f9c8de2d0e..06e3940cc9 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" @@ -329,6 +330,13 @@ func (template *Template) UnmarshalYAML(unmarshal func(interface{}) error) error 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("info.name is a mandatory field").WithTag("invalid template") + } + if info.Authors.IsEmpty() { + return errorutil.New("info.author is a mandatory field").WithTag("invalid template") + } if len(template.RequestsHTTP) > 0 || len(template.RequestsNetwork) > 0 { _ = deprecatedProtocolNameTemplates.Set(template.ID, true)