From ab36aeed39fc7dd507aa1e09d2dd64a24f24a451 Mon Sep 17 00:00:00 2001 From: Tarun Koyalwar Date: Thu, 10 Aug 2023 19:28:05 +0530 Subject: [PATCH] deprecate iterate-all+ missing multi-proto implementation --- v2/pkg/protocols/code/code.go | 11 ++++++++++- v2/pkg/protocols/http/http.go | 1 + v2/pkg/protocols/multi/README.md | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/v2/pkg/protocols/code/code.go b/v2/pkg/protocols/code/code.go index e7f710074b..14de35becb 100644 --- a/v2/pkg/protocols/code/code.go +++ b/v2/pkg/protocols/code/code.go @@ -117,10 +117,12 @@ func (request *Request) ExecuteWithResults(input *contextargs.Context, dynamicVa // inject all template context values as gozero env variables variables := protocolutils.GenerateVariables(input.MetaInput.Input, false, nil) + // add template context values + variables = generators.MergeMaps(variables, request.options.TemplateCtx.GetAll()) // optionvars are vars passed from CLI or env variables optionVars := generators.BuildPayloadFromOptions(request.options.Options) variablesMap := request.options.Variables.Evaluate(variables) - variables = generators.MergeMaps(variablesMap, variables, optionVars) + variables = generators.MergeMaps(variablesMap, variables, optionVars, request.options.Constants) for name, value := range variables { v := fmt.Sprint(value) v, interactshURLs = request.options.Interactsh.Replace(v, interactshURLs) @@ -153,6 +155,13 @@ func (request *Request) ExecuteWithResults(input *contextargs.Context, dynamicVa data["template-id"] = request.options.TemplateID data["template-info"] = request.options.TemplateInfo + // expose response variables in proto_var format + // this is no-op if the template is not a multi protocol template + request.options.AddTemplateVars(request.Type(), request.ID, data) + + // add variables from template context before matching/extraction + data = generators.MergeMaps(data, request.options.TemplateCtx.GetAll()) + if request.options.Interactsh != nil { request.options.Interactsh.MakePlaceholders(interactshURLs, data) } diff --git a/v2/pkg/protocols/http/http.go b/v2/pkg/protocols/http/http.go index 7cef0a2e18..afd5545a17 100644 --- a/v2/pkg/protocols/http/http.go +++ b/v2/pkg/protocols/http/http.go @@ -190,6 +190,7 @@ type Request struct { SkipVariablesCheck bool `yaml:"skip-variables-check,omitempty" json:"skip-variables-check,omitempty" jsonschema:"title=skip variable checks,description=Skips the check for unresolved variables in request"` // description: | // IterateAll iterates all the values extracted from internal extractors + // Deprecated: Use flow instead . iterate-all will be removed in future releases IterateAll bool `yaml:"iterate-all,omitempty" json:"iterate-all,omitempty" jsonschema:"title=iterate all the values,description=Iterates all the values extracted from internal extractors"` // description: | // DigestAuthUsername specifies the username for digest authentication diff --git a/v2/pkg/protocols/multi/README.md b/v2/pkg/protocols/multi/README.md index f7c665cdb8..f905554001 100644 --- a/v2/pkg/protocols/multi/README.md +++ b/v2/pkg/protocols/multi/README.md @@ -36,7 +36,7 @@ to make response fields of that protocol available to global context outputEvent := request.responseToDSLMap(compiledRequest, response, domain, question, traceData) // expose response variables in proto_var format // this is no-op if the template is not a multi protocol template - request.options.AddTemplateVars(request.Type(), outputEvent) + request.options.AddTemplateVars(request.Type(),request.ID, outputEvent) ``` - Append all available template context values to outputEvent