2020-06-26 08:23:54 +00:00
package workflows
2021-07-15 10:41:41 +00:00
import (
2021-09-03 13:48:39 +00:00
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/stringslice"
2021-07-15 10:41:41 +00:00
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
)
2020-12-25 20:38:48 +00:00
2020-06-29 12:13:08 +00:00
// Workflow is a workflow to execute with chained requests, etc.
2020-06-26 08:23:54 +00:00
type Workflow struct {
2021-07-27 10:33:56 +00:00
// description: |
// Workflows is a list of workflows to execute for a template.
2021-08-23 18:20:45 +00:00
Workflows [ ] * WorkflowTemplate ` yaml:"workflows,omitempty" jsonschema:"title=list of workflows to execute,description=List of workflows to execute for template" `
2021-02-22 12:19:02 +00:00
2021-08-23 18:20:45 +00:00
Options * protocols . ExecuterOptions ` yaml:"-" `
2020-11-12 17:58:24 +00:00
}
2021-09-07 14:31:46 +00:00
// WorkflowTemplate is a template to be run as part of a workflow
2020-11-12 17:58:24 +00:00
type WorkflowTemplate struct {
2021-07-27 10:33:56 +00:00
// description: |
// Template is a single template or directory to execute as part of workflow.
// examples:
// - name: A single template
// value: "\"dns/worksites-detection.yaml\""
// - name: A template directory
// value: "\"misconfigurations/aem\""
2021-08-23 18:20:45 +00:00
Template string ` yaml:"template,omitempty" jsonschema:"title=template/directory to execute,description=Template or directory to execute as part of workflow" `
2021-07-27 10:33:56 +00:00
// description: |
// Tags to run templates based on.
2021-09-03 13:48:39 +00:00
Tags stringslice . StringSlice ` yaml:"tags,omitempty" jsonschema:"title=tags to execute,description=Tags to run template based on" `
2021-07-27 10:33:56 +00:00
// description: |
// Matchers perform name based matching to run subtemplates for a workflow.
2021-08-23 18:20:45 +00:00
Matchers [ ] * Matcher ` yaml:"matchers,omitempty" jsonschema:"title=name based template result matchers,description=Matchers perform name based matching to run subtemplates for a workflow" `
2021-07-27 10:33:56 +00:00
// description: |
2021-09-07 14:31:46 +00:00
// Subtemplates are run if the `template` field Template matches.
2021-08-23 18:20:45 +00:00
Subtemplates [ ] * WorkflowTemplate ` yaml:"subtemplates,omitempty" jsonschema:"title=subtemplate based result matchers,description=Subtemplates are ran if the template field Template matches" `
2021-01-17 07:26:29 +00:00
// Executers perform the actual execution for the workflow template
2021-08-19 11:21:02 +00:00
Executers [ ] * ProtocolExecuterPair ` yaml:"-" `
2021-01-17 07:26:29 +00:00
}
// ProtocolExecuterPair is a pair of protocol executer and its options
type ProtocolExecuterPair struct {
2020-12-29 12:32:45 +00:00
Executer protocols . Executer
2021-01-17 07:26:29 +00:00
Options * protocols . ExecuterOptions
2020-11-12 17:58:24 +00:00
}
// Matcher performs conditional matching on the workflow template results.
type Matcher struct {
2021-07-27 10:33:56 +00:00
// description: |
// Name is the name of the item to match.
2021-08-23 18:20:45 +00:00
Name string ` yaml:"name,omitempty" jsonschema:"title=name of item to match,description=Name of item to match" `
2021-07-27 10:33:56 +00:00
// description: |
2021-09-07 14:31:46 +00:00
// Subtemplates are run if the name of matcher matches.
2021-08-23 18:20:45 +00:00
Subtemplates [ ] * WorkflowTemplate ` yaml:"subtemplates,omitempty" jsonschema:"title=templates to run after match,description=Templates to run after match" `
2020-07-26 18:14:05 +00:00
}