Skip to content

Commit

Permalink
Add checks to mandatory fields
Browse files Browse the repository at this point in the history
  • Loading branch information
RamanaReddy0M committed Jun 5, 2024
1 parent 49ad3c4 commit 68ce297
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/templates/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 68ce297

Please sign in to comment.