Skip to content

Support ProgramOptions to limit and disable comprehension macros #1050

@sergiitk

Description

@sergiitk

Feature request checklist

  • There are no issues that match the desired change
  • The change is large enough it can't be addressed with a simple Pull Request
  • If this is a bug, please file a Bug Report.

Change
To make CEL environment setup consistent across CEL implementations, I propose to add a runtime option equivalent to CEL-cpp InterpreterOptions.enable_comprehension to CEL-Go and CEL-Java (corresponding ticket google/cel-java#484).

In Java, runtime CEL comprehensions can be limited using comprehensionMaxIterations(int value) runtime option. Setting value to 0 disables the comprehension macros. If the limit is reached, program evaluation throws CelEvaluationException with CelErrorCode.ITERATION_BUDGET_EXCEEDED.

There is no option equivalent to comprehensionMaxIterations() in CEL-Go . Similar to google/cel-java#484, the new Go option equivalent to cpp's enable_comprehension could use comprehensionMaxIterations(0) under-the-hood.

Example

// Actual option names up to the implementer.
prg, err := env.Program(ast, EvalOptions(OptDisableComprehension))

// Equivalent:
prg, err := env.Program(ast, ComprehensionMaxIterations(0))

Related
Internal ref: go/grpc-cel-integration

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions