diff --git a/internal/actions/setvar.go b/internal/actions/setvar.go index 2c3635206..ec772c529 100644 --- a/internal/actions/setvar.go +++ b/internal/actions/setvar.go @@ -150,11 +150,17 @@ func (a *setvarFn) evaluateTxCollection(r plugintypes.RuleMetadata, tx plugintyp if len(value) > 1 { val, err = strconv.Atoi(value[1:]) if err != nil { - tx.DebugLogger().Error(). - Str("var_value", value). - Int("rule_id", r.ID()). - Err(err). - Msg("Invalid value") + // If the variable doesn't exist, we would need to raise an error. Otherwise, it should be the same value. + if strings.HasPrefix(value[1:], "tx.") { + tx.DebugLogger().Error(). + Str("var_value", value). + Int("rule_id", r.ID()). + Err(err). + Msg(value) + return + } + + col.Set(key, []string{value}) return } } diff --git a/internal/actions/setvar_test.go b/internal/actions/setvar_test.go index 591d5a853..e8e922142 100644 --- a/internal/actions/setvar_test.go +++ b/internal/actions/setvar_test.go @@ -96,6 +96,16 @@ func TestSetvarEvaluate(t *testing.T) { init: "TX.newvar=-%{tx.missingvar}", expectInvalidSyntaxError: true, }, + { + name: "Non Numerical Operation - If the value starts with -", + init: "TX.newvar=----expected_value", + expectInvalidSyntaxError: false, + }, + { + name: "Non Numerical Operation - If the value starts with +", + init: "TX.newvar=+++expected_value", + expectInvalidSyntaxError: false, + }, } for _, tt := range tests {