Skip to content

New conformance fixes #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 22, 2025
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
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ archive_override(
]
)

bazel_dep(name = "protovalidate", version = "0.10.4", repo_name = "com_github_bufbuild_protovalidate")
bazel_dep(name = "protovalidate", version = "0.10.6", repo_name = "com_github_bufbuild_protovalidate")
6 changes: 3 additions & 3 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

608 changes: 0 additions & 608 deletions buf/validate/conformance/expected_failures.yaml

Large diffs are not rendered by default.

20 changes: 1 addition & 19 deletions buf/validate/internal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ cc_library(
"@com_github_bufbuild_protovalidate//proto/protovalidate/buf/validate:validate_proto_cc",
"@com_google_cel_cpp//eval/public:activation",
"@com_google_cel_cpp//eval/public:builtin_func_registrar",
"@com_google_cel_cpp//eval/public:string_extension_func_registrar",
"@com_google_cel_cpp//eval/public:cel_expr_builder_factory",
"@com_google_cel_cpp//eval/public:cel_expression",
"@com_google_cel_cpp//eval/public/containers:field_access",
Expand All @@ -132,7 +133,6 @@ cc_library(
srcs = ["extra_func.cc"],
hdrs = ["extra_func.h"],
deps = [
":string_format",
"//buf/validate/internal/lib:ipv4",
"//buf/validate/internal/lib:ipv6",
"//buf/validate/internal/lib:uri",
Expand All @@ -144,24 +144,6 @@ cc_library(
],
)

cc_library(
name = "string_format",
srcs = ["string_format.cc"],
hdrs = ["string_format.h"],
deps = [
"@com_google_cel_cpp//eval/public:cel_value",
],
)

cc_test(
name = "string_format_test",
srcs = ["string_format_test.cc"],
deps = [
":string_format",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "extra_func_test",
srcs = ["extra_func_test.cc"],
Expand Down
5 changes: 5 additions & 0 deletions buf/validate/internal/constraints.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "eval/public/containers/field_access.h"
#include "eval/public/containers/field_backed_list_impl.h"
#include "eval/public/containers/field_backed_map_impl.h"
#include "eval/public/string_extension_func_registrar.h"
#include "eval/public/structs/cel_proto_wrapper.h"
#include "google/protobuf/dynamic_message.h"
#include "google/protobuf/util/message_differencer.h"
Expand Down Expand Up @@ -105,6 +106,10 @@ NewConstraintBuilder(google::protobuf::Arena* arena) {
if (!register_status.ok()) {
return register_status;
}
register_status = cel::runtime::RegisterStringExtensionFunctions(builder->GetRegistry());
if (!register_status.ok()) {
return register_status;
}
register_status = RegisterExtraFuncs(*builder->GetRegistry(), arena);
if (!register_status.ok()) {
return register_status;
Expand Down
16 changes: 1 addition & 15 deletions buf/validate/internal/extra_func.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "buf/validate/internal/lib/ipv4.h"
#include "buf/validate/internal/lib/ipv6.h"
#include "buf/validate/internal/lib/uri.h"
#include "buf/validate/internal/string_format.h"
#include "eval/public/cel_function_adapter.h"
#include "eval/public/cel_value.h"
#include "eval/public/containers/container_backed_map_impl.h"
Expand Down Expand Up @@ -230,7 +229,7 @@ bool IsHostAndPort(const std::string_view str, const bool portRequired) {

const auto splitIdx = str.rfind(':');
if (str.front() == '[') {
const auto end = str.find(']');
const auto end = str.rfind(']');
const auto afterEnd = end + 1;
if (afterEnd == str.size()) { // no port
const auto host = str.substr(1, end - 1);
Expand Down Expand Up @@ -339,19 +338,6 @@ cel::CelValue isUriRef(google::protobuf::Arena* arena, cel::CelValue::StringHold

absl::Status RegisterExtraFuncs(
google::api::expr::runtime::CelFunctionRegistry& registry, google::protobuf::Arena* regArena) {
auto* formatter = google::protobuf::Arena::Create<StringFormat>(regArena);
auto status = cel::FunctionAdapter<cel::CelValue, cel::CelValue::StringHolder, cel::CelValue>::
CreateAndRegister(
"format",
true,
[formatter](
google::protobuf::Arena* arena,
cel::CelValue::StringHolder format,
cel::CelValue arg) -> cel::CelValue { return formatter->format(arena, format, arg); },
&registry);
if (!status.ok()) {
return status;
}
auto isNanStatus = cel::FunctionAdapter<cel::CelValue, cel::CelValue>::CreateAndRegister(
"isNan", true, &isNan, &registry);
if (!isNanStatus.ok()) {
Expand Down
1 change: 1 addition & 0 deletions buf/validate/internal/extra_func_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ TEST(ExtraFuncTest, TestIpPrefix) {
// Additional Tests for IsHostAndPort()
EXPECT_FALSE(buf::validate::internal::IsHostAndPort("example.com:00", false));
EXPECT_FALSE(buf::validate::internal::IsHostAndPort("example.com:080", false));
EXPECT_TRUE(buf::validate::internal::IsHostAndPort("[::0%00]]", false));
}
Loading
Loading