diff --git a/v2/pkg/operators/operators.go b/v2/pkg/operators/operators.go index 87886e64..2497fa49 100644 --- a/v2/pkg/operators/operators.go +++ b/v2/pkg/operators/operators.go @@ -162,3 +162,21 @@ func (r *Operators) Execute(data map[string]interface{}, match MatchFunc, extrac } return nil, false } + +// ExecuteInternalExtractors executes internal dynamic extractors +func (r *Operators) ExecuteInternalExtractors(data map[string]interface{}, extract ExtractFunc) map[string]interface{} { + dynamicValues := make(map[string]interface{}) + + // Start with the extractors first and evaluate them. + for _, extractor := range r.Extractors { + if !extractor.Internal { + continue + } + for match := range extract(data, extractor) { + if _, ok := dynamicValues[extractor.Name]; !ok { + dynamicValues[extractor.Name] = match + } + } + } + return dynamicValues +} diff --git a/v2/pkg/protocols/network/request.go b/v2/pkg/protocols/network/request.go index 16764b04..8e8f122d 100644 --- a/v2/pkg/protocols/network/request.go +++ b/v2/pkg/protocols/network/request.go @@ -149,8 +149,18 @@ func (r *Request) executeRequestWithPayloads(actualAddress, address, input strin buffer := make([]byte, input.Read) n, _ := conn.Read(buffer) responseBuilder.Write(buffer[:n]) + + bufferStr := string(buffer[:n]) if input.Name != "" { - inputEvents[input.Name] = string(buffer[:n]) + inputEvents[input.Name] = bufferStr + } + + // Run any internal extractors for the request here and add found values to map. + if r.CompiledOperators != nil { + values := r.CompiledOperators.ExecuteInternalExtractors(map[string]interface{}{input.Name: bufferStr}, r.Extract) + for k, v := range values { + payloads[k] = v + } } } }