Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bundle/src/main/java/dev/cel/bundle/CelFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static CelBuilder standardCelBuilder() {
CelParserImpl.newBuilder(), CelCheckerLegacyImpl.newBuilder()),
CelRuntimeLegacyImpl.newBuilder())
.setOptions(CelOptions.current().build())
// CEL-Internal-2
.setStandardEnvironmentEnabled(true);
}

Expand Down
6 changes: 6 additions & 0 deletions bundle/src/test/java/dev/cel/bundle/CelImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ public void program_setTypeFactoryOnAnyPackedMessage_fieldSelectionSuccess() thr
CelAbstractSyntaxTree ast = celCompiler.compile("input.expression").getAst();
CelRuntime celRuntime =
CelRuntimeFactory.standardCelRuntimeBuilder()
// CEL-Internal-2
.setTypeFactory(
(typeName) ->
typeName.equals("google.type.Expr") ? com.google.type.Expr.newBuilder() : null)
Expand Down Expand Up @@ -401,6 +402,7 @@ public void program_setTypeFactoryOnAnyPackedMessage_messageConstructionSucceeds

CelRuntime celRuntime =
CelRuntimeFactory.standardCelRuntimeBuilder()
// CEL-Internal-2
.setTypeFactory(
(typeName) ->
typeName.equals("google.type.Expr") ? com.google.type.Expr.newBuilder() : null)
Expand Down Expand Up @@ -832,6 +834,7 @@ public void program_duplicateTypeDescriptor() throws Exception {
public void program_hermeticDescriptors_wellKnownProtobuf() throws Exception {
Cel cel =
standardCelBuilderWithMacros()
// CEL-Internal-2
.addMessageTypes(Timestamp.getDescriptor())
.setContainer(CelContainer.ofName("google"))
.setResultType(SimpleType.TIMESTAMP)
Expand Down Expand Up @@ -914,6 +917,7 @@ public void program_deepTypeResolutionEnabledForRuntime_success() throws Excepti
CelRuntimeFactory.standardCelRuntimeBuilder()
.addFileTypes(CheckedExpr.getDescriptor().getFile())
.setOptions(CelOptions.current().resolveTypeDependencies(true).build())
// CEL-Internal-2
.build();
CelRuntime.Program program = celRuntime.createProgram(ast);

Expand Down Expand Up @@ -942,6 +946,7 @@ public void program_deepTypeResolutionDisabledForRuntime_fails() throws Exceptio
CelRuntimeFactory.standardCelRuntimeBuilder()
.addFileTypes(CheckedExpr.getDescriptor().getFile())
.setOptions(CelOptions.current().resolveTypeDependencies(false).build())
// CEL-Internal-2
.build();
CelRuntime.Program program = celRuntime.createProgram(ast);

Expand Down Expand Up @@ -2154,6 +2159,7 @@ public void program_fdsContainsWktDependency_descriptorInstancesMatch() throws E
Cel cel =
standardCelBuilderWithMacros()
.addMessageTypes(descriptors)
// CEL-Internal-2
.setOptions(CelOptions.current().enableTimestampEpoch(true).build())
.setContainer(CelContainer.ofName("cel.expr.conformance.proto3"))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ public void getExt_onAnyPackedExtensionField_success() throws Exception {
TestAllTypesExtensions.registerAllExtensions(extensionRegistry);
Cel cel =
CelFactory.standardCelBuilder()
// CEL-Internal-2
.addCompilerLibraries(CelExtensions.protos())
.addFileTypes(TestAllTypesExtensions.getDescriptor())
.setExtensionRegistry(extensionRegistry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.ByteStreams;
// CEL-Internal-5
// CEL-Internal-3
import freemarker.template.Configuration;
import freemarker.template.DefaultObjectWrapperBuilder;
import freemarker.template.Template;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public final class CelRuntimeFactory {
public static CelRuntimeBuilder standardCelRuntimeBuilder() {
return CelRuntimeLegacyImpl.newBuilder()
.setOptions(CelOptions.current().build())
// CEL-Internal-2
.setStandardEnvironmentEnabled(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import dev.cel.common.internal.DefaultDescriptorPool;
import dev.cel.common.internal.DefaultMessageFactory;
import dev.cel.common.internal.DynamicProto;
// CEL-Internal-3
// CEL-Internal-1
import dev.cel.common.internal.ProtoMessageFactory;
import dev.cel.common.types.CelTypes;
import dev.cel.common.values.CelValueProvider;
Expand Down Expand Up @@ -97,6 +97,7 @@ public CelRuntimeBuilder toRuntimeBuilder() {
CelRuntimeBuilder builder =
new Builder()
.setOptions(options)
// CEL-Internal-2
.setStandardEnvironmentEnabled(standardEnvironmentEnabled)
.setExtensionRegistry(extensionRegistry)
.addFileTypes(fileDescriptors)
Expand Down Expand Up @@ -366,7 +367,8 @@ private ImmutableSet<CelFunctionBinding> newStandardFunctionBindings(
break;
default:
if (!options.enableHeterogeneousNumericComparisons()) {
return !CelStandardFunctions.isHeterogeneousComparison(standardOverload);
return !CelStandardFunctions.isHeterogeneousComparison(
standardOverload);
}
break;
}
Expand Down
6 changes: 6 additions & 0 deletions runtime/src/test/java/dev/cel/runtime/CelRuntimeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public void newWellKnownTypeMessage_withDifferentDescriptorInstance() throws Exc
.build();
CelRuntime celRuntime =
CelRuntimeFactory.standardCelRuntimeBuilder()
// CEL-Internal-2
.addFileTypes(
FileDescriptorSet.newBuilder()
.addFile(
Expand All @@ -192,6 +193,7 @@ public void newWellKnownTypeMessage_inDynamicMessage_withSetTypeFactory() throws
.build();
CelRuntime celRuntime =
CelRuntimeFactory.standardCelRuntimeBuilder()
// CEL-Internal-2
.setTypeFactory(
(typeName) ->
typeName.equals("google.protobuf.BoolValue")
Expand All @@ -218,6 +220,8 @@ public void newWellKnownTypeMessage_inAnyMessage_withDifferentDescriptorInstance
CelCompilerFactory.standardCelCompilerBuilder().addFileTypes(fds).build();
CelRuntime celRuntime =
CelRuntimeFactory.standardCelRuntimeBuilder()
// CEL-Internal-2
.addFileTypes(fds)
.build();

CelAbstractSyntaxTree ast =
Expand All @@ -241,6 +245,8 @@ public void newWellKnownTypeMessage_inAnyMessage_withSetTypeFactory() throws Exc
CelCompilerFactory.standardCelCompilerBuilder().addFileTypes(fds).build();
CelRuntime celRuntime =
CelRuntimeFactory.standardCelRuntimeBuilder()
// CEL-Internal-2
.addFileTypes(fds)
.setTypeFactory(
(typeName) ->
typeName.equals("google.protobuf.Any")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import dev.cel.common.internal.CelDescriptorPool;
import dev.cel.common.internal.DefaultDescriptorPool;
import dev.cel.common.internal.DefaultMessageFactory;
// CEL-Internal-3
// CEL-Internal-1
import dev.cel.common.internal.ProtoMessageFactory;
import dev.cel.common.internal.WellKnownProto;
import dev.cel.expr.conformance.proto2.TestAllTypes;
Expand Down
Loading