@@ -22,6 +22,7 @@ import (
2222 "github.com/projectdiscovery/nuclei/v3/pkg/progress"
2323 "github.com/projectdiscovery/nuclei/v3/pkg/protocols"
2424 "github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/generators"
25+ "github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/globalmatchers"
2526 "github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/variables"
2627 "github.com/projectdiscovery/nuclei/v3/pkg/protocols/http"
2728 "github.com/projectdiscovery/nuclei/v3/pkg/templates"
@@ -184,6 +185,26 @@ func Test_ParseWorkflow(t *testing.T) {
184185 require .Equal (t , len (expectedTemplate .Workflows ), len (got .Workflows ))
185186}
186187
188+ func Test_ParseWorkflowWithGlobalMatchers (t * testing.T ) {
189+ setup ()
190+ previousGlobalMatchers := executerOpts .Options .EnableGlobalMatchersTemplates
191+ executerOpts .Options .EnableGlobalMatchersTemplates = true
192+ defer func () {
193+ executerOpts .Options .EnableGlobalMatchersTemplates = previousGlobalMatchers
194+ executerOpts .GlobalMatchers = nil
195+ }()
196+ executerOpts .GlobalMatchers = globalmatchers .New ()
197+
198+ filePath := "tests/workflow-global-matchers.yaml"
199+ got , err := templates .Parse (filePath , nil , executerOpts )
200+ require .NoError (t , err , "could not parse workflow template" )
201+ require .NotNil (t , got , "workflow template should not be nil" )
202+ require .NotNil (t , got .CompiledWorkflow , "compiled workflow should not be nil" )
203+ require .Len (t , got .CompiledWorkflow .Workflows , 2 )
204+ require .Len (t , got .CompiledWorkflow .Workflows [0 ].Executers , 1 )
205+ require .Len (t , got .CompiledWorkflow .Workflows [1 ].Executers , 0 )
206+ }
207+
187208func Test_WrongTemplate (t * testing.T ) {
188209 setup ()
189210
0 commit comments