diff --git a/v2/pkg/operators/operators.go b/v2/pkg/operators/operators.go index 818cba73..63581f0a 100644 --- a/v2/pkg/operators/operators.go +++ b/v2/pkg/operators/operators.go @@ -121,7 +121,7 @@ func (r *Operators) Execute(data map[string]interface{}, match MatchFunc, extrac } // Write a final string of output if matcher type is // AND or if we have extractors for the mechanism too. - if len(result.Extracts) > 0 || matches { + if len(result.Extracts) > 0 || len(result.OutputExtracts) > 0 || matches { return result, true } return nil, false diff --git a/v2/pkg/output/output.go b/v2/pkg/output/output.go index aeeb92dd..e79c1f4a 100644 --- a/v2/pkg/output/output.go +++ b/v2/pkg/output/output.go @@ -54,7 +54,7 @@ type ResultEvent struct { // TemplateID is the ID of the template for the result. TemplateID string `json:"templateID"` // Info contains information block of the template for the result. - Info map[string]string `json:"info"` + Info map[string]string `json:"info,inline"` // MatcherName is the name of the matcher matched if any. MatcherName string `json:"matcher_name,omitempty"` // ExtractorName is the name of the extractor matched if any. diff --git a/v2/pkg/protocols/dns/request.go b/v2/pkg/protocols/dns/request.go index 1b299ade..7b95cad4 100644 --- a/v2/pkg/protocols/dns/request.go +++ b/v2/pkg/protocols/dns/request.go @@ -56,7 +56,7 @@ func (r *Request) ExecuteWithResults(input string, metadata output.InternalEvent event := &output.InternalWrappedEvent{InternalEvent: ouputEvent} if r.CompiledOperators != nil { - result, ok := r.Operators.Execute(ouputEvent, r.Match, r.Extract) + result, ok := r.CompiledOperators.Execute(ouputEvent, r.Match, r.Extract) if ok && result != nil { event.OperatorsResult = result event.Results = r.MakeResultEvent(event) diff --git a/v2/pkg/protocols/file/request.go b/v2/pkg/protocols/file/request.go index 29e56a94..dd054c6a 100644 --- a/v2/pkg/protocols/file/request.go +++ b/v2/pkg/protocols/file/request.go @@ -50,7 +50,7 @@ func (r *Request) ExecuteWithResults(input string, metadata output.InternalEvent event := &output.InternalWrappedEvent{InternalEvent: ouputEvent} if r.CompiledOperators != nil { - result, ok := r.Operators.Execute(ouputEvent, r.Match, r.Extract) + result, ok := r.CompiledOperators.Execute(ouputEvent, r.Match, r.Extract) if ok && result != nil { event.OperatorsResult = result event.Results = r.MakeResultEvent(event) diff --git a/v2/pkg/protocols/http/build_request.go b/v2/pkg/protocols/http/build_request.go index b2c515ba..958dd077 100644 --- a/v2/pkg/protocols/http/build_request.go +++ b/v2/pkg/protocols/http/build_request.go @@ -105,6 +105,8 @@ type generatedRequest struct { // Make creates a http request for the provided input. // It returns io.EOF as error when all the requests have been exhausted. func (r *requestGenerator) Make(baseURL string, dynamicValues map[string]interface{}) (*generatedRequest, error) { + baseURL = strings.TrimSuffix(baseURL, "/") + data, payloads, ok := r.nextValue() if !ok { return nil, io.EOF @@ -155,9 +157,6 @@ func baseURLWithTemplatePrefs(data string, parsedURL *url.URL) string { // MakeHTTPRequestFromModel creates a *http.Request from a request template func (r *requestGenerator) makeHTTPRequestFromModel(ctx context.Context, data string, values map[string]interface{}) (*generatedRequest, error) { - if strings.HasSuffix(values["BaseURL"].(string), "/") { - data = strings.TrimPrefix(data, "/") - } URL := replacer.New(values).Replace(data) // Build a request on the specified URL diff --git a/v2/pkg/protocols/http/raw/raw.go b/v2/pkg/protocols/http/raw/raw.go index 000c21ee..27fb5768 100644 --- a/v2/pkg/protocols/http/raw/raw.go +++ b/v2/pkg/protocols/http/raw/raw.go @@ -96,9 +96,6 @@ func Parse(request, baseURL string, unsafe bool) (*Request, error) { } else if strings.HasPrefix(rawRequest.Path, "?") { rawRequest.Path = fmt.Sprintf("%s%s", parsedURL.Path, rawRequest.Path) } - if strings.HasSuffix(hostURL, "/") { - rawRequest.Path = strings.TrimPrefix(rawRequest.Path, "/") - } rawRequest.FullURL = fmt.Sprintf("%s://%s%s", parsedURL.Scheme, strings.TrimSpace(hostURL), rawRequest.Path) // Set the request body diff --git a/v2/pkg/protocols/http/request.go b/v2/pkg/protocols/http/request.go index f49a932f..b0868545 100644 --- a/v2/pkg/protocols/http/request.go +++ b/v2/pkg/protocols/http/request.go @@ -330,7 +330,7 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, dynam event := &output.InternalWrappedEvent{InternalEvent: ouputEvent} if r.CompiledOperators != nil { - result, ok := r.Operators.Execute(ouputEvent, r.Match, r.Extract) + result, ok := r.CompiledOperators.Execute(ouputEvent, r.Match, r.Extract) if ok && result != nil { event.OperatorsResult = result result.PayloadValues = request.meta diff --git a/v2/pkg/protocols/network/request.go b/v2/pkg/protocols/network/request.go index a3402163..408caa31 100644 --- a/v2/pkg/protocols/network/request.go +++ b/v2/pkg/protocols/network/request.go @@ -122,7 +122,7 @@ func (r *Request) executeAddress(actualAddress, address, input string, callback event := &output.InternalWrappedEvent{InternalEvent: ouputEvent} if r.CompiledOperators != nil { - result, ok := r.Operators.Execute(ouputEvent, r.Match, r.Extract) + result, ok := r.CompiledOperators.Execute(ouputEvent, r.Match, r.Extract) if ok && result != nil { event.OperatorsResult = result event.Results = r.MakeResultEvent(event)