mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 18:55:24 +00:00
parent
cc03b7591a
commit
1c51a6bef6
@ -342,6 +342,11 @@ func parseTemplate(data []byte, options protocols.ExecutorOptions) (*Template, e
|
||||
return nil, errors.New("no template author field provided")
|
||||
}
|
||||
|
||||
numberOfWorkflows := len(template.Workflows)
|
||||
if numberOfWorkflows > 0 && numberOfWorkflows != template.Requests() {
|
||||
return nil, errors.New("workflows cannot have other protocols")
|
||||
}
|
||||
|
||||
// use default unknown severity
|
||||
if len(template.Workflows) == 0 {
|
||||
if template.Info.SeverityHolder.Severity == severity.Undefined {
|
||||
|
||||
@ -197,3 +197,12 @@ func Test_WrongTemplate(t *testing.T) {
|
||||
require.Nil(t, got, "could not parse template")
|
||||
require.ErrorContains(t, err, "no requests defined ")
|
||||
}
|
||||
|
||||
func TestWrongWorkflow(t *testing.T) {
|
||||
setup()
|
||||
|
||||
filePath := "tests/workflow-invalid.yaml"
|
||||
got, err := templates.Parse(filePath, nil, executerOpts)
|
||||
require.Nil(t, got, "could not parse template")
|
||||
require.ErrorContains(t, err, "workflows cannot have other protocols")
|
||||
}
|
||||
|
||||
@ -177,8 +177,6 @@ func (template *Template) Type() types.ProtocolType {
|
||||
return types.HeadlessProtocol
|
||||
case len(template.RequestsNetwork) > 0:
|
||||
return types.NetworkProtocol
|
||||
case len(template.Workflow.Workflows) > 0:
|
||||
return types.WorkflowProtocol
|
||||
case len(template.RequestsSSL) > 0:
|
||||
return types.SSLProtocol
|
||||
case len(template.RequestsWebsocket) > 0:
|
||||
@ -189,6 +187,8 @@ func (template *Template) Type() types.ProtocolType {
|
||||
return types.CodeProtocol
|
||||
case len(template.RequestsJavascript) > 0:
|
||||
return types.JavascriptProtocol
|
||||
case len(template.Workflow.Workflows) > 0:
|
||||
return types.WorkflowProtocol
|
||||
default:
|
||||
return types.InvalidProtocol
|
||||
}
|
||||
|
||||
18
pkg/templates/tests/workflow-invalid.yaml
Normal file
18
pkg/templates/tests/workflow-invalid.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
id: workflow-example
|
||||
|
||||
info:
|
||||
name: Test Invalid Workflow Template
|
||||
author: pdteam
|
||||
severity: info
|
||||
|
||||
http:
|
||||
- raw:
|
||||
- |
|
||||
POST /re HTTP/1.1
|
||||
Host: {{Hostname}}
|
||||
|
||||
{{code_response}}
|
||||
|
||||
workflows:
|
||||
- template: tests/match-1.yaml
|
||||
- template: tests/match-1.yaml
|
||||
Loading…
x
Reference in New Issue
Block a user