Merge pull request #580 from projectdiscovery/fix-unevaulable-exprs

Fix erroring out behaviour on unevaulable expressions
dev
Ice3man 2021-02-26 13:33:33 +05:30 committed by GitHub
commit e6a52b649b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -26,11 +26,11 @@ func Evaluate(data string, base map[string]interface{}) (string, error) {
compiled, err := govaluate.NewEvaluableExpressionWithFunctions(expr, dsl.HelperFunctions())
if err != nil {
return "", err
continue
}
result, err := compiled.Evaluate(base)
if err != nil {
return "", err
continue
}
dynamicValues[expr] = result // convert x(<payload_name>) => <x-representation>
}

View File

@ -16,6 +16,7 @@ func TestEvaluate(t *testing.T) {
{input: "test", expected: "test", extra: map[string]interface{}{}},
{input: "{{hex_encode(Item)}}", expected: "50494e47", extra: map[string]interface{}{"Item": "PING"}},
{input: "{{hex_encode(Item)}}\r\n", expected: "50494e47\r\n", extra: map[string]interface{}{"Item": "PING"}},
{input: "{{someTestData}}{{hex_encode('PING')}}", expected: "{{someTestData}}50494e47", extra: map[string]interface{}{}},
}
for _, item := range items {
value, err := Evaluate(item.input, item.extra)