diff --git a/pkg/protocols/http/operators.go b/pkg/protocols/http/operators.go index 298da25e1a..0ba0fc5577 100644 --- a/pkg/protocols/http/operators.go +++ b/pkg/protocols/http/operators.go @@ -173,6 +173,12 @@ func (request *Request) MakeResultEventItem(wrapped *output.InternalWrappedEvent if value, ok := wrapped.InternalEvent["analyzer_details"]; ok { analyzerDetails = value.(string) } + var reqURLPattern string + if request.options.ExportReqURLPattern { + if value, ok := wrapped.InternalEvent[ReqURLPatternKey]; ok { + reqURLPattern = types.ToString(value) + } + } data := &output.ResultEvent{ TemplateID: types.ToString(wrapped.InternalEvent["template-id"]), TemplatePath: types.ToString(wrapped.InternalEvent["template-path"]), @@ -197,6 +203,7 @@ func (request *Request) MakeResultEventItem(wrapped *output.InternalWrappedEvent TemplateEncoded: request.options.EncodeTemplate(), Error: types.ToString(wrapped.InternalEvent["error"]), AnalyzerDetails: analyzerDetails, + ReqURLPattern: reqURLPattern, } return data } diff --git a/pkg/protocols/http/request.go b/pkg/protocols/http/request.go index 9698b4ade5..47d795f9f5 100644 --- a/pkg/protocols/http/request.go +++ b/pkg/protocols/http/request.go @@ -1043,6 +1043,11 @@ func (request *Request) executeRequest(input *contextargs.Context, generatedRequ request.pruneSignatureInternalValues(generatedRequest.meta) interimEvent := generators.MergeMaps(generatedRequest.dynamicValues, finalEvent) + // add the request URL pattern to the event BEFORE operators execute + // so that interactsh events etc can also access it + if request.options.ExportReqURLPattern { + interimEvent[ReqURLPatternKey] = generatedRequest.requestURLPattern + } isDebug := request.options.Options.Debug || request.options.Options.DebugResponse event := eventcreator.CreateEventWithAdditionalOptions(request, interimEvent, isDebug, func(internalWrappedEvent *output.InternalWrappedEvent) { internalWrappedEvent.OperatorsResult.PayloadValues = generatedRequest.meta @@ -1058,14 +1063,6 @@ func (request *Request) executeRequest(input *contextargs.Context, generatedRequ }) } - // if requrlpattern is enabled, only then it is reflected in result event else it is empty string - // consult @Ice3man543 before changing this logic (context: vuln_hash) - if request.options.ExportReqURLPattern { - for _, v := range event.Results { - v.ReqURLPattern = generatedRequest.requestURLPattern - } - } - responseContentType := respChain.Response().Header.Get("Content-Type") isResponseTruncated := request.MaxSize > 0 && respChain.Body().Len() >= request.MaxSize dumpResponse(event, request, respChain.FullResponse().Bytes(), formedURL, responseContentType, isResponseTruncated, input.MetaInput.Input)