mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2026-01-31 15:53:10 +08:00
Revert "introducing workflow sequential mode"
This reverts commit 1093bbc62d.
This commit is contained in:
@@ -27,34 +27,24 @@ func (e *Engine) executeWorkflow(ctx *scan.ScanContext, w *workflows.Workflow) b
|
||||
|
||||
// we can know the nesting level only at runtime, so the best we can do here is increase template threads by one unit in case it's equal to 1 to allow
|
||||
// at least one subtemplate to go through, which it's idempotent to one in-flight template as the parent one is in an idle state
|
||||
|
||||
templateThreads := w.Options.Options.TemplateThreads
|
||||
if templateThreads == 1 {
|
||||
templateThreads++
|
||||
}
|
||||
|
||||
runWorkflowStep := func(template *workflows.WorkflowTemplate, ctx *scan.ScanContext, results *atomic.Bool, swg *syncutil.AdaptiveWaitGroup, w *workflows.Workflow) {
|
||||
if err := e.runWorkflowStep(template, ctx, results, swg, w); err != nil {
|
||||
gologger.Warning().Msgf(workflowStepExecutionError, template.Template, err)
|
||||
}
|
||||
}
|
||||
|
||||
swg, _ := syncutil.New(syncutil.WithSize(templateThreads))
|
||||
|
||||
for _, template := range w.Workflows {
|
||||
if w.Mode == "sequential" {
|
||||
runWorkflowStep(template, ctx, results, swg, w)
|
||||
} else {
|
||||
swg.Add()
|
||||
go func(template *workflows.WorkflowTemplate) {
|
||||
defer swg.Done()
|
||||
newCtx := scan.NewScanContext(ctx.Context(), ctx.Input.Clone())
|
||||
runWorkflowStep(template, newCtx, results, swg, w)
|
||||
}(template)
|
||||
}
|
||||
swg.Add()
|
||||
|
||||
go func(template *workflows.WorkflowTemplate) {
|
||||
defer swg.Done()
|
||||
newCtx := scan.NewScanContext(ctx.Context(), ctx.Input.Clone())
|
||||
if err := e.runWorkflowStep(template, newCtx, results, swg, w); err != nil {
|
||||
gologger.Warning().Msgf(workflowStepExecutionError, template.Template, err)
|
||||
}
|
||||
}(template)
|
||||
}
|
||||
swg.Wait()
|
||||
|
||||
return results.Load()
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,6 @@ import (
|
||||
|
||||
// Workflow is a workflow to execute with chained requests, etc.
|
||||
type Workflow struct {
|
||||
// description: |
|
||||
// Mode to execute workflow (default: "concurrent").
|
||||
// values:
|
||||
// - empty|concurrent (default)
|
||||
// - sequential
|
||||
Mode string `yaml:"mode,omitempty" json:"mode,omitempty" jsonschema:"title=mode to execute workflow,description=Mode to execute workflow,enum=concurrent,enum=sequential"`
|
||||
// description: |
|
||||
// Workflows is a list of workflows to execute for a template.
|
||||
Workflows []*WorkflowTemplate `yaml:"workflows,omitempty" json:"workflows,omitempty" jsonschema:"title=list of workflows to execute,description=List of workflows to execute for template"`
|
||||
|
||||
Reference in New Issue
Block a user