mirror of https://github.com/daffainfo/nuclei.git
Misc fixes related to workflows
parent
3ec3ecdd8a
commit
c4843cdaf5
|
@ -71,6 +71,7 @@ func Parse(filePath string, options protocols.ExecuterOptions) (*Template, error
|
||||||
return nil, errors.Wrap(err, "could not compile workflow")
|
return nil, errors.Wrap(err, "could not compile workflow")
|
||||||
}
|
}
|
||||||
template.CompiledWorkflow = compiled
|
template.CompiledWorkflow = compiled
|
||||||
|
template.CompiledWorkflow.Options = &options
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile the requests found
|
// Compile the requests found
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
|
|
||||||
// Parse a yaml workflow file
|
// Parse a yaml workflow file
|
||||||
func Parse(file string, options *protocols.ExecuterOptions) (*Workflow, error) {
|
func Parse(file string, options *protocols.ExecuterOptions) (*Workflow, error) {
|
||||||
workflow := &Workflow{options: options}
|
workflow := &Workflow{Options: options}
|
||||||
|
|
||||||
f, err := os.Open(file)
|
f, err := os.Open(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
func (w *Workflow) RunWorkflow(input string) bool {
|
func (w *Workflow) RunWorkflow(input string) bool {
|
||||||
results := &atomic.Bool{}
|
results := &atomic.Bool{}
|
||||||
|
|
||||||
swg := sizedwaitgroup.New(w.options.Options.TemplateThreads)
|
swg := sizedwaitgroup.New(w.Options.Options.TemplateThreads)
|
||||||
for _, template := range w.Workflows {
|
for _, template := range w.Workflows {
|
||||||
swg.Add()
|
swg.Add()
|
||||||
func(template *WorkflowTemplate) {
|
func(template *WorkflowTemplate) {
|
||||||
|
|
|
@ -12,9 +12,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestWorkflowsSimple(t *testing.T) {
|
func TestWorkflowsSimple(t *testing.T) {
|
||||||
progress, _ := progress.NewProgress(false, false, 0)
|
progress, _ := progress.NewProgress(0, false, false, 0)
|
||||||
|
|
||||||
workflow := &Workflow{options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
|
workflow := &Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
|
||||||
{Executers: []*ProtocolExecuterPair{{
|
{Executers: []*ProtocolExecuterPair{{
|
||||||
Executer: &mockExecuter{result: true}, Options: &protocols.ExecuterOptions{Progress: progress}},
|
Executer: &mockExecuter{result: true}, Options: &protocols.ExecuterOptions{Progress: progress}},
|
||||||
}},
|
}},
|
||||||
|
@ -25,10 +25,10 @@ func TestWorkflowsSimple(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWorkflowsSimpleMultiple(t *testing.T) {
|
func TestWorkflowsSimpleMultiple(t *testing.T) {
|
||||||
progress, _ := progress.NewProgress(false, false, 0)
|
progress, _ := progress.NewProgress(0, false, false, 0)
|
||||||
|
|
||||||
var firstInput, secondInput string
|
var firstInput, secondInput string
|
||||||
workflow := &Workflow{options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
|
workflow := &Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
|
||||||
{Executers: []*ProtocolExecuterPair{{
|
{Executers: []*ProtocolExecuterPair{{
|
||||||
Executer: &mockExecuter{result: true, executeHook: func(input string) {
|
Executer: &mockExecuter{result: true, executeHook: func(input string) {
|
||||||
firstInput = input
|
firstInput = input
|
||||||
|
@ -49,10 +49,10 @@ func TestWorkflowsSimpleMultiple(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWorkflowsSubtemplates(t *testing.T) {
|
func TestWorkflowsSubtemplates(t *testing.T) {
|
||||||
progress, _ := progress.NewProgress(false, false, 0)
|
progress, _ := progress.NewProgress(0, false, false, 0)
|
||||||
|
|
||||||
var firstInput, secondInput string
|
var firstInput, secondInput string
|
||||||
workflow := &Workflow{options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
|
workflow := &Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
|
||||||
{Executers: []*ProtocolExecuterPair{{
|
{Executers: []*ProtocolExecuterPair{{
|
||||||
Executer: &mockExecuter{result: true, executeHook: func(input string) {
|
Executer: &mockExecuter{result: true, executeHook: func(input string) {
|
||||||
firstInput = input
|
firstInput = input
|
||||||
|
@ -72,10 +72,10 @@ func TestWorkflowsSubtemplates(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWorkflowsSubtemplatesNoMatch(t *testing.T) {
|
func TestWorkflowsSubtemplatesNoMatch(t *testing.T) {
|
||||||
progress, _ := progress.NewProgress(false, false, 0)
|
progress, _ := progress.NewProgress(0, false, false, 0)
|
||||||
|
|
||||||
var firstInput, secondInput string
|
var firstInput, secondInput string
|
||||||
workflow := &Workflow{options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
|
workflow := &Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
|
||||||
{Executers: []*ProtocolExecuterPair{{
|
{Executers: []*ProtocolExecuterPair{{
|
||||||
Executer: &mockExecuter{result: false, executeHook: func(input string) {
|
Executer: &mockExecuter{result: false, executeHook: func(input string) {
|
||||||
firstInput = input
|
firstInput = input
|
||||||
|
@ -95,10 +95,10 @@ func TestWorkflowsSubtemplatesNoMatch(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWorkflowsSubtemplatesWithMatcher(t *testing.T) {
|
func TestWorkflowsSubtemplatesWithMatcher(t *testing.T) {
|
||||||
progress, _ := progress.NewProgress(false, false, 0)
|
progress, _ := progress.NewProgress(0, false, false, 0)
|
||||||
|
|
||||||
var firstInput, secondInput string
|
var firstInput, secondInput string
|
||||||
workflow := &Workflow{options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
|
workflow := &Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
|
||||||
{Executers: []*ProtocolExecuterPair{{
|
{Executers: []*ProtocolExecuterPair{{
|
||||||
Executer: &mockExecuter{result: true, executeHook: func(input string) {
|
Executer: &mockExecuter{result: true, executeHook: func(input string) {
|
||||||
firstInput = input
|
firstInput = input
|
||||||
|
@ -123,10 +123,10 @@ func TestWorkflowsSubtemplatesWithMatcher(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWorkflowsSubtemplatesWithMatcherNoMatch(t *testing.T) {
|
func TestWorkflowsSubtemplatesWithMatcherNoMatch(t *testing.T) {
|
||||||
progress, _ := progress.NewProgress(false, false, 0)
|
progress, _ := progress.NewProgress(0, false, false, 0)
|
||||||
|
|
||||||
var firstInput, secondInput string
|
var firstInput, secondInput string
|
||||||
workflow := &Workflow{options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
|
workflow := &Workflow{Options: &protocols.ExecuterOptions{Options: &types.Options{TemplateThreads: 10}}, Workflows: []*WorkflowTemplate{
|
||||||
{Executers: []*ProtocolExecuterPair{{
|
{Executers: []*ProtocolExecuterPair{{
|
||||||
Executer: &mockExecuter{result: true, executeHook: func(input string) {
|
Executer: &mockExecuter{result: true, executeHook: func(input string) {
|
||||||
firstInput = input
|
firstInput = input
|
||||||
|
|
|
@ -7,7 +7,7 @@ type Workflow struct {
|
||||||
// Workflows is a yaml based workflow declaration code.
|
// Workflows is a yaml based workflow declaration code.
|
||||||
Workflows []*WorkflowTemplate `yaml:"workflows,omitempty"`
|
Workflows []*WorkflowTemplate `yaml:"workflows,omitempty"`
|
||||||
|
|
||||||
options *protocols.ExecuterOptions
|
Options *protocols.ExecuterOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
// WorkflowTemplate is a template to be ran as part of a workflow
|
// WorkflowTemplate is a template to be ran as part of a workflow
|
||||||
|
|
Loading…
Reference in New Issue