Skip to content

Commit 1961a55

Browse files
author
jchadwick-buf
authored
Update CEL to v0.10.0, update intertwined dependencies (#67)
1 parent 9a1915f commit 1961a55

File tree

9 files changed

+134
-112
lines changed

9 files changed

+134
-112
lines changed

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
common --noenable_bzlmod
2+
13
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
24
build --cxxopt=-fsized-deallocation
35

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.4.0
1+
7.4.0

WORKSPACE

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ load("//bazel:deps.bzl", "protovalidate_cc_dependencies")
44

55
protovalidate_cc_dependencies()
66

7+
load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
8+
9+
rules_java_dependencies()
10+
11+
rules_java_toolchains()
12+
13+
load("@rules_python//python:repositories.bzl", "py_repositories")
14+
15+
py_repositories()
16+
717
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
818

919
protobuf_deps()

bazel/abseil.patch

Whitespace-only changes.

bazel/cel_cpp.patch

Lines changed: 0 additions & 92 deletions
This file was deleted.

bazel/deps.bzl

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,44 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
1616
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1717

1818
_dependencies = {
19-
# This is needed due to an unresolved issue with protobuf v27+.
19+
# cel-cpp needs a newer version of absl, otherwise it will fail to build in
20+
# a very strange manner.
21+
"com_google_absl": {
22+
"sha256": "f50e5ac311a81382da7fa75b97310e4b9006474f9560ac46f54a9967f07d4ae3",
23+
"strip_prefix": "abseil-cpp-20240722.0",
24+
"urls": [
25+
"https://github.com/abseil/abseil-cpp/archive/20240722.0.tar.gz",
26+
],
27+
},
28+
# These extra dependencies are needed by protobuf.
29+
# This may be alleviated somewhat by protobuf v30.
2030
# https://github.com/protocolbuffers/protobuf/issues/17200
21-
"rules_python": {
22-
"sha256": "0a8003b044294d7840ac7d9d73eef05d6ceb682d7516781a4ec62eeb34702578",
23-
"strip_prefix": "rules_python-0.24.0",
31+
"rules_cc": {
32+
"sha256": "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
33+
"strip_prefix": "rules_cc-0.0.17",
2434
"urls": [
25-
"https://github.com/bazelbuild/rules_python/releases/download/0.24.0/rules_python-0.24.0.tar.gz",
35+
"https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"
2636
],
2737
},
28-
"bazel_skylib": {
29-
"sha256": "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
38+
"rules_java": {
39+
"sha256": "c0ee60f8757f140c157fc2c7af703d819514de6e025ebf70386d38bdd85fce83",
3040
"urls": [
31-
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
32-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
41+
"https://github.com/bazelbuild/rules_java/releases/download/7.12.3/rules_java-7.12.3.tar.gz"
42+
],
43+
},
44+
"rules_python": {
45+
"sha256": "9c6e26911a79fbf510a8f06d8eedb40f412023cf7fa6d1461def27116bff022c",
46+
"strip_prefix": "rules_python-1.1.0",
47+
"urls": [
48+
"https://github.com/bazelbuild/rules_python/releases/download/1.1.0/rules_python-1.1.0.tar.gz",
3349
],
3450
},
3551
"com_google_protobuf": {
36-
"sha256": "e4ff2aeb767da6f4f52485c2e72468960ddfe5262483879ef6ad552e52757a77",
37-
"strip_prefix": "protobuf-27.2",
52+
"sha256": "63150aba23f7a90fd7d87bdf514e459dd5fe7023fdde01b56ac53335df64d4bd",
53+
"strip_prefix": "protobuf-29.2",
3854
"urls": [
39-
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v27.2.tar.gz",
40-
"https://github.com/protocolbuffers/protobuf/archive/v27.2.tar.gz",
55+
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v29.2.tar.gz",
56+
"https://github.com/protocolbuffers/protobuf/archive/v29.2.tar.gz",
4157
],
4258
},
4359
"rules_proto": {
@@ -55,12 +71,14 @@ _dependencies = {
5571
],
5672
},
5773
"com_google_cel_cpp": {
58-
"sha256": "d62b93fd07c6151749e83855157f3f2778d62c168318f9c40dfcfe1c336c496f",
59-
"strip_prefix": "cel-cpp-da0aba702f44a41ec6d2eb4bbf6a9f01efc2746d",
74+
"sha256": "dd06b708a9f4c3728e76037ec9fb14fc9f6d9c9980e5d5f3a1d047f3855a8b98",
75+
"strip_prefix": "cel-cpp-0.10.0",
6076
"urls": [
61-
"https://github.com/google/cel-cpp/archive/da0aba702f44a41ec6d2eb4bbf6a9f01efc2746d.tar.gz",
77+
"https://github.com/google/cel-cpp/archive/v0.10.0.tar.gz",
78+
],
79+
"patches": [
80+
"@com_github_bufbuild_protovalidate_cc//bazel:patches/cel_cpp/0001-Allow-message-field-access-using-index-operator.patch"
6281
],
63-
"patches": ["@com_github_bufbuild_protovalidate_cc//bazel:cel_cpp.patch"],
6482
"patch_args": ["-p1"],
6583
},
6684
# NOTE: Keep Version in sync with `/Makefile`.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
From b8881a537441bfc4995f38a1e8d80f9b22f5f095 Mon Sep 17 00:00:00 2001
2+
From: John Chadwick <[email protected]>
3+
Date: Fri, 24 Jan 2025 18:19:56 -0500
4+
Subject: [PATCH] Allow message field access using index operator
5+
6+
CEL doesn't yet have a standard way to access field names that conflict
7+
with identifiers. This temporary workaround enables the index operator
8+
to access fields from a message. It can be used as follows:
9+
10+
dyn(message)["field_name"]
11+
---
12+
eval/eval/container_access_step.cc | 35 ++++++++++++++++++++++++++++++
13+
1 file changed, 35 insertions(+)
14+
15+
diff --git a/eval/eval/container_access_step.cc b/eval/eval/container_access_step.cc
16+
index 67a783ad..ddb49375 100644
17+
--- a/eval/eval/container_access_step.cc
18+
+++ b/eval/eval/container_access_step.cc
19+
@@ -3,6 +3,7 @@
20+
#include <cstdint>
21+
#include <memory>
22+
#include <utility>
23+
+#include <csignal>
24+
25+
#include "absl/status/status.h"
26+
#include "absl/status/statusor.h"
27+
@@ -22,6 +23,8 @@
28+
#include "eval/eval/evaluator_core.h"
29+
#include "eval/eval/expression_step_base.h"
30+
#include "eval/internal/errors.h"
31+
+#include "eval/public/structs/legacy_type_adapter.h"
32+
+#include "eval/public/structs/legacy_type_info_apis.h"
33+
#include "internal/casts.h"
34+
#include "internal/number.h"
35+
#include "internal/status_macros.h"
36+
@@ -196,6 +199,34 @@ void LookupInList(const ListValue& cel_list, const Value& key,
37+
}
38+
}
39+
40+
+void LookupInMessage(const cel::StructValue& struct_value, const Value& key, ExecutionFrameBase& frame, Value& result) {
41+
+ if (!key.IsString()) {
42+
+ result = frame.value_manager().CreateErrorValue(
43+
+ absl::UnknownError(
44+
+ absl::StrCat(
45+
+ "Index error: expected string type, got '", ValueKindToString(key->kind()), "'")));
46+
+ return;
47+
+ }
48+
+ auto found = struct_value.HasFieldByName(key.GetString().ToString());
49+
+ if (!found.ok()) {
50+
+ result = frame.value_manager().CreateErrorValue(found.status());
51+
+ return;
52+
+ }
53+
+ if (!*found) {
54+
+ result = cel::NoSuchFieldError(key.AsString()->ToString());
55+
+ return;
56+
+ }
57+
+ auto status = struct_value.GetFieldByName(
58+
+ frame.value_manager(),
59+
+ key.GetString().ToString(),
60+
+ result,
61+
+ ProtoWrapperTypeOptions::kUnsetProtoDefault);
62+
+ if (!status.ok()) {
63+
+ result = frame.value_manager().CreateErrorValue(status);
64+
+ }
65+
+ return;
66+
+}
67+
+
68+
void LookupInContainer(const Value& container, const Value& key,
69+
ExecutionFrameBase& frame, Value& result) {
70+
// Select steps can be applied to either maps or messages
71+
@@ -208,6 +239,10 @@ void LookupInContainer(const Value& container, const Value& key,
72+
LookupInList(Cast<ListValue>(container), key, frame, result);
73+
return;
74+
}
75+
+ case ValueKind::kStruct: {
76+
+ LookupInMessage(*container.AsStruct(), key, frame, result);
77+
+ return;
78+
+ }
79+
default:
80+
result =
81+
frame.value_manager().CreateErrorValue(absl::InvalidArgumentError(
82+
--
83+
2.47.0
84+

buf/validate/internal/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ cc_library(
2222
":constraint_rules",
2323
"@com_google_cel_cpp//eval/public:activation",
2424
"@com_google_cel_cpp//eval/public:cel_expression",
25+
"@com_google_cel_cpp//eval/public:cel_value",
2526
"@com_google_cel_cpp//eval/public/structs:cel_proto_wrapper",
2627
"@com_google_cel_cpp//eval/public/containers:field_access",
2728
"@com_google_cel_cpp//eval/public/containers:field_backed_list_impl",
2829
"@com_google_cel_cpp//eval/public/containers:field_backed_map_impl",
2930
"@com_google_cel_cpp//parser",
30-
"@com_google_cel_cpp//base:value"
3131
],
3232
)
3333

buf/validate/internal/cel_constraint_rules.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "buf/validate/internal/cel_constraint_rules.h"
1616

17-
#include "base/values/struct_value.h"
17+
#include "common/values/struct_value.h"
1818
#include "eval/public/containers/field_access.h"
1919
#include "eval/public/containers/field_backed_list_impl.h"
2020
#include "eval/public/containers/field_backed_map_impl.h"

0 commit comments

Comments
 (0)