diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 297164e1a..71316927d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -36,7 +36,7 @@ jobs: setup_only: true token: ${{ secrets.BUF_TOKEN }} - name: Validate Gradle Wrapper - uses: gradle/actions/wrapper-validation@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0 + uses: gradle/actions/wrapper-validation@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0 - name: Lint run: make lint - name: Generate diff --git a/.github/workflows/conformance.yaml b/.github/workflows/conformance.yaml index 1995fd679..cb19af9b6 100644 --- a/.github/workflows/conformance.yaml +++ b/.github/workflows/conformance.yaml @@ -36,6 +36,6 @@ jobs: setup_only: true token: ${{ secrets.BUF_TOKEN }} - name: Validate Gradle Wrapper - uses: gradle/actions/wrapper-validation@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0 + uses: gradle/actions/wrapper-validation@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0 - name: Test conformance run: make conformance diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0890019fa..4f1ca5abd 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -33,7 +33,7 @@ jobs: setup_only: true token: ${{ secrets.BUF_TOKEN }} - name: Validate Gradle Wrapper - uses: gradle/actions/wrapper-validation@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0 + uses: gradle/actions/wrapper-validation@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0 - name: Configure GPG signing & publish env: GPG_KEY: ${{ secrets.GPG_KEY }} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b94b7d7b2..07d7c5e8f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,11 @@ [versions] assertj = "3.27.7" buf = "1.70.0" -cel = "0.13.0" -error-prone = "2.49.0" +cel = "0.13.1" +error-prone = "2.50.0" junit = "5.14.4" maven-publish = "0.36.0" -protobuf = "4.35.0" +protobuf = "4.35.1" re2j = "1.8" [libraries] @@ -14,7 +14,7 @@ buf = { module = "build.buf:buf", version.ref = "buf" } cel = { module = "dev.cel:cel", version.ref = "cel" } errorprone-annotations = { module = "com.google.errorprone:error_prone_annotations", version.ref = "error-prone" } errorprone-core = { module = "com.google.errorprone:error_prone_core", version.ref = "error-prone" } -grpc-protobuf = { module = "io.grpc:grpc-protobuf", version = "1.81.0" } +grpc-protobuf = { module = "io.grpc:grpc-protobuf", version = "1.82.0" } jspecify = { module ="org.jspecify:jspecify", version = "1.0.0" } junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" } maven-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "maven-publish" } diff --git a/src/main/java/build/buf/protovalidate/ValidateLibrary.java b/src/main/java/build/buf/protovalidate/ValidateLibrary.java index 6b032450c..9078e8356 100644 --- a/src/main/java/build/buf/protovalidate/ValidateLibrary.java +++ b/src/main/java/build/buf/protovalidate/ValidateLibrary.java @@ -18,15 +18,21 @@ import dev.cel.bundle.Cel; import dev.cel.bundle.CelFactory; import dev.cel.checker.CelCheckerBuilder; +import dev.cel.checker.CelCheckerLegacyImpl; import dev.cel.checker.CelStandardDeclarations; import dev.cel.common.CelOptions; import dev.cel.common.CelVarDecl; import dev.cel.common.types.SimpleType; +import dev.cel.compiler.CelCompiler; +import dev.cel.compiler.CelCompilerImpl; import dev.cel.compiler.CelCompilerLibrary; import dev.cel.extensions.CelExtensions; import dev.cel.parser.CelParserBuilder; +import dev.cel.parser.CelParserImpl; import dev.cel.parser.CelStandardMacro; +import dev.cel.runtime.CelRuntime; import dev.cel.runtime.CelRuntimeBuilder; +import dev.cel.runtime.CelRuntimeImpl; import dev.cel.runtime.CelRuntimeLibrary; import dev.cel.runtime.CelStandardFunctions; import java.util.concurrent.ConcurrentHashMap; @@ -38,7 +44,8 @@ */ final class ValidateLibrary implements CelCompilerLibrary, CelRuntimeLibrary { - private static final CelOptions CEL_OPTIONS = CelOptions.DEFAULT; + private static final CelOptions CEL_OPTIONS = + CelOptions.current().enableHeterogeneousNumericComparisons(true).build(); private final ConcurrentMap patternCache = new ConcurrentHashMap<>(); @@ -47,22 +54,32 @@ final class ValidateLibrary implements CelCompilerLibrary, CelRuntimeLibrary { static Cel newCel() { ValidateLibrary validateLibrary = new ValidateLibrary(); - return CelFactory.standardCelBuilder() - .setOptions(CEL_OPTIONS) - // Drop stdlib matches; CustomOverload provides a caching replacement. - // Ref: https://github.com/google/cel-java/issues/1038 - .setStandardEnvironmentEnabled(false) - .setStandardDeclarations( - CelStandardDeclarations.newBuilder() - .excludeFunctions(CelStandardDeclarations.StandardFunction.MATCHES) - .build()) - .setStandardFunctions( - CelStandardFunctions.newBuilder() - .excludeFunctions(CelStandardFunctions.StandardFunction.MATCHES) - .build()) - .addCompilerLibraries(validateLibrary, CelExtensions.strings()) - .addRuntimeLibraries(validateLibrary, CelExtensions.strings()) - .build(); + // Wired by hand instead of via plannerCelBuilder(): CelRuntimeImpl directs callers to subset + // stdlib via setStandardFunctions rather than setStandardEnvironmentEnabled, so the runtime + // does that while the checker uses setStandardEnvironmentEnabled(false). + CelCompiler compiler = + CelCompilerImpl.newBuilder( + CelParserImpl.newBuilder(), + CelCheckerLegacyImpl.newBuilder().setStandardEnvironmentEnabled(false)) + .setOptions(CEL_OPTIONS) + // Drop stdlib matches; CustomOverload provides a caching replacement. + // Ref: https://github.com/google/cel-java/issues/1038 + .setStandardDeclarations( + CelStandardDeclarations.newBuilder() + .excludeFunctions(CelStandardDeclarations.StandardFunction.MATCHES) + .build()) + .addLibraries(validateLibrary, CelExtensions.strings()) + .build(); + CelRuntime runtime = + CelRuntimeImpl.newBuilder() + .setOptions(CEL_OPTIONS) + .setStandardFunctions( + CelStandardFunctions.newBuilder() + .excludeFunctions(CelStandardFunctions.StandardFunction.MATCHES) + .build()) + .addLibraries(validateLibrary, CelExtensions.strings()) + .build(); + return CelFactory.combine(compiler, runtime); } @Override