Skip to content

Commit

Permalink
Merge pull request netobserv#123 from ronensc/103-bug-mice
Browse files Browse the repository at this point in the history
Fix bug with AddIf
  • Loading branch information
ronensc committed Mar 7, 2022
2 parents e0d95f2 + 5982c88 commit 680ddb3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion pkg/pipeline/transform/transform_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ func (n *Network) Transform(inputEntry config.GenericMap) config.GenericMap {
outputEntries[rule.Output+"_Matched"] = true
}
case api.TransformNetworkOperationName("AddIf"):
expression, err := govaluate.NewEvaluableExpression(fmt.Sprintf("%s%s", outputEntries[rule.Input], rule.Parameters))
expressionString := fmt.Sprintf("%v%s", outputEntries[rule.Input], rule.Parameters)
expression, err := govaluate.NewEvaluableExpression(expressionString)
if err != nil {
log.Errorf("Can't evaluate AddIf rule: %+v expression: %v. err %v", rule, expressionString, err)
continue
}
result, evaluateErr := expression.Evaluate(nil)
Expand Down
4 changes: 2 additions & 2 deletions pkg/pipeline/transform/transform_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ func getExpectedOutput() config.GenericMap {
"subnet16SrcIP": "10.0.0.0/16",
"subnet24SrcIP": "10.0.0.0/24",
"emptyIP": "",
"value": "7",
"smaller_than_10": "7",
"value": 7.0,
"smaller_than_10": 7.0,
"smaller_than_10_Evaluate": true,
"service": "ssh",
"service_protocol_num": "ssh",
Expand Down
2 changes: 1 addition & 1 deletion pkg/test/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func GetIngestMockEntry(missingKey bool) config.GenericMap {
"srcPort": 11777,
"protocol": "tcp",
"protocol_num": 6,
"value": "7",
"value": 7.0,
"message": "test message",
}

Expand Down

0 comments on commit 680ddb3

Please sign in to comment.