Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: google/cel-java
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.3.1
Choose a base ref
...
head repository: google/cel-java
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.4.0
Choose a head ref

Commits on Dec 20, 2023

  1. Include optimizer and validator in publish script

    PiperOrigin-RevId: 592410792
    l46kok authored and copybara-github committed Dec 20, 2023
    Copy the full SHA
    95714d0 View commit details

Commits on Dec 21, 2023

  1. Copy the full SHA
    37799bc View commit details
  2. Merge pull request #199 from l46kok:fix-const-fold-with-list

    PiperOrigin-RevId: 592940954
    copybara-github committed Dec 21, 2023
    Copy the full SHA
    d76c341 View commit details

Commits on Jan 5, 2024

  1. Allow MutableAst to insert a new bind macro

    PiperOrigin-RevId: 595833681
    l46kok authored and copybara-github committed Jan 5, 2024
    Copy the full SHA
    7c4c5ee View commit details

Commits on Jan 10, 2024

  1. Fix standard function 'type' to accept a parameter type of TypeParamT…

    …ype instead of Dyn
    
    PiperOrigin-RevId: 597349307
    l46kok authored and copybara-github committed Jan 10, 2024
    Copy the full SHA
    870c594 View commit details
  2. Add an enum for Standard functions that are non-operators

    PiperOrigin-RevId: 597366073
    l46kok authored and copybara-github committed Jan 10, 2024
    Copy the full SHA
    8ff0918 View commit details

Commits on Jan 16, 2024

  1. Move standard macro definitions from CelMacro to CelStandardMacro

    PiperOrigin-RevId: 598901986
    l46kok authored and copybara-github committed Jan 16, 2024
    Copy the full SHA
    562ec94 View commit details

Commits on Jan 18, 2024

  1. Internal test change.

    PiperOrigin-RevId: 599559120
    CEL Dev Team authored and copybara-github committed Jan 18, 2024
    Copy the full SHA
    8dffc6c View commit details

Commits on Jan 19, 2024

  1. Implement Optimizer for Common Subexpression Elimination

    PiperOrigin-RevId: 599696579
    l46kok authored and copybara-github committed Jan 19, 2024
    Copy the full SHA
    790e8cf View commit details
  2. Perform CSE on comprehension loop step by mangling identifier names

    PiperOrigin-RevId: 599877299
    l46kok authored and copybara-github committed Jan 19, 2024
    Copy the full SHA
    5a7cbab View commit details
  3. Perform CSE on presence tests

    PiperOrigin-RevId: 599886305
    l46kok authored and copybara-github committed Jan 19, 2024
    Copy the full SHA
    cd11baf View commit details

Commits on Jan 20, 2024

  1. Allow configuration of MutableAst by making it instantiable

    PiperOrigin-RevId: 599966084
    l46kok authored and copybara-github committed Jan 20, 2024
    Copy the full SHA
    f9f370d View commit details
  2. Add ConstantFoldingOptions

    PiperOrigin-RevId: 599969298
    l46kok authored and copybara-github committed Jan 20, 2024
    Copy the full SHA
    7d28e89 View commit details

Commits on Jan 24, 2024

  1. Prevent string.format injection when interpreter exception is being b…

    …uilt
    
    PiperOrigin-RevId: 601159713
    l46kok authored and copybara-github committed Jan 24, 2024
    Copy the full SHA
    b7823ba View commit details

Commits on Jan 25, 2024

  1. Allow cel.bind to be lazily evaluated

    PiperOrigin-RevId: 601512156
    l46kok authored and copybara-github committed Jan 25, 2024
    Copy the full SHA
    90e9b2a View commit details

Commits on Jan 26, 2024

  1. Enable lazy comprehension eval by default

    PiperOrigin-RevId: 601600918
    l46kok authored and copybara-github committed Jan 26, 2024
    Copy the full SHA
    e69a4dd View commit details
  2. Add SafeStringFormatter. Address fuzzing issue around CelValidationEx…

    …ception.
    
    PiperOrigin-RevId: 601609078
    l46kok authored and copybara-github committed Jan 26, 2024
    Copy the full SHA
    948fd36 View commit details

Commits on Jan 30, 2024

  1. No public description

    PiperOrigin-RevId: 602549697
    ckennelly authored and copybara-github committed Jan 30, 2024
    Copy the full SHA
    c24b995 View commit details
  2. Remove enableComprehensionLazyEval flag

    PiperOrigin-RevId: 602764888
    l46kok authored and copybara-github committed Jan 30, 2024
    Copy the full SHA
    3a73459 View commit details
  3. No public description

    PiperOrigin-RevId: 602823902
    cpovirk authored and copybara-github committed Jan 30, 2024
    Copy the full SHA
    61b20df View commit details
  4. No public description

    PiperOrigin-RevId: 602831989
    cpovirk authored and copybara-github committed Jan 30, 2024
    Copy the full SHA
    9ae535c View commit details

