diff --git a/WORKSPACE b/WORKSPACE index e2bc9580..86d3c57e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -119,7 +119,7 @@ go_repository( # CEL Spec deps go_repository( name = "com_google_cel_spec", - commit = "1bc3fb168317fa77d1227c52d0becbf2d358c023", + commit = "91f3cb1a7590f594a392b607ae9cab5e969b4cf3", importpath = "github.com/google/cel-spec", ) diff --git a/conformance/BUILD.bazel b/conformance/BUILD.bazel index dc78a024..e1fd8b9b 100644 --- a/conformance/BUILD.bazel +++ b/conformance/BUILD.bazel @@ -10,6 +10,7 @@ ALL_TESTS = [ "@com_google_cel_spec//tests/simple:testdata/lists.textproto", "@com_google_cel_spec//tests/simple:testdata/logic.textproto", "@com_google_cel_spec//tests/simple:testdata/macros.textproto", + "@com_google_cel_spec//tests/simple:testdata/math_ext.textproto", "@com_google_cel_spec//tests/simple:testdata/namespace.textproto", "@com_google_cel_spec//tests/simple:testdata/optionals.textproto", "@com_google_cel_spec//tests/simple:testdata/parse.textproto", @@ -17,6 +18,7 @@ ALL_TESTS = [ "@com_google_cel_spec//tests/simple:testdata/proto2.textproto", "@com_google_cel_spec//tests/simple:testdata/proto3.textproto", "@com_google_cel_spec//tests/simple:testdata/string.textproto", + "@com_google_cel_spec//tests/simple:testdata/string_ext.textproto", "@com_google_cel_spec//tests/simple:testdata/timestamps.textproto", "@com_google_cel_spec//tests/simple:testdata/unknowns.textproto", "@com_google_cel_spec//tests/simple:testdata/wrappers.textproto", @@ -37,6 +39,7 @@ sh_test( # Failing conformance tests. "--skip_test=fields/qualified_identifier_resolution/map_key_float,map_key_null,map_value_repeat_key", "--skip_test=fields/qualified_identifier_resolution/map_value_repeat_key_heterogeneous", + "--skip_test=macros/map/map_extract_keys", "--skip_test=timestamps/duration_converters/get_milliseconds", # Future enhancments. diff --git a/server/BUILD.bazel b/server/BUILD.bazel index a0ff2e4a..f501d5be 100644 --- a/server/BUILD.bazel +++ b/server/BUILD.bazel @@ -15,6 +15,7 @@ go_library( "//cel:go_default_library", "//common/types:go_default_library", "//common/types/ref:go_default_library", + "//ext:go_default_library", "@com_google_cel_spec//proto/test/v1/proto2:test_all_types_go_proto", "@com_google_cel_spec//proto/test/v1/proto3:test_all_types_go_proto", "@org_golang_google_genproto_googleapis_api//expr/conformance/v1alpha1:go_default_library", diff --git a/server/server.go b/server/server.go index b20b52d3..7a4bb02a 100644 --- a/server/server.go +++ b/server/server.go @@ -22,6 +22,7 @@ import ( "github.com/google/cel-go/cel" "github.com/google/cel-go/common/types" "github.com/google/cel-go/common/types/ref" + "github.com/google/cel-go/ext" test2pb "github.com/google/cel-spec/proto/test/v1/proto2/test_all_types" test3pb "github.com/google/cel-spec/proto/test/v1/proto3/test_all_types" @@ -41,7 +42,11 @@ func (s *ConformanceServer) Parse(ctx context.Context, in *confpb.ParseRequest) return nil, invalidArgument("No source code.") } // NOTE: syntax_version isn't currently used - var parseOptions []cel.EnvOption + parseOptions := []cel.EnvOption{ + ext.Math(), + ext.Protos(), + ext.Bindings(), + } if in.DisableMacros { parseOptions = append(parseOptions, cel.ClearMacros()) } @@ -68,7 +73,12 @@ func (s *ConformanceServer) Check(ctx context.Context, in *confpb.CheckRequest) return nil, invalidArgument("No source info.") } // Build the environment. - var checkOptions []cel.EnvOption = []cel.EnvOption{cel.StdLib()} + checkOptions := []cel.EnvOption{ + cel.StdLib(), + ext.Strings(), + ext.Math(), + ext.Encoders(), + } if in.NoStdEnv { checkOptions = []cel.EnvOption{} } @@ -255,6 +265,9 @@ var evalEnv *cel.Env func init() { evalEnv, _ = cel.NewEnv( + ext.Strings(), + ext.Math(), + ext.Encoders(), cel.Types(&test2pb.TestAllTypes{}, &test3pb.TestAllTypes{}), cel.EagerlyValidateDeclarations(true), cel.OptionalTypes())