From 53b280cf326854b75efa7b73afdf6b2a75c00bba Mon Sep 17 00:00:00 2001 From: Manuel Bua Date: Mon, 27 Jul 2020 20:38:48 +0200 Subject: [PATCH] Ensure workflows can be run alone as well --- v2/internal/runner/runner.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/v2/internal/runner/runner.go b/v2/internal/runner/runner.go index 5d04d764..cb40035d 100644 --- a/v2/internal/runner/runner.go +++ b/v2/internal/runner/runner.go @@ -285,7 +285,7 @@ func (r *Runner) RunEnumeration() { // precompute total request count var totalRequests int64 = 0 - templateCount := len(allTemplates) + hasWorkflows := false parsedTemplates := []string{} for _, match := range allTemplates { @@ -299,11 +299,16 @@ func (r *Runner) RunEnumeration() { // workflows will dynamically adjust the totals while running, as // it can't be know in advance which requests will be called parsedTemplates = append(parsedTemplates, match) + hasWorkflows = true default: gologger.Errorf("Could not parse file '%s': %s\n", match, err) } } + // ensure only successfully parsed templates are processed + allTemplates = parsedTemplates + templateCount := len(allTemplates) + var ( wgtemplates sync.WaitGroup results atomicboolean.AtomBool @@ -311,9 +316,7 @@ func (r *Runner) RunEnumeration() { if r.inputCount == 0 { gologger.Errorf("Could not find any valid input URLs.") - } else if totalRequests > 0 { - // ensure only successfully parsed templates are processed - allTemplates = parsedTemplates + } else if totalRequests > 0 || hasWorkflows { // track global progress p.InitProgressbar(r.inputCount, templateCount, totalRequests) @@ -459,7 +462,9 @@ func (r *Runner) ProcessWorkflowWithList(p *progress.Progress, workflow *workflo for scanner.Scan() { text := scanner.Text() if err := r.ProcessWorkflow(p, workflow, text); err != nil { + p.StartStdCapture() gologger.Warningf("Could not run workflow for %s: %s\n", text, err) + p.StopStdCapture() } } }