Commits on Jan 31, 2024

  1. Add serialization capability for tagged AST extensions

    PiperOrigin-RevId: 603185360
    l46kok authored and copybara-github committed Jan 31, 2024
    Copy the full SHA
    aa0fb8c View commit details

Commits on Feb 5, 2024

  1. Move cel.bind memoization into ScopedResolver

    PiperOrigin-RevId: 604368929
    l46kok authored and copybara-github committed Feb 5, 2024
    Copy the full SHA
    6f55a67 View commit details

Commits on Feb 6, 2024

  1. Update to [Truth 1.4.0](https://github.com/google/truth/releases/tag/…

    …v1.4.0).
    
    This makes available the rest of the Truth APIs that were recently added in Google's monorepo.
    
    It may be worth also updating to the _following_ version of Truth after it's released, but the purpose of that release will mostly be to deprecate `Truth8`. So, if you just avoid using `Truth8` now (starting by approving any migration CLs that I send your way), then there will be little need for that upgrade. Or, more to the point: I don't expect to keep sending you weekly upgrade CLs after this one :)
    
    PiperOrigin-RevId: 604710681
    cpovirk authored and copybara-github committed Feb 6, 2024
    Copy the full SHA
    5957b55 View commit details
  2. Migrate usages of Truth8.assertThat to equivalent usages of `Truth.…

    …assertThat`.
    
    The `Truth8` methods will be deprecated (or hidden) in the future. Callers should move to `Truth`.
    
    Some (but not all) of the CLs in this batch require Truth [1.4.0](https://github.com/google/truth/releases/tag/v1.4.0). I submitted a CL earlier today to (I hope) perform that upgrade for your project.
    
    PiperOrigin-RevId: 604739382
    cpovirk authored and copybara-github committed Feb 6, 2024
    Copy the full SHA
    8f51c97 View commit details

Commits on Feb 8, 2024

  1. Add .toBuilder methods to constructed CEL environments

    PiperOrigin-RevId: 605383725
    l46kok authored and copybara-github committed Feb 8, 2024
    Copy the full SHA
    00d7726 View commit details

Commits on Feb 12, 2024

  1. Add capability to evaluate cel.block calls in the runtime

    PiperOrigin-RevId: 606316063
    l46kok authored and copybara-github committed Feb 12, 2024
    Copy the full SHA
    c916a11 View commit details

Commits on Feb 13, 2024

  1. Add height property to CelNavigableExpr

    PiperOrigin-RevId: 606657258
    l46kok authored and copybara-github committed Feb 13, 2024
    Copy the full SHA
    f98b582 View commit details
  2. No public description

    PiperOrigin-RevId: 606668350
    CEL Dev Team authored and copybara-github committed Feb 13, 2024
    Copy the full SHA
    4a723aa View commit details
  3. Properly set subtree height for navigable expr's children

    PiperOrigin-RevId: 606736573
    l46kok authored and copybara-github committed Feb 13, 2024
    Copy the full SHA
    bda6026 View commit details

Commits on Feb 16, 2024

  1. Augment CSE to produce optimized ASTs using cel.block

    PiperOrigin-RevId: 607486802
    l46kok authored and copybara-github committed Feb 16, 2024
    Copy the full SHA
    70ef6f9 View commit details
  2. Tag AST containing cel.block call

    PiperOrigin-RevId: 607499642
    l46kok authored and copybara-github committed Feb 16, 2024
    Copy the full SHA
    496ab08 View commit details
  3. Add mangled comprehension variables as identifier declaration to the …

    …environment
    
    PiperOrigin-RevId: 607507168
    l46kok authored and copybara-github committed Feb 16, 2024
    Copy the full SHA
    629f85b View commit details
  4. Assign unique indices for mangled comprehension identifiers with diff…

    …erent types
    
    PiperOrigin-RevId: 607513056
    l46kok authored and copybara-github committed Feb 16, 2024
    Copy the full SHA
    ad2c6b6 View commit details

Commits on Feb 21, 2024

  1. Mangle identifier name for comprehension result

    PiperOrigin-RevId: 609094679
    l46kok authored and copybara-github committed Feb 21, 2024
    Copy the full SHA
    90671c0 View commit details
  2. Mark type-checker implementation as internal

    PiperOrigin-RevId: 609103910
    l46kok authored and copybara-github committed Feb 21, 2024
    Copy the full SHA
    a740bbd View commit details
  3. Create an enum for functions used in CelOptionalLibrary

    PiperOrigin-RevId: 609107977
    l46kok authored and copybara-github committed Feb 21, 2024
    Copy the full SHA
    1e12305 View commit details
  4. Allow setting nesting limit for extractable subexpressions.

    PiperOrigin-RevId: 609114886
    l46kok authored and copybara-github committed Feb 21, 2024
    Copy the full SHA
    5ebf44e View commit details

Commits on Feb 22, 2024

  1. Compute navigable expr heights in a separate pass

    PiperOrigin-RevId: 609416184
    l46kok authored and copybara-github committed Feb 22, 2024
    Copy the full SHA
    4f8f455 View commit details

Commits on Feb 23, 2024

  1. Copy the full SHA
    c18f2a3 View commit details

Commits on Feb 25, 2024

  1. Copy the full SHA
    9935113 View commit details

Commits on Feb 27, 2024

  1. Merge pull request #251 from Snowflake-Labs:smparkes/publish

    PiperOrigin-RevId: 610795662
    copybara-github committed Feb 27, 2024
    Copy the full SHA
    a370d05 View commit details
  2. Create baseline tests for SubexpressionOptimizer

    PiperOrigin-RevId: 610833955
    l46kok authored and copybara-github committed Feb 27, 2024
    Copy the full SHA
    dc9083b View commit details
  3. Accept eliminable custom functions as an option

    PiperOrigin-RevId: 610849935
    l46kok authored and copybara-github committed Feb 27, 2024
    Copy the full SHA
    9ebad48 View commit details
  4. Prepare 0.3.1 release

    l46kok committed Feb 27, 2024
    Copy the full SHA
    cebfd9d View commit details

Commits on Feb 28, 2024

  1. Merge pull request #259 from google:release/0.3.1

    PiperOrigin-RevId: 610950733
    copybara-github committed Feb 28, 2024
    Copy the full SHA
    4f6682c View commit details
  2. Merge pull request #254 from modhanami:add-protobuf-tutorials-link

    PiperOrigin-RevId: 610951182
    copybara-github committed Feb 28, 2024
    Copy the full SHA
    09b934a View commit details
  3. Properly honor enableStandardEnvironment flag when constructing runtime

    Fixes #255
    
    PiperOrigin-RevId: 611167529
    l46kok authored and copybara-github committed Feb 28, 2024
    Copy the full SHA
    776f95a View commit details
  4. Fix replacing namespaced identifiers for accu_init

    PiperOrigin-RevId: 611217621
    l46kok authored and copybara-github committed Feb 28, 2024
    Copy the full SHA
    73d29cf View commit details
  5. Assert correctness on AST ran through SubexpressionOptimizer

    PiperOrigin-RevId: 611245287
    l46kok authored and copybara-github committed Feb 28, 2024
    Copy the full SHA
    b302caa View commit details
Showing with 44,719 additions and 934 deletions.
  1. +4 −2 .gitignore
  2. +2 −2 README.md
  3. +9 −9 WORKSPACE
  4. +3 −1 bundle/src/main/java/dev/cel/bundle/Cel.java
  5. +6 −1 bundle/src/main/java/dev/cel/bundle/CelFactory.java
  6. +31 −7 bundle/src/main/java/dev/cel/bundle/CelImpl.java
  7. +2 −0 bundle/src/test/java/dev/cel/bundle/BUILD.bazel
  8. +34 −0 bundle/src/test/java/dev/cel/bundle/CelImplTest.java
  9. +1 −0 checker/src/main/java/dev/cel/checker/BUILD.bazel
  10. +2 −0 checker/src/main/java/dev/cel/checker/CelChecker.java
  11. +89 −15 checker/src/main/java/dev/cel/checker/CelCheckerLegacyImpl.java
  12. +2 −2 checker/src/main/java/dev/cel/checker/Env.java
  13. +23 −12 checker/src/main/java/dev/cel/checker/ExprChecker.java
  14. +3 −3 checker/src/main/java/dev/cel/checker/ProtoTypeMaskTypeProvider.java
  15. +68 −26 checker/src/main/java/dev/cel/checker/Standard.java
  16. +1 −0 checker/src/test/java/dev/cel/checker/BUILD.bazel
  17. +106 −0 checker/src/test/java/dev/cel/checker/CelCheckerLegacyImplTest.java
  18. +45 −0 checker/src/test/java/dev/cel/checker/CelCompilerImplTest.java
  19. +6 −4 checker/src/test/java/dev/cel/checker/CelFunctionDeclTest.java
  20. +0 −1 checker/src/test/java/dev/cel/checker/CelIdentDeclTest.java
  21. +2 −0 checker/src/test/java/dev/cel/checker/ExprCheckerTest.java
  22. +15 −17 checker/src/test/java/dev/cel/checker/ProtoTypeMaskTypeProviderTest.java
  23. +0 −1 checker/src/test/java/dev/cel/checker/TypeInferencerTest.java
  24. +1 −2 checker/src/test/resources/abstractTypeParameterLess.baseline
  25. +1 −2 checker/src/test/resources/abstractTypeParameterized.baseline
  26. +1 −1 checker/src/test/resources/standardEnvDump.baseline
  27. +29 −2 checker/src/test/resources/types.baseline
  28. +1 −1 codelab/README.md
  29. +5 −0 common/internal/BUILD.bazel
  30. +1 −0 common/src/main/java/dev/cel/common/BUILD.bazel
  31. +6 −6 common/src/main/java/dev/cel/common/CelFunctionDecl.java
  32. +2 −1 common/src/main/java/dev/cel/common/CelIssue.java
  33. +14 −0 common/src/main/java/dev/cel/common/CelOptions.java
  34. +1 −1 common/src/main/java/dev/cel/common/CelOverloadDecl.java
  35. +75 −0 common/src/main/java/dev/cel/common/CelProtoAbstractSyntaxTree.java
  36. +111 −16 common/src/main/java/dev/cel/common/CelSource.java
  37. +20 −2 common/src/main/java/dev/cel/common/CelValidationException.java
  38. +1 −0 common/src/main/java/dev/cel/common/ast/BUILD.bazel
  39. +13 −0 common/src/main/java/dev/cel/common/ast/CelExpr.java
  40. +20 −3 common/src/main/java/dev/cel/common/ast/CelExprFactory.java
  41. +15 −4 common/src/main/java/dev/cel/common/ast/CelExprFormatter.java
  42. +51 −1 common/src/main/java/dev/cel/common/ast/CelExprIdGeneratorFactory.java
  43. +11 −0 common/src/main/java/dev/cel/common/internal/BUILD.bazel
  44. +9 −1 common/src/main/java/dev/cel/common/internal/Constants.java
  45. +48 −0 common/src/main/java/dev/cel/common/internal/SafeStringFormatter.java
  46. +2 −0 common/src/main/java/dev/cel/common/navigation/BUILD.bazel
  47. +31 −5 common/src/main/java/dev/cel/common/navigation/CelNavigableExpr.java
  48. +22 −18 common/src/main/java/dev/cel/common/navigation/CelNavigableExprVisitor.java
  49. +132 −0 common/src/main/java/dev/cel/common/navigation/ExprHeightCalculator.java
  50. +3 −3 common/src/main/java/dev/cel/common/testing/RepeatedTestProvider.java
  51. +2 −2 common/src/main/resources/testdata/proto2/test_all_types.proto
  52. +1 −1 common/src/main/resources/testdata/proto3/test_all_types.proto
  53. +1 −0 common/src/test/java/dev/cel/common/BUILD.bazel
  54. +0 −1 common/src/test/java/dev/cel/common/CelAbstractSyntaxTreeTest.java
  55. +10 −0 common/src/test/java/dev/cel/common/CelProtoAbstractSyntaxTreeTest.java
  56. +25 −1 common/src/test/java/dev/cel/common/CelSourceTest.java
  57. +42 −0 common/src/test/java/dev/cel/common/CelValidationExceptionTest.java
  58. +12 −0 common/src/test/java/dev/cel/common/ast/CelExprFactoryTest.java
  59. +40 −0 common/src/test/java/dev/cel/common/ast/CelExprFormatterTest.java
  60. +0 −1 common/src/test/java/dev/cel/common/ast/CelExprVisitorTest.java
  61. +0 −1 common/src/test/java/dev/cel/common/ast/CelReferenceTest.java
  62. +0 −1 common/src/test/java/dev/cel/common/internal/CombinedDescriptorPoolTest.java
  63. +0 −1 common/src/test/java/dev/cel/common/internal/DefaultInstanceMessageFactoryTest.java
  64. +0 −1 common/src/test/java/dev/cel/common/internal/DefaultMessageFactoryTest.java
  65. +0 −1 common/src/test/java/dev/cel/common/internal/ErrorsTest.java
  66. +0 −1 common/src/test/java/dev/cel/common/internal/ProtoAdapterTest.java
  67. +0 −1 common/src/test/java/dev/cel/common/navigation/CelNavigableAstTest.java
  68. +0 −1 common/src/test/java/dev/cel/common/navigation/CelNavigableExprTest.java
  69. +276 −2 common/src/test/java/dev/cel/common/navigation/CelNavigableExprVisitorTest.java
  70. +1 −1 common/src/test/java/dev/cel/common/types/EnumTypeTest.java
  71. +0 −1 common/src/test/java/dev/cel/common/types/ProtoMessageTypeProviderTest.java
  72. +0 −1 common/src/test/java/dev/cel/common/types/ProtoMessageTypeTest.java
  73. +0 −1 common/src/test/java/dev/cel/common/values/OptionalValueTest.java
  74. +0 −1 common/src/test/java/dev/cel/common/values/ProtoMessageValueTest.java
  75. +2 −0 compiler/src/main/java/dev/cel/compiler/CelCompiler.java
  76. +15 −0 compiler/src/main/java/dev/cel/compiler/CelCompilerImpl.java
  77. +32 −17 extensions/src/main/java/dev/cel/extensions/CelOptionalLibrary.java
  78. +2 −0 extensions/src/test/java/dev/cel/extensions/BUILD.bazel
  79. +145 −20 extensions/src/test/java/dev/cel/extensions/CelBindingsExtensionsTest.java
  80. +47 −1 extensions/src/test/java/dev/cel/extensions/CelOptionalLibraryTest.java
  81. +0 −2 optimizer/BUILD.bazel
  82. +5 −0 optimizer/optimizers/BUILD.bazel
  83. +10 −3 optimizer/src/main/java/dev/cel/optimizer/BUILD.bazel
  84. +31 −19 optimizer/src/main/java/dev/cel/optimizer/CelAstOptimizer.java
  85. +13 −3 optimizer/src/main/java/dev/cel/optimizer/CelOptimizerImpl.java
  86. +761 −132 optimizer/src/main/java/dev/cel/optimizer/MutableAst.java
  87. +166 −0 optimizer/src/main/java/dev/cel/optimizer/MutableExprVisitor.java
  88. +30 −0 optimizer/src/main/java/dev/cel/optimizer/optimizers/BUILD.bazel
  89. +122 −44 optimizer/src/main/java/dev/cel/optimizer/optimizers/ConstantFoldingOptimizer.java
  90. +788 −0 optimizer/src/main/java/dev/cel/optimizer/optimizers/SubexpressionOptimizer.java
  91. +3 −0 optimizer/src/test/java/dev/cel/optimizer/BUILD.bazel
  92. +9 −6 optimizer/src/test/java/dev/cel/optimizer/CelOptimizerImplTest.java
  93. +609 −33 optimizer/src/test/java/dev/cel/optimizer/MutableAstTest.java
  94. +16 −2 optimizer/src/test/java/dev/cel/optimizer/optimizers/BUILD.bazel
  95. +121 −11 optimizer/src/test/java/dev/cel/optimizer/optimizers/ConstantFoldingOptimizerTest.java
  96. +583 −0 optimizer/src/test/java/dev/cel/optimizer/optimizers/SubexpressionOptimizerBaselineTest.java
  97. +607 −0 optimizer/src/test/java/dev/cel/optimizer/optimizers/SubexpressionOptimizerTest.java
  98. +15 −0 optimizer/src/test/resources/BUILD.bazel
  99. +655 −0 optimizer/src/test/resources/constfold_before_subexpression_unparsed.baseline
  100. +17 −0 optimizer/src/test/resources/large_expressions_bind_cascaded.baseline
  101. +17 −0 optimizer/src/test/resources/large_expressions_block_common_subexpr.baseline
  102. +17 −0 optimizer/src/test/resources/large_expressions_block_recursion_depth_1.baseline
  103. +17 −0 optimizer/src/test/resources/large_expressions_block_recursion_depth_2.baseline
  104. +17 −0 optimizer/src/test/resources/large_expressions_block_recursion_depth_3.baseline
  105. +3,069 −0 optimizer/src/test/resources/subexpression_ast_block_common_subexpr_only.baseline
  106. +3,882 −0 optimizer/src/test/resources/subexpression_ast_block_recursion_depth_1.baseline
  107. +3,581 −0 optimizer/src/test/resources/subexpression_ast_block_recursion_depth_2.baseline
  108. +3,301 −0 optimizer/src/test/resources/subexpression_ast_block_recursion_depth_3.baseline
  109. +3,217 −0 optimizer/src/test/resources/subexpression_ast_block_recursion_depth_4.baseline
  110. +3,166 −0 optimizer/src/test/resources/subexpression_ast_block_recursion_depth_5.baseline
  111. +3,133 −0 optimizer/src/test/resources/subexpression_ast_block_recursion_depth_6.baseline
  112. +3,127 −0 optimizer/src/test/resources/subexpression_ast_block_recursion_depth_7.baseline
  113. +3,109 −0 optimizer/src/test/resources/subexpression_ast_block_recursion_depth_8.baseline
  114. +3,097 −0 optimizer/src/test/resources/subexpression_ast_block_recursion_depth_9.baseline
  115. +4,109 −0 optimizer/src/test/resources/subexpression_ast_cascaded_binds.baseline
  116. +655 −0 optimizer/src/test/resources/subexpression_unparsed.baseline
  117. +0 −239 parser/src/main/java/dev/cel/parser/CelMacro.java
  118. +2 −0 parser/src/main/java/dev/cel/parser/CelParser.java
  119. +42 −2 parser/src/main/java/dev/cel/parser/CelParserImpl.java
  120. +206 −7 parser/src/main/java/dev/cel/parser/CelStandardMacro.java
  121. +0 −1 parser/src/test/java/dev/cel/parser/CelMacroExprFactoryTest.java
  122. +0 −98 parser/src/test/java/dev/cel/parser/CelMacroTest.java
  123. +75 −28 parser/src/test/java/dev/cel/parser/CelParserImplTest.java
  124. +106 −0 parser/src/test/java/dev/cel/parser/CelStandardMacroTest.java
  125. +8 −8 parser/src/test/java/dev/cel/parser/CelUnparserImplTest.java
  126. +1 −1 parser/src/test/java/dev/cel/parser/OperatorTest.java
  127. +23 −0 publish/BUILD.bazel
  128. +1 −1 publish/cel_version.bzl
  129. +1 −1 publish/publish.sh
  130. +1 −0 runtime/src/main/java/dev/cel/runtime/BUILD.bazel
  131. +2 −0 runtime/src/main/java/dev/cel/runtime/CelRuntime.java
  132. +60 −10 runtime/src/main/java/dev/cel/runtime/CelRuntimeLegacyImpl.java
  133. +21 −19 runtime/src/main/java/dev/cel/runtime/DefaultDispatcher.java
  134. +116 −24 runtime/src/main/java/dev/cel/runtime/DefaultInterpreter.java
  135. +3 −2 runtime/src/main/java/dev/cel/runtime/InterpreterException.java
  136. +20 −3 runtime/src/main/java/dev/cel/runtime/RuntimeUnknownResolver.java
  137. +60 −0 runtime/src/test/java/dev/cel/runtime/CelRuntimeLegacyImplTest.java
  138. +155 −2 runtime/src/test/java/dev/cel/runtime/CelRuntimeTest.java
  139. +1 −1 runtime/src/test/java/dev/cel/runtime/CelVariableResolverTest.java
  140. +0 −1 runtime/src/test/java/dev/cel/runtime/UnknownContextTest.java
  141. +7 −0 runtime/src/test/resources/contextPropagation.baseline
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -2,10 +2,12 @@
bazel-bin
bazel-examples
bazel-genfiles
bazel-grpc-java
bazel-cel-java
bazel-out
bazel-testlogs

MODULE.bazel*

# IntelliJ IDEA
.idea
*.iml
@@ -27,4 +29,4 @@ bin
target

# Temporary output dir for artifacts
mvn-artifacts
mvn-artifacts
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -55,14 +55,14 @@ CEL-Java is available in Maven Central Repository. [Download the JARs here][8] o
<dependency>
<groupId>dev.cel</groupId>
<artifactId>cel</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</dependency>
```

**Gradle**

```gradle
implementation 'dev.cel:cel:0.3.0'
implementation 'dev.cel:cel:0.4.0'
```

Then run this example:
18 changes: 9 additions & 9 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -63,15 +63,15 @@ maven_install(
"com.google.auto.value:auto-value-annotations:1.10.4",
"com.google.code.findbugs:annotations:3.0.1",
"com.google.errorprone:error_prone_annotations:2.23.0",
"com.google.guava:guava:32.1.3-jre",
"com.google.guava:guava-testlib:32.1.3-jre",
"com.google.guava:guava:33.0.0-jre",
"com.google.guava:guava-testlib:33.0.0-jre",
"com.google.protobuf:protobuf-java:3.24.4",
"com.google.protobuf:protobuf-java-util:3.24.4",
"com.google.re2j:re2j:1.7",
"com.google.testparameterinjector:test-parameter-injector:1.14",
"com.google.truth.extensions:truth-java8-extension:1.1.5",
"com.google.truth.extensions:truth-proto-extension:1.1.5",
"com.google.truth:truth:1.1.5",
"com.google.testparameterinjector:test-parameter-injector:1.15",
"com.google.truth.extensions:truth-java8-extension:1.4.0",
"com.google.truth.extensions:truth-proto-extension:1.4.0",
"com.google.truth:truth:1.4.0",
"org.antlr:antlr4-runtime:" + ANTLR4_VERSION,
"org.jspecify:jspecify:0.2.0",
"org.threeten:threeten-extra:1.7.2",
@@ -138,10 +138,10 @@ http_archive(
# cel-spec api/expr canonical protos
http_archive(
name = "cel_spec",
sha256 = "6c2d9ec6dd5e2afbc41423dcaeca9fdd73edcd76554a897caee5b9a2b0e20491",
strip_prefix = "cel-spec-0.11.0",
sha256 = "3579c97b13548714f9059ef6f30c5264d439efef4b438e76e7180709efd93a6b",
strip_prefix = "cel-spec-0.14.0",
urls = [
"https://github.com/google/cel-spec/archive/refs/tags/v0.11.0.tar.gz",
"https://github.com/google/cel-spec/archive/refs/tags/v0.14.0.tar.gz",
],
)

4 changes: 3 additions & 1 deletion bundle/src/main/java/dev/cel/bundle/Cel.java
Original file line number Diff line number Diff line change
@@ -20,4 +20,6 @@

/** Cel interface for parse, type-check, and evaluation of CEL programs. */
@ThreadSafe
public interface Cel extends CelCompiler, CelRuntime {}
public interface Cel extends CelCompiler, CelRuntime {
CelBuilder toCelBuilder();
}
7 changes: 6 additions & 1 deletion bundle/src/main/java/dev/cel/bundle/CelFactory.java
Original file line number Diff line number Diff line change
@@ -17,8 +17,10 @@
import dev.cel.checker.CelCheckerLegacyImpl;
import dev.cel.common.CelOptions;
import dev.cel.compiler.CelCompiler;
import dev.cel.compiler.CelCompilerImpl;
import dev.cel.parser.CelParserImpl;
import dev.cel.runtime.CelRuntime;
import dev.cel.runtime.CelRuntimeLegacyImpl;

/** Helper class to configure the entire CEL stack in a common interface. */
public final class CelFactory {
@@ -33,7 +35,10 @@ private CelFactory() {}
* evaluation are enabled by default.
*/
public static CelBuilder standardCelBuilder() {
return CelImpl.newBuilder(CelParserImpl.newBuilder(), CelCheckerLegacyImpl.newBuilder())
return CelImpl.newBuilder(
CelCompilerImpl.newBuilder(
CelParserImpl.newBuilder(), CelCheckerLegacyImpl.newBuilder()),
CelRuntimeLegacyImpl.newBuilder())
.setOptions(CelOptions.current().build())
.setStandardEnvironmentEnabled(true);
}
38 changes: 31 additions & 7 deletions bundle/src/main/java/dev/cel/bundle/CelImpl.java
Original file line number Diff line number Diff line change
@@ -45,15 +45,13 @@
import dev.cel.common.values.CelValueProvider;
import dev.cel.compiler.CelCompiler;
import dev.cel.compiler.CelCompilerBuilder;
import dev.cel.compiler.CelCompilerImpl;
import dev.cel.compiler.CelCompilerLibrary;
import dev.cel.parser.CelMacro;
import dev.cel.parser.CelParserBuilder;
import dev.cel.parser.CelStandardMacro;
import dev.cel.runtime.CelEvaluationException;
import dev.cel.runtime.CelRuntime;
import dev.cel.runtime.CelRuntimeBuilder;
import dev.cel.runtime.CelRuntimeLegacyImpl;
import dev.cel.runtime.CelRuntimeLibrary;
import java.util.Arrays;
import java.util.function.Function;
@@ -102,6 +100,31 @@ public void accept(EnvVisitor envVisitor) {
}
}

@Override
public CelBuilder toCelBuilder() {
return newBuilder(toCompilerBuilder(), toRuntimeBuilder());
}

@Override
public CelParserBuilder toParserBuilder() {
return compiler.get().toParserBuilder();
}

@Override
public CelCheckerBuilder toCheckerBuilder() {
return compiler.get().toCheckerBuilder();
}

@Override
public CelCompilerBuilder toCompilerBuilder() {
return compiler.get().toCompilerBuilder();
}

@Override
public CelRuntimeBuilder toRuntimeBuilder() {
return runtime.get().toRuntimeBuilder();
}

/** Combines a prebuilt {@link CelCompiler} and {@link CelRuntime} into {@link CelImpl}. */
static CelImpl combine(CelCompiler compiler, CelRuntime runtime) {
return new CelImpl(Suppliers.memoize(() -> compiler), Suppliers.memoize(() -> runtime));
@@ -112,8 +135,9 @@ static CelImpl combine(CelCompiler compiler, CelRuntime runtime) {
*
* <p>By default, {@link CelOptions#DEFAULT} are enabled, as is the CEL standard environment.
*/
static CelBuilder newBuilder(CelParserBuilder parserBuilder, CelCheckerBuilder checkerBuilder) {
return new CelImpl.Builder(parserBuilder, checkerBuilder);
static CelBuilder newBuilder(
CelCompilerBuilder compilerBuilder, CelRuntimeBuilder celRuntimeBuilder) {
return new CelImpl.Builder(compilerBuilder, celRuntimeBuilder);
}

/** Builder class for CelImpl instances. */
@@ -122,9 +146,9 @@ public static final class Builder implements CelBuilder {
private final CelCompilerBuilder compilerBuilder;
private final CelRuntimeBuilder runtimeBuilder;

private Builder(CelParserBuilder parserBuilder, CelCheckerBuilder checkerBuilder) {
this.compilerBuilder = CelCompilerImpl.newBuilder(parserBuilder, checkerBuilder);
this.runtimeBuilder = CelRuntimeLegacyImpl.newBuilder();
private Builder(CelCompilerBuilder celCompilerBuilder, CelRuntimeBuilder celRuntimeBuilder) {
this.compilerBuilder = celCompilerBuilder;
this.runtimeBuilder = celRuntimeBuilder;
}

@Override
2 changes: 2 additions & 0 deletions bundle/src/test/java/dev/cel/bundle/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ java_library(
"//:auto_value",
"//:java_truth",
"//bundle:cel",
"//checker",
"//checker:checker_legacy_environment",
"//checker:proto_type_mask",
"//common",
@@ -31,6 +32,7 @@ java_library(
"//common/types:type_providers",
"//compiler",
"//compiler:compiler_builder",
"//parser",
"//parser:macro",
"//runtime",
"//runtime:unknown_attributes",
34 changes: 34 additions & 0 deletions bundle/src/test/java/dev/cel/bundle/CelImplTest.java
Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@
import com.google.testing.junit.testparameterinjector.TestParameter;
import com.google.testing.junit.testparameterinjector.TestParameterInjector;
import com.google.testing.junit.testparameterinjector.TestParameters;
import dev.cel.checker.CelCheckerLegacyImpl;
import dev.cel.checker.DescriptorTypeProvider;
import dev.cel.checker.ProtoTypeMask;
import dev.cel.checker.TypeProvider;
@@ -77,6 +78,8 @@
import dev.cel.common.types.StructTypeReference;
import dev.cel.compiler.CelCompiler;
import dev.cel.compiler.CelCompilerFactory;
import dev.cel.compiler.CelCompilerImpl;
import dev.cel.parser.CelParserImpl;
import dev.cel.parser.CelStandardMacro;
import dev.cel.runtime.CelAttribute;
import dev.cel.runtime.CelAttribute.Qualifier;
@@ -86,6 +89,7 @@
import dev.cel.runtime.CelRuntime.CelFunctionBinding;
import dev.cel.runtime.CelRuntime.Program;
import dev.cel.runtime.CelRuntimeFactory;
import dev.cel.runtime.CelRuntimeLegacyImpl;
import dev.cel.runtime.CelUnknownSet;
import dev.cel.runtime.CelVariableResolver;
import dev.cel.runtime.UnknownContext;
@@ -1045,6 +1049,15 @@ public void program_wrongTypeComprehensionThrows() throws Exception {
assertThat(e).hasMessageThat().contains("expected a list or a map");
}

@Test
public void program_stringFormatInjection_throwsEvaluationException() throws Exception {
Cel cel = standardCelBuilderWithMacros().build();
CelRuntime.Program program = cel.createProgram(cel.compile("{}['%2000222222s']").getAst());

CelEvaluationException e = assertThrows(CelEvaluationException.class, program::eval);
assertThat(e).hasMessageThat().contains("evaluation error");
}

@Test
public void program_emptyTypeProviderConfig() throws Exception {
Cel cel = standardCelBuilderWithMacros().build();
@@ -1803,6 +1816,27 @@ public boolean isAssignableFrom(CelType other) {
assertThat(result).isEqualTo("5");
}

@Test
public void toBuilder_isImmutable() {
CelBuilder celBuilder = CelFactory.standardCelBuilder();
CelImpl celImpl = (CelImpl) celBuilder.build();

CelImpl.Builder newCelBuilder = (CelImpl.Builder) celImpl.toCelBuilder();
CelParserImpl.Builder newParserBuilder = (CelParserImpl.Builder) celImpl.toParserBuilder();
CelCheckerLegacyImpl.Builder newCheckerBuilder =
(CelCheckerLegacyImpl.Builder) celImpl.toCheckerBuilder();
CelCompilerImpl.Builder newCompilerBuilder =
(CelCompilerImpl.Builder) celImpl.toCompilerBuilder();
CelRuntimeLegacyImpl.Builder newRuntimeBuilder =
(CelRuntimeLegacyImpl.Builder) celImpl.toRuntimeBuilder();

assertThat(newCelBuilder).isNotEqualTo(celBuilder);
assertThat(newParserBuilder).isNotEqualTo(celImpl.toParserBuilder());
assertThat(newCheckerBuilder).isNotEqualTo(celImpl.toCheckerBuilder());
assertThat(newCompilerBuilder).isNotEqualTo(celImpl.toCompilerBuilder());
assertThat(newRuntimeBuilder).isNotEqualTo(celImpl.toRuntimeBuilder());
}

private static TypeProvider aliasingProvider(ImmutableMap<String, Type> typeAliases) {
return new TypeProvider() {
@Override
1 change: 1 addition & 0 deletions checker/src/main/java/dev/cel/checker/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -73,6 +73,7 @@ java_library(
"//common",
"//common:compiler_common",
"//common:options",
"//common/annotations",
"//common/ast:expr_converter",
"//common/internal:env_visitor",
"//common/internal:errors",
2 changes: 2 additions & 0 deletions checker/src/main/java/dev/cel/checker/CelChecker.java
Original file line number Diff line number Diff line change
@@ -28,4 +28,6 @@ public interface CelChecker {
* <p>Check validates the type-agreement of the parsed {@code CelAbstractSyntaxTree}.
*/
CelValidationResult check(CelAbstractSyntaxTree ast);

CelCheckerBuilder toCheckerBuilder();
}
Loading