camunda / feel-scala

FEEL parser and interpreter written in Scala
https://camunda.github.io/feel-scala/
Apache License 2.0
119 stars 46 forks source link

I can't interrupt an expression evaluation #823

Closed vicmosin closed 2 months ago

vicmosin commented 2 months ago

Is your feature request related to a problem? Please describe. The feel engine is currently stuck while executing long-running expressions because of the lack of "cooperation mode" (ref). It is not possible to interrupt the execution from outside the engine.

Related forum discussion: https://forum.camunda.io/t/feelengines-cooperation-mode-while-performing-longrunning-and-resource-consuming-operations/51049

We are using org.camunda.feel.FeelEngine instance to evaluate FEEL expressions and trying to find a proper way to “sandbox” this operation and give a dedicated timeout for each one, in case the user tries to execute a malicious expression. We’ve came across the following expression as an example of such harmful snippet which can bring the instance down:

count(for x in 1..(2 16) return {"power": 2 x}) > 0

Describe the solution you'd like The most classical solution is to repeatedly check whether the current thread was interrupted and throw an appropriate exception

saig0 commented 2 months ago

@vicmosin thank you for raising this. :+1: I adjusted the issue description based on the forum discussion.

I think this feature could be a small but useful improvement.