From c5c180015e268c0c87415770744996d267503589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fan=20Can=20Bak=C4=B1r?= Date: Fri, 24 Jan 2025 11:33:50 +0300 Subject: [PATCH] Ensure Headless protocol accesses flow protocol variables --- pkg/protocols/headless/request.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/protocols/headless/request.go b/pkg/protocols/headless/request.go index 5617fc7bae..57c79dfad4 100644 --- a/pkg/protocols/headless/request.go +++ b/pkg/protocols/headless/request.go @@ -52,14 +52,13 @@ func (request *Request) ExecuteWithResults(input *contextargs.Context, metadata, } vars := protocolutils.GenerateVariablesWithContextArgs(input, false) - payloads := generators.BuildPayloadFromOptions(request.options.Options) + optionVars := generators.BuildPayloadFromOptions(request.options.Options) // add templatecontext variables to varMap - values := generators.MergeMaps(vars, metadata, payloads) if request.options.HasTemplateCtx(input.MetaInput) { - values = generators.MergeMaps(values, request.options.GetTemplateCtx(input.MetaInput).GetAll()) + vars = generators.MergeMaps(vars, metadata, optionVars, request.options.GetTemplateCtx(input.MetaInput).GetAll()) } - variablesMap := request.options.Variables.Evaluate(values) - payloads = generators.MergeMaps(variablesMap, payloads, request.options.Constants) + variablesMap := request.options.Variables.Evaluate(vars) + vars = generators.MergeMaps(vars, variablesMap, request.options.Constants) // check for operator matches by wrapping callback gotmatches := false @@ -71,7 +70,7 @@ func (request *Request) ExecuteWithResults(input *contextargs.Context, metadata, } // verify if fuzz elaboration was requested if len(request.Fuzzing) > 0 { - return request.executeFuzzingRule(input, payloads, previous, wrappedCallback) + return request.executeFuzzingRule(input, vars, previous, wrappedCallback) } if request.generator != nil { iterator := request.generator.NewIterator() @@ -83,13 +82,13 @@ func (request *Request) ExecuteWithResults(input *contextargs.Context, metadata, if gotmatches && (request.StopAtFirstMatch || request.options.Options.StopAtFirstMatch || request.options.StopAtFirstMatch) { return nil } - value = generators.MergeMaps(value, payloads) + value = generators.MergeMaps(value, vars) if err := request.executeRequestWithPayloads(input, value, previous, wrappedCallback); err != nil { return err } } } else { - value := maps.Clone(payloads) + value := maps.Clone(vars) if err := request.executeRequestWithPayloads(input, value, previous, wrappedCallback); err != nil { return err }