From 3ff62432436d48dd5cc36f8ef830c531a204a183 Mon Sep 17 00:00:00 2001 From: Ramana Reddy Date: Wed, 17 Apr 2024 21:45:05 +0530 Subject: [PATCH 1/3] Fix panic err using flow templates with workflows --- pkg/tmplexec/exec.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pkg/tmplexec/exec.go b/pkg/tmplexec/exec.go index fc504171e6..00309f320b 100644 --- a/pkg/tmplexec/exec.go +++ b/pkg/tmplexec/exec.go @@ -205,9 +205,23 @@ func (e *TemplateExecuter) Execute(ctx *scan.ScanContext) (bool, error) { // ExecuteWithResults executes the protocol requests and returns results instead of writing them. func (e *TemplateExecuter) ExecuteWithResults(ctx *scan.ScanContext) ([]*output.ResultEvent, error) { - err := e.engine.ExecuteWithResults(ctx) - ctx.LogError(err) - return ctx.GenerateResult(), err + var errx error + if e.options.Flow != "" { + flowexec, err := flow.NewFlowExecutor(e.requests, ctx, e.options, e.results, e.program) + if err != nil { + ctx.LogError(err) + return nil, fmt.Errorf("could not create flow executor: %s", err) + } + if err := flowexec.Compile(); err != nil { + ctx.LogError(err) + return nil, err + } + errx = flowexec.ExecuteWithResults(ctx) + } else { + errx = e.engine.ExecuteWithResults(ctx) + } + ctx.LogError(errx) + return ctx.GenerateResult(), errx } // getTemplateType returns the template type of the template From 267ebaf479512f72d964769449a9142c6d1d5cb2 Mon Sep 17 00:00:00 2001 From: Ramana Reddy Date: Thu, 18 Apr 2024 13:01:07 +0530 Subject: [PATCH 2/3] Misc update --- pkg/tmplexec/exec.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/tmplexec/exec.go b/pkg/tmplexec/exec.go index 00309f320b..c510131da2 100644 --- a/pkg/tmplexec/exec.go +++ b/pkg/tmplexec/exec.go @@ -220,7 +220,9 @@ func (e *TemplateExecuter) ExecuteWithResults(ctx *scan.ScanContext) ([]*output. } else { errx = e.engine.ExecuteWithResults(ctx) } - ctx.LogError(errx) + if errx != nil { + ctx.LogError(errx) + } return ctx.GenerateResult(), errx } From fea13757d178193b9c4e53952350416800c36ed1 Mon Sep 17 00:00:00 2001 From: Tarun Koyalwar Date: Thu, 18 Apr 2024 17:21:00 +0530 Subject: [PATCH 3/3] skip test if pdcp keys are not present --- pkg/input/provider/list/hmap_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/input/provider/list/hmap_test.go b/pkg/input/provider/list/hmap_test.go index c3fb4a6699..95fc57f2d9 100644 --- a/pkg/input/provider/list/hmap_test.go +++ b/pkg/input/provider/list/hmap_test.go @@ -13,6 +13,7 @@ import ( "github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate" "github.com/projectdiscovery/nuclei/v3/pkg/types" "github.com/projectdiscovery/nuclei/v3/pkg/utils/expand" + "github.com/projectdiscovery/utils/auth/pdcp" "github.com/stretchr/testify/require" ) @@ -153,6 +154,13 @@ func Test_scanallips_normalizeStoreInputValue(t *testing.T) { } func Test_expandASNInputValue(t *testing.T) { + // skip this test if pdcp keys are not present + h := pdcp.PDCPCredHandler{} + creds, err := h.GetCreds() + if err != nil || creds == nil || creds.APIKey == "" { + t.Logf("Skipping asnmap test as pdcp keys are not present") + t.SkipNow() + } tests := []struct { asn string expectedOutputFile string