1414
1515package dev .cel .verifier .tools ;
1616
17+ import static com .google .common .collect .ImmutableList .toImmutableList ;
18+
19+ import com .google .common .collect .ImmutableList ;
1720import com .google .common .collect .ImmutableMap ;
21+ import com .google .protobuf .Descriptors .Descriptor ;
1822import dev .cel .bundle .Cel ;
1923import dev .cel .bundle .CelBuilder ;
2024import dev .cel .bundle .CelFactory ;
2125import dev .cel .common .CelAbstractSyntaxTree ;
2226import dev .cel .common .CelOptions ;
27+ import dev .cel .common .internal .DefaultDescriptorPool ;
28+ import dev .cel .common .internal .WellKnownProto ;
2329import dev .cel .common .types .CelType ;
2430import dev .cel .compiler .CelCompiler ;
2531import dev .cel .compiler .CelCompilerBuilder ;
4248/** Core decoupled engine that executes formal verification operations. */
4349final class CelVerifierToolCore {
4450
51+ private static final ImmutableList <Descriptor > WELL_KNOWN_DESCRIPTORS =
52+ ImmutableList .of (
53+ WellKnownProto .DURATION ,
54+ WellKnownProto .JSON_LIST_VALUE ,
55+ WellKnownProto .JSON_STRUCT_VALUE ,
56+ WellKnownProto .JSON_VALUE ,
57+ WellKnownProto .TIMESTAMP ,
58+ WellKnownProto .FLOAT_VALUE ,
59+ WellKnownProto .INT32_VALUE ,
60+ WellKnownProto .INT64_VALUE ,
61+ WellKnownProto .STRING_VALUE ,
62+ WellKnownProto .BOOL_VALUE ,
63+ WellKnownProto .BYTES_VALUE ,
64+ WellKnownProto .DOUBLE_VALUE ,
65+ WellKnownProto .UINT32_VALUE ,
66+ WellKnownProto .UINT64_VALUE )
67+ .stream ()
68+ .map (DefaultDescriptorPool ::getWellKnownProtoDescriptor )
69+ .collect (toImmutableList ());
70+
4571 private CelVerifierToolCore () {}
4672
4773 /** Checks if a single CEL expression is satisfiable. */
@@ -108,6 +134,7 @@ static CelCompiler buildCompiler(Map<String, CelType> variables) {
108134 CelCompilerBuilder builder =
109135 CelCompilerFactory .standardCelCompilerBuilder ()
110136 .setStandardMacros (CelStandardMacro .STANDARD_MACROS )
137+ .addMessageTypes (WELL_KNOWN_DESCRIPTORS )
111138 .addLibraries (
112139 CelExtensions .bindings (),
113140 CelExtensions .comprehensions (),
@@ -129,6 +156,7 @@ static Cel buildCel(Map<String, CelType> variables) {
129156 CelBuilder celBuilder =
130157 CelFactory .plannerCelBuilder ()
131158 .setStandardMacros (CelStandardMacro .STANDARD_MACROS )
159+ .addMessageTypes (WELL_KNOWN_DESCRIPTORS )
132160 .addCompilerLibraries (
133161 CelExtensions .optional (),
134162 CelExtensions .bindings (),
0 commit comments