mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 16:15:26 +00:00
Fix panic err using flow templates with workflow (#5064)
* Fix panic err using flow templates with workflows * Misc update * skip test if pdcp keys are not present --------- Co-authored-by: Tarun Koyalwar <tarun@projectdiscovery.io>
This commit is contained in:
parent
3a3db67248
commit
66da73c1b1
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate"
|
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate"
|
||||||
"github.com/projectdiscovery/nuclei/v3/pkg/types"
|
"github.com/projectdiscovery/nuclei/v3/pkg/types"
|
||||||
"github.com/projectdiscovery/nuclei/v3/pkg/utils/expand"
|
"github.com/projectdiscovery/nuclei/v3/pkg/utils/expand"
|
||||||
|
"github.com/projectdiscovery/utils/auth/pdcp"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -153,6 +154,13 @@ func Test_scanallips_normalizeStoreInputValue(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_expandASNInputValue(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 {
|
tests := []struct {
|
||||||
asn string
|
asn string
|
||||||
expectedOutputFile string
|
expectedOutputFile string
|
||||||
|
|||||||
@ -205,9 +205,25 @@ func (e *TemplateExecuter) Execute(ctx *scan.ScanContext) (bool, error) {
|
|||||||
|
|
||||||
// ExecuteWithResults executes the protocol requests and returns results instead of writing them.
|
// ExecuteWithResults executes the protocol requests and returns results instead of writing them.
|
||||||
func (e *TemplateExecuter) ExecuteWithResults(ctx *scan.ScanContext) ([]*output.ResultEvent, error) {
|
func (e *TemplateExecuter) ExecuteWithResults(ctx *scan.ScanContext) ([]*output.ResultEvent, error) {
|
||||||
err := e.engine.ExecuteWithResults(ctx)
|
var errx error
|
||||||
ctx.LogError(err)
|
if e.options.Flow != "" {
|
||||||
return ctx.GenerateResult(), err
|
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)
|
||||||
|
}
|
||||||
|
if errx != nil {
|
||||||
|
ctx.LogError(errx)
|
||||||
|
}
|
||||||
|
return ctx.GenerateResult(), errx
|
||||||
}
|
}
|
||||||
|
|
||||||
// getTemplateType returns the template type of the template
|
// getTemplateType returns the template type of the template
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user