clarkmcc / cel-rust

Common Expression Language interpreter written in Rust
https://crates.io/crates/cel-interpreter
MIT License
362 stars 18 forks source link

Provide a mechanism for limiting the number of expressions #56

Open lucperkins opened 2 months ago

lucperkins commented 2 months ago

Providing massive expressions is a good way to bring down a server. It's pretty trivial to, for example, write a little script that creates an "or" chain 100,000 Booleans long. Because of this, it'd be good to provide support for optionally limiting the number of expressions evaluated by a Program.

lucperkins commented 2 months ago

I have some ideas on how to make this happen and am happy to do the work. Just wanted to see if I encounter any resistance before I submit a PR 😄

clarkmcc commented 2 months ago

No resistance from me! That's actually something I've been thinking about recently. I know other CEL implementations do something similar to this, i.e. cel-go.

lucperkins commented 2 months ago

@clarkmcc Oh, nice! I was not aware of that implementation, but great to know. Glad you're amenable to this 😄 I'll submit a PR pretty soon here.

clarkmcc commented 1 month ago

Documenting for posterity: this should probably be our guiding star for expression cost estimation/limiting.