├── .bazelversion ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── BUILD.bazel ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── MODULE.bazel ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── WORKSPACE ├── WORKSPACE.bzlmod ├── cel ├── BUILD.bazel ├── cel.go ├── cel_example_test.go ├── cel_test.go ├── decls.go ├── decls_test.go ├── env.go ├── env_test.go ├── folding.go ├── folding_test.go ├── inlining.go ├── inlining_test.go ├── io.go ├── io_test.go ├── library.go ├── macro.go ├── macro_test.go ├── optimizer.go ├── optimizer_test.go ├── options.go ├── program.go ├── prompt.go ├── prompt_test.go ├── templates │ ├── BUILD.bazel │ └── authoring.tmpl ├── testdata │ ├── BUILD.bazel │ ├── basic.prompt.txt │ ├── macros.prompt.txt │ ├── mutant.proto │ ├── standard_env.prompt.txt │ ├── team.fds │ └── team.proto ├── validator.go └── validator_test.go ├── checker ├── BUILD.bazel ├── checker.go ├── checker_test.go ├── cost.go ├── cost_test.go ├── decls │ ├── BUILD.bazel │ └── decls.go ├── env.go ├── env_test.go ├── errors.go ├── format.go ├── format_test.go ├── mapping.go ├── options.go ├── printer.go ├── scopes.go └── types.go ├── cloudbuild.yaml ├── codelab ├── README.md ├── codelab.go ├── go.mod ├── go.sum └── solution │ └── codelab.go ├── common ├── BUILD.bazel ├── ast │ ├── BUILD.bazel │ ├── ast.go │ ├── ast_test.go │ ├── conversion.go │ ├── conversion_test.go │ ├── expr.go │ ├── expr_test.go │ ├── factory.go │ ├── navigable.go │ └── navigable_test.go ├── containers │ ├── BUILD.bazel │ ├── container.go │ └── container_test.go ├── cost.go ├── debug │ ├── BUILD.bazel │ └── debug.go ├── decls │ ├── BUILD.bazel │ ├── decls.go │ └── decls_test.go ├── doc.go ├── doc_test.go ├── env │ ├── BUILD.bazel │ ├── env.go │ ├── env_test.go │ └── testdata │ │ ├── context_env.yaml │ │ ├── extended_env.yaml │ │ └── subset_env.yaml ├── error.go ├── errors.go ├── errors_test.go ├── functions │ ├── BUILD.bazel │ └── functions.go ├── location.go ├── operators │ ├── BUILD.bazel │ └── operators.go ├── overloads │ ├── BUILD.bazel │ └── overloads.go ├── runes │ ├── BUILD.bazel │ ├── buffer.go │ └── buffer_test.go ├── source.go ├── source_test.go ├── stdlib │ ├── BUILD.bazel │ └── standard.go └── types │ ├── BUILD.bazel │ ├── any_value.go │ ├── bool.go │ ├── bool_test.go │ ├── bytes.go │ ├── bytes_test.go │ ├── compare.go │ ├── doc.go │ ├── double.go │ ├── double_test.go │ ├── duration.go │ ├── duration_test.go │ ├── err.go │ ├── format.go │ ├── int.go │ ├── int_test.go │ ├── iterator.go │ ├── json_list_test.go │ ├── json_struct_test.go │ ├── json_value.go │ ├── list.go │ ├── list_test.go │ ├── map.go │ ├── map_test.go │ ├── null.go │ ├── null_test.go │ ├── object.go │ ├── object_test.go │ ├── optional.go │ ├── optional_test.go │ ├── overflow.go │ ├── pb │ ├── BUILD.bazel │ ├── checked.go │ ├── enum.go │ ├── equal.go │ ├── equal_test.go │ ├── file.go │ ├── file_test.go │ ├── pb.go │ ├── pb_test.go │ ├── type.go │ └── type_test.go │ ├── provider.go │ ├── provider_test.go │ ├── ref │ ├── BUILD.bazel │ ├── provider.go │ └── reference.go │ ├── string.go │ ├── string_test.go │ ├── timestamp.go │ ├── timestamp_test.go │ ├── traits │ ├── BUILD.bazel │ ├── comparer.go │ ├── container.go │ ├── field_tester.go │ ├── indexer.go │ ├── iterator.go │ ├── lister.go │ ├── mapper.go │ ├── matcher.go │ ├── math.go │ ├── receiver.go │ ├── sizer.go │ ├── traits.go │ └── zeroer.go │ ├── type_test.go │ ├── types.go │ ├── types_test.go │ ├── uint.go │ ├── uint_test.go │ ├── unknown.go │ ├── unknown_test.go │ ├── util.go │ └── util_test.go ├── conformance ├── BUILD.bazel ├── conformance_test.bzl ├── conformance_test.go ├── conformance_test.sh ├── go.mod └── go.sum ├── examples ├── README.md ├── custom_global_function_test.go ├── custom_instance_function_test.go └── simple_test.go ├── ext ├── BUILD.bazel ├── README.md ├── bindings.go ├── bindings_test.go ├── comprehensions.go ├── comprehensions_test.go ├── encoders.go ├── encoders_test.go ├── extension_option_factory.go ├── extension_option_factory_test.go ├── formatting.go ├── formatting_test.go ├── formatting_v2.go ├── formatting_v2_test.go ├── guards.go ├── lists.go ├── lists_test.go ├── math.go ├── math_test.go ├── native.go ├── native_test.go ├── protos.go ├── protos_test.go ├── sets.go ├── sets_test.go ├── strings.go └── strings_test.go ├── go.mod ├── go.sum ├── interpreter ├── BUILD.bazel ├── activation.go ├── activation_test.go ├── attribute_patterns.go ├── attribute_patterns_test.go ├── attributes.go ├── attributes_test.go ├── decorators.go ├── dispatcher.go ├── evalstate.go ├── functions │ ├── BUILD.bazel │ └── functions.go ├── interpretable.go ├── interpreter.go ├── interpreter_test.go ├── optimizations.go ├── planner.go ├── prune.go ├── prune_test.go ├── runtimecost.go └── runtimecost_test.go ├── parser ├── BUILD.bazel ├── errors.go ├── gen │ ├── BUILD.bazel │ ├── CEL.g4 │ ├── CEL.interp │ ├── CEL.tokens │ ├── CELLexer.interp │ ├── CELLexer.tokens │ ├── cel_base_listener.go │ ├── cel_base_visitor.go │ ├── cel_lexer.go │ ├── cel_listener.go │ ├── cel_parser.go │ ├── cel_visitor.go │ ├── doc.go │ └── generate.sh ├── helper.go ├── helper_test.go ├── input.go ├── macro.go ├── macro_test.go ├── options.go ├── parser.go ├── parser_test.go ├── unescape.go ├── unescape_test.go ├── unparser.go └── unparser_test.go ├── policy ├── BUILD.bazel ├── README.md ├── compiler.go ├── compiler_test.go ├── composer.go ├── config.go ├── config_test.go ├── conformance.go ├── go.mod ├── go.sum ├── helper_test.go ├── parser.go ├── parser_test.go ├── source.go ├── test │ ├── BUILD.bazel │ ├── cel_test_runner.go │ └── k8s_cel_test_runner.go ├── test_tag_handler_k8s.go └── testdata │ ├── context_pb │ ├── config.yaml │ ├── policy.yaml │ └── tests.yaml │ ├── errors │ ├── config.yaml │ └── policy.yaml │ ├── errors_unreachable │ ├── config.yaml │ └── policy.yaml │ ├── k8s │ ├── config.yaml │ ├── policy.yaml │ └── tests.yaml │ ├── limits │ ├── config.yaml │ ├── policy.yaml │ └── tests.yaml │ ├── nested_incompatible_outputs │ ├── config.yaml │ └── policy.yaml │ ├── nested_rule │ ├── config.yaml │ ├── policy.yaml │ └── tests.yaml │ ├── nested_rule2 │ ├── config.yaml │ ├── policy.yaml │ └── tests.yaml │ ├── nested_rule3 │ ├── config.yaml │ ├── policy.yaml │ └── tests.yaml │ ├── nested_rule4 │ ├── config.yaml │ ├── policy.yaml │ └── tests.yaml │ ├── nested_rule5 │ ├── config.yaml │ ├── policy.yaml │ └── tests.yaml │ ├── nested_rule6 │ ├── config.yaml │ ├── policy.yaml │ └── tests.yaml │ ├── nested_rule7 │ ├── config.yaml │ ├── policy.yaml │ └── tests.yaml │ ├── pb │ ├── config.yaml │ ├── policy.yaml │ └── tests.yaml │ ├── required_labels │ ├── config.yaml │ ├── policy.yaml │ └── tests.yaml │ ├── restricted_destinations │ ├── base_config.yaml │ ├── config.yaml │ ├── partial_config.yaml │ ├── policy.yaml │ └── tests.yaml │ └── unnest │ ├── config.yaml │ ├── policy.yaml │ └── tests.yaml ├── repl ├── BUILD.bazel ├── appengine │ ├── .gcloudignore │ ├── README.md │ ├── app.yaml │ ├── app │ │ ├── BUILD.bazel │ │ ├── api.go │ │ ├── api_test.go │ │ └── app.go │ ├── go.mod │ ├── go.sum │ ├── main │ │ ├── BUILD.bazel │ │ └── main.go │ ├── tsconfig.json │ └── web │ │ ├── .editorconfig │ │ ├── .eslintrc.json │ │ ├── .gitignore │ │ ├── README.md │ │ ├── angular.json │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── src │ │ ├── app │ │ │ ├── app-component.html │ │ │ ├── app-component.scss │ │ │ ├── app-component.spec.ts │ │ │ ├── app-component.ts │ │ │ ├── app-module.ts │ │ │ ├── reference_panel │ │ │ │ ├── reference-panel-component.html │ │ │ │ ├── reference-panel-component.scss │ │ │ │ ├── reference-panel-component.spec.ts │ │ │ │ ├── reference-panel-component.ts │ │ │ │ └── reference-panel-module.ts │ │ │ ├── repl_console │ │ │ │ ├── repl-console-component.html │ │ │ │ ├── repl-console-component.scss │ │ │ │ ├── repl-console-component.spec.ts │ │ │ │ ├── repl-console-component.ts │ │ │ │ ├── repl-console-module.ts │ │ │ │ ├── repl-result-detail-component.html │ │ │ │ ├── repl-result-detail-component.scss │ │ │ │ ├── repl-result-detail-component.spec.ts │ │ │ │ └── repl-result-detail-component.ts │ │ │ └── shared │ │ │ │ ├── repl-api-service.spec.ts │ │ │ │ ├── repl-api-service.ts │ │ │ │ ├── repl-example-service.spec.ts │ │ │ │ ├── repl-example-service.ts │ │ │ │ ├── shared-module.ts │ │ │ │ ├── trim-pipe.spec.ts │ │ │ │ └── trim-pipe.ts │ │ ├── assets │ │ │ ├── .gitkeep │ │ │ └── github.svg │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── main.ts │ │ ├── styles.scss │ │ └── theme.scss │ │ ├── tsconfig.app.json │ │ ├── tsconfig.json │ │ └── tsconfig.spec.json ├── commands.go ├── commands_test.go ├── evaluator.go ├── evaluator_test.go ├── go.mod ├── go.sum ├── main │ ├── BUILD.bazel │ ├── README.md │ └── main.go ├── parser │ ├── BUILD.bazel │ ├── Commands.g4 │ ├── Commands.interp │ ├── Commands.tokens │ ├── CommandsLexer.interp │ ├── CommandsLexer.tokens │ ├── commands_base_listener.go │ ├── commands_base_visitor.go │ ├── commands_lexer.go │ ├── commands_listener.go │ ├── commands_parser.go │ ├── commands_test.go │ ├── commands_visitor.go │ └── regen.sh ├── testdata │ └── attribute_context_fds.textproto ├── typefmt.go └── typefmt_test.go ├── scripts └── verify-vendor.sh ├── test ├── BUILD.bazel ├── bench │ ├── BUILD.bazel │ ├── bench.go │ └── bench_test.go ├── cel_go_test.bzl ├── compare.go ├── expr.go ├── proto2pb │ ├── BUILD.bazel │ ├── test_all_types.pb.go │ ├── test_all_types.proto │ ├── test_extensions.pb.go │ └── test_extensions.proto ├── proto3pb │ ├── BUILD.bazel │ ├── test_all_types.pb.go │ ├── test_all_types.proto │ ├── test_import.pb.go │ └── test_import.proto └── suite.go ├── tools ├── BUILD.bazel ├── celtest │ ├── BUILD.bazel │ ├── test_runner.go │ ├── test_runner_test.go │ └── testdata │ │ ├── config.yaml │ │ ├── custom_policy.celpolicy │ │ ├── custom_policy_tests.yaml │ │ ├── raw_expr.cel │ │ └── raw_expr_tests.yaml ├── compiler │ ├── BUILD.bazel │ ├── compiler.go │ ├── compiler_test.go │ └── testdata │ │ └── config.yaml ├── go.mod └── go.sum └── vendor ├── cel.dev └── expr │ ├── .bazelversion │ ├── .gitattributes │ ├── .gitignore │ ├── BUILD.bazel │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── GOVERNANCE.md │ ├── LICENSE │ ├── MAINTAINERS.md │ ├── MODULE.bazel │ ├── README.md │ ├── WORKSPACE │ ├── WORKSPACE.bzlmod │ ├── checked.pb.go │ ├── cloudbuild.yaml │ ├── eval.pb.go │ ├── explain.pb.go │ ├── regen_go_proto.sh │ ├── regen_go_proto_canonical_protos.sh │ ├── syntax.pb.go │ └── value.pb.go ├── github.com ├── antlr4-go │ └── antlr │ │ └── v4 │ │ ├── .gitignore │ │ ├── LICENSE │ │ ├── README.md │ │ ├── antlrdoc.go │ │ ├── atn.go │ │ ├── atn_config.go │ │ ├── atn_config_set.go │ │ ├── atn_deserialization_options.go │ │ ├── atn_deserializer.go │ │ ├── atn_simulator.go │ │ ├── atn_state.go │ │ ├── atn_type.go │ │ ├── char_stream.go │ │ ├── common_token_factory.go │ │ ├── common_token_stream.go │ │ ├── comparators.go │ │ ├── configuration.go │ │ ├── dfa.go │ │ ├── dfa_serializer.go │ │ ├── dfa_state.go │ │ ├── diagnostic_error_listener.go │ │ ├── error_listener.go │ │ ├── error_strategy.go │ │ ├── errors.go │ │ ├── file_stream.go │ │ ├── input_stream.go │ │ ├── int_stream.go │ │ ├── interval_set.go │ │ ├── jcollect.go │ │ ├── lexer.go │ │ ├── lexer_action.go │ │ ├── lexer_action_executor.go │ │ ├── lexer_atn_simulator.go │ │ ├── ll1_analyzer.go │ │ ├── nostatistics.go │ │ ├── parser.go │ │ ├── parser_atn_simulator.go │ │ ├── parser_rule_context.go │ │ ├── prediction_context.go │ │ ├── prediction_context_cache.go │ │ ├── prediction_mode.go │ │ ├── recognizer.go │ │ ├── rule_context.go │ │ ├── semantic_context.go │ │ ├── statistics.go │ │ ├── stats_data.go │ │ ├── token.go │ │ ├── token_source.go │ │ ├── token_stream.go │ │ ├── tokenstream_rewriter.go │ │ ├── trace_listener.go │ │ ├── transition.go │ │ ├── tree.go │ │ ├── trees.go │ │ └── utils.go └── stoewer │ └── go-strcase │ ├── .gitignore │ ├── .golangci.yml │ ├── LICENSE │ ├── README.md │ ├── camel.go │ ├── doc.go │ ├── helper.go │ ├── kebab.go │ └── snake.go ├── golang.org └── x │ ├── exp │ ├── LICENSE │ ├── PATENTS │ ├── constraints │ │ └── constraints.go │ └── slices │ │ ├── slices.go │ │ ├── sort.go │ │ ├── zsortfunc.go │ │ └── zsortordered.go │ └── text │ ├── LICENSE │ ├── PATENTS │ ├── feature │ └── plural │ │ ├── common.go │ │ ├── message.go │ │ ├── plural.go │ │ └── tables.go │ ├── internal │ ├── catmsg │ │ ├── catmsg.go │ │ ├── codec.go │ │ └── varint.go │ ├── format │ │ ├── format.go │ │ └── parser.go │ ├── internal.go │ ├── language │ │ ├── common.go │ │ ├── compact.go │ │ ├── compact │ │ │ ├── compact.go │ │ │ ├── language.go │ │ │ ├── parents.go │ │ │ ├── tables.go │ │ │ └── tags.go │ │ ├── compose.go │ │ ├── coverage.go │ │ ├── language.go │ │ ├── lookup.go │ │ ├── match.go │ │ ├── parse.go │ │ ├── tables.go │ │ └── tags.go │ ├── match.go │ ├── number │ │ ├── common.go │ │ ├── decimal.go │ │ ├── format.go │ │ ├── number.go │ │ ├── pattern.go │ │ ├── roundingmode_string.go │ │ └── tables.go │ ├── stringset │ │ └── set.go │ └── tag │ │ └── tag.go │ ├── language │ ├── coverage.go │ ├── doc.go │ ├── language.go │ ├── match.go │ ├── parse.go │ ├── tables.go │ └── tags.go │ └── message │ ├── catalog.go │ ├── catalog │ ├── catalog.go │ ├── dict.go │ ├── go19.go │ └── gopre19.go │ ├── doc.go │ ├── format.go │ ├── message.go │ └── print.go ├── google.golang.org ├── genproto │ └── googleapis │ │ ├── api │ │ ├── LICENSE │ │ └── expr │ │ │ └── v1alpha1 │ │ │ ├── checked.pb.go │ │ │ ├── eval.pb.go │ │ │ ├── explain.pb.go │ │ │ ├── syntax.pb.go │ │ │ └── value.pb.go │ │ └── rpc │ │ ├── LICENSE │ │ └── status │ │ └── status.pb.go └── protobuf │ ├── LICENSE │ ├── PATENTS │ ├── encoding │ ├── protojson │ │ ├── decode.go │ │ ├── doc.go │ │ ├── encode.go │ │ └── well_known_types.go │ ├── prototext │ │ ├── decode.go │ │ ├── doc.go │ │ └── encode.go │ └── protowire │ │ └── wire.go │ ├── internal │ ├── descfmt │ │ └── stringer.go │ ├── descopts │ │ └── options.go │ ├── detrand │ │ └── rand.go │ ├── editiondefaults │ │ ├── defaults.go │ │ └── editions_defaults.binpb │ ├── editionssupport │ │ └── editions.go │ ├── encoding │ │ ├── defval │ │ │ └── default.go │ │ ├── json │ │ │ ├── decode.go │ │ │ ├── decode_number.go │ │ │ ├── decode_string.go │ │ │ ├── decode_token.go │ │ │ └── encode.go │ │ ├── messageset │ │ │ └── messageset.go │ │ ├── tag │ │ │ └── tag.go │ │ └── text │ │ │ ├── decode.go │ │ │ ├── decode_number.go │ │ │ ├── decode_string.go │ │ │ ├── decode_token.go │ │ │ ├── doc.go │ │ │ └── encode.go │ ├── errors │ │ ├── errors.go │ │ ├── is_go112.go │ │ └── is_go113.go │ ├── filedesc │ │ ├── build.go │ │ ├── desc.go │ │ ├── desc_init.go │ │ ├── desc_lazy.go │ │ ├── desc_list.go │ │ ├── desc_list_gen.go │ │ ├── editions.go │ │ └── placeholder.go │ ├── filetype │ │ └── build.go │ ├── flags │ │ ├── flags.go │ │ ├── proto_legacy_disable.go │ │ └── proto_legacy_enable.go │ ├── genid │ │ ├── any_gen.go │ │ ├── api_gen.go │ │ ├── descriptor_gen.go │ │ ├── doc.go │ │ ├── duration_gen.go │ │ ├── empty_gen.go │ │ ├── field_mask_gen.go │ │ ├── go_features_gen.go │ │ ├── goname.go │ │ ├── map_entry.go │ │ ├── source_context_gen.go │ │ ├── struct_gen.go │ │ ├── timestamp_gen.go │ │ ├── type_gen.go │ │ ├── wrappers.go │ │ └── wrappers_gen.go │ ├── impl │ │ ├── api_export.go │ │ ├── checkinit.go │ │ ├── codec_extension.go │ │ ├── codec_field.go │ │ ├── codec_gen.go │ │ ├── codec_map.go │ │ ├── codec_map_go111.go │ │ ├── codec_map_go112.go │ │ ├── codec_message.go │ │ ├── codec_messageset.go │ │ ├── codec_reflect.go │ │ ├── codec_tables.go │ │ ├── codec_unsafe.go │ │ ├── convert.go │ │ ├── convert_list.go │ │ ├── convert_map.go │ │ ├── decode.go │ │ ├── encode.go │ │ ├── enum.go │ │ ├── extension.go │ │ ├── legacy_enum.go │ │ ├── legacy_export.go │ │ ├── legacy_extension.go │ │ ├── legacy_file.go │ │ ├── legacy_message.go │ │ ├── merge.go │ │ ├── merge_gen.go │ │ ├── message.go │ │ ├── message_reflect.go │ │ ├── message_reflect_field.go │ │ ├── message_reflect_gen.go │ │ ├── pointer_reflect.go │ │ ├── pointer_unsafe.go │ │ ├── validate.go │ │ └── weak.go │ ├── order │ │ ├── order.go │ │ └── range.go │ ├── pragma │ │ └── pragma.go │ ├── set │ │ └── ints.go │ ├── strs │ │ ├── strings.go │ │ ├── strings_pure.go │ │ ├── strings_unsafe_go120.go │ │ └── strings_unsafe_go121.go │ └── version │ │ └── version.go │ ├── proto │ ├── checkinit.go │ ├── decode.go │ ├── decode_gen.go │ ├── doc.go │ ├── encode.go │ ├── encode_gen.go │ ├── equal.go │ ├── extension.go │ ├── merge.go │ ├── messageset.go │ ├── proto.go │ ├── proto_methods.go │ ├── proto_reflect.go │ ├── reset.go │ ├── size.go │ ├── size_gen.go │ └── wrappers.go │ ├── reflect │ ├── protodesc │ │ ├── desc.go │ │ ├── desc_init.go │ │ ├── desc_resolve.go │ │ ├── desc_validate.go │ │ ├── editions.go │ │ └── proto.go │ ├── protoreflect │ │ ├── methods.go │ │ ├── proto.go │ │ ├── source.go │ │ ├── source_gen.go │ │ ├── type.go │ │ ├── value.go │ │ ├── value_equal.go │ │ ├── value_pure.go │ │ ├── value_union.go │ │ ├── value_unsafe_go120.go │ │ └── value_unsafe_go121.go │ └── protoregistry │ │ └── registry.go │ ├── runtime │ ├── protoiface │ │ ├── legacy.go │ │ └── methods.go │ └── protoimpl │ │ ├── impl.go │ │ └── version.go │ └── types │ ├── descriptorpb │ └── descriptor.pb.go │ ├── dynamicpb │ ├── dynamic.go │ └── types.go │ ├── gofeaturespb │ └── go_features.pb.go │ └── known │ ├── anypb │ └── any.pb.go │ ├── durationpb │ └── duration.pb.go │ ├── emptypb │ └── empty.pb.go │ ├── structpb │ └── struct.pb.go │ ├── timestamppb │ └── timestamp.pb.go │ └── wrapperspb │ └── wrappers.pb.go ├── gopkg.in └── yaml.v3 │ ├── LICENSE │ ├── NOTICE │ ├── README.md │ ├── apic.go │ ├── decode.go │ ├── emitterc.go │ ├── encode.go │ ├── parserc.go │ ├── readerc.go │ ├── resolve.go │ ├── scannerc.go │ ├── sorter.go │ ├── writerc.go │ ├── yaml.go │ ├── yamlh.go │ └── yamlprivateh.go └── modules.txt /.bazelversion: -------------------------------------------------------------------------------- 1 | 7.3.2 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Check which components this affects: 12 | 13 | - [ ] parser 14 | - [ ] checker 15 | - [ ] interpreter 16 | 17 | Sample expression and input that reproduces the issue: 18 | ```cel 19 | // sample expression string 20 | ``` 21 | 22 | Test setup: 23 | ```go 24 | // test case in go 25 | ``` 26 | 27 | **Expected behavior** 28 | A clear and concise description of what you expected to happen. 29 | 30 | **Additional context** 31 | Add any other context about the problem here. 32 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Feature request checklist** 8 | 9 | - [ ] There are no issues that match the desired change 10 | - [ ] The change is large enough it can't be addressed with a simple Pull Request 11 | - [ ] If this is a bug, please file a [Bug Report](./ISSUE_TEMPLATE). 12 | 13 | **Change** 14 | Summary of the proposed change and some details about what problem 15 | it helps solve. 16 | 17 | **Example** 18 | Replace this text with an example indicating the desired functionality. 19 | 20 | **Alternatives considered** 21 | Briefly list alternative designs, or an example of the functionality to be replaced. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .vscode 4 | bazel-bin 5 | bazel-cel-go 6 | bazel-genfiles 7 | bazel-out 8 | bazel-testlogs 9 | proto/checked.pb.go 10 | proto/syntax.pb.go 11 | *~ 12 | MODULE.bazel.lock 13 | .ijwb/ -------------------------------------------------------------------------------- /BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | licenses(["notice"]) # Apache 2.0 4 | 5 | exports_files(["LICENSE"]) 6 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | ## Version 0.1.1 (adapted from 0.3b-angular) 3 | 4 | As contributors and maintainers of the Common Expression Language 5 | (CEL) project, we pledge to respect everyone who contributes by 6 | posting issues, updating documentation, submitting pull requests, 7 | providing feedback in comments, and any other activities. 8 | 9 | Communication through any of CEL's channels (GitHub, Gitter, IRC, 10 | mailing lists, Google+, Twitter, etc.) must be constructive and never 11 | resort to personal attacks, trolling, public or private harassment, 12 | insults, or other unprofessional conduct. 13 | 14 | We promise to extend courtesy and respect to everyone involved in this 15 | project regardless of gender, gender identity, sexual orientation, 16 | disability, age, race, ethnicity, religion, or level of experience. We 17 | expect anyone contributing to the project to do the same. 18 | 19 | If any member of the community violates this code of conduct, the 20 | maintainers of the CEL project may take action, removing issues, 21 | comments, and PRs or blocking accounts as deemed appropriate. 22 | 23 | If you are subject to or witness unacceptable behavior, or have any 24 | other concerns, please email us at 25 | [cel-conduct@google.com](mailto:cel-conduct@google.com). 26 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Pull Requests Guidelines 2 | 3 | See [CONTRIBUTING.md](./CONTRIBUTING.md) for more details about when to create 4 | a GitHub [Pull Request][1] and when other kinds of contributions or 5 | consultation might be more desirable. 6 | 7 | When creating a new pull request, please fork the repo and work within a 8 | development branch. 9 | 10 | ## Commit Messages 11 | 12 | * Most changes should be accompanied by tests. 13 | * Commit messages should explain _why_ the changes were made. 14 | ``` 15 | Summary of change in 50 characters or less 16 | 17 | Background on why the change is being made with additional detail on 18 | consequences of the changes elsewhere in the code or to the general 19 | functionality of the library. Multiple paragraphs may be used, but 20 | please keep lines to 72 characters or less. 21 | ``` 22 | 23 | ## Reviews 24 | 25 | * Perform a self-review. 26 | * Make sure the Travis CI build passes. 27 | * Assign a reviewer once both the above have been completed. 28 | 29 | ## Merging 30 | 31 | * If a CEL maintaner approves the change, it may be merged by the author if 32 | they have write access. Otherwise, the change will be merged by a maintainer. 33 | * Multiple commits should be squashed before merging. 34 | * Please append the line `closes #: description` in the merge message, 35 | if applicable. 36 | 37 | [1]: https://help.github.com/articles/about-pull-requests -------------------------------------------------------------------------------- /WORKSPACE.bzlmod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/cel-go/c55aebf5346fcd5c06dc56fd6b817015fc008ee4/WORKSPACE.bzlmod -------------------------------------------------------------------------------- /cel/cel.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package cel defines the top-level interface for the Common Expression Language (CEL). 16 | // 17 | // CEL is a non-Turing complete expression language designed to parse, check, and evaluate 18 | // expressions against user-defined environments. 19 | package cel 20 | -------------------------------------------------------------------------------- /cel/templates/BUILD.bazel: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) # Apache 2.0 2 | 3 | filegroup( 4 | name = "templates", 5 | srcs = glob(["*.tmpl"]), 6 | visibility = ["//visibility:public"], 7 | ) -------------------------------------------------------------------------------- /cel/templates/authoring.tmpl: -------------------------------------------------------------------------------- 1 | {{define "variable"}}{{.Name}} is a {{.Type}} 2 | {{- end -}} 3 | 4 | {{define "macro" -}} 5 | {{.Name}} macro{{if .Description}} - {{range split .Description}}{{.}} {{end}} 6 | {{end}} 7 | {{range .Children}}{{range split .Description}} {{.}} 8 | {{end}} 9 | {{- end -}} 10 | {{- end -}} 11 | 12 | {{define "overload" -}} 13 | {{if .Children}}{{range .Children}}{{range split .Description}} {{.}} 14 | {{end}} 15 | {{- end -}} 16 | {{else}} {{.Signature}} 17 | {{end}} 18 | {{- end -}} 19 | 20 | {{define "function" -}} 21 | {{.Name}}{{if .Description}} - {{range split .Description}}{{.}} {{end}} 22 | {{end}} 23 | {{range .Children}}{{template "overload" .}}{{end}} 24 | {{- end -}} 25 | 26 | {{.Persona}} 27 | 28 | {{.FormatRules}} 29 | 30 | {{if or .Variables .Macros .Functions -}} 31 | Only use the following variables, macros, and functions in expressions. 32 | {{if .Variables}} 33 | Variables: 34 | 35 | {{range .Variables}}* {{template "variable" .}} 36 | {{end -}} 37 | 38 | {{end -}} 39 | {{if .Macros}} 40 | Macros: 41 | 42 | {{range .Macros}}* {{template "macro" .}} 43 | {{end -}} 44 | 45 | {{end -}} 46 | {{if .Functions}} 47 | Functions: 48 | 49 | {{range .Functions}}* {{template "function" .}} 50 | {{end -}} 51 | 52 | {{end -}} 53 | {{- end -}} 54 | {{.GeneralUsage}} 55 | 56 | {{.UserPrompt}} 57 | -------------------------------------------------------------------------------- /cel/testdata/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package( 2 | default_visibility = ["//visibility:public"], 3 | licenses = ["notice"], # Apache 2.0 4 | ) 5 | 6 | genrule( 7 | name = "gen_test_fds", 8 | srcs = [ 9 | "team.proto", 10 | "mutant.proto", 11 | ], 12 | outs = [ 13 | "team.fds", 14 | ], 15 | cmd = ("$(location @com_google_protobuf//:protoc) " + 16 | "--descriptor_set_out=$@ $(SRCS)"), 17 | tools = ["@com_google_protobuf//:protoc"], 18 | ) 19 | 20 | filegroup( 21 | name = "prompts", 22 | srcs = glob(["*.prompt.txt"]), 23 | ) -------------------------------------------------------------------------------- /cel/testdata/mutant.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package cel.testdata; 4 | 5 | message Mutant { 6 | string name = 1; 7 | int32 level = 2; 8 | string super_power = 3; 9 | } 10 | -------------------------------------------------------------------------------- /cel/testdata/team.fds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/cel-go/c55aebf5346fcd5c06dc56fd6b817015fc008ee4/cel/testdata/team.fds -------------------------------------------------------------------------------- /cel/testdata/team.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package cel.testdata; 4 | 5 | import "cel/testdata/mutant.proto"; 6 | 7 | message Team { 8 | string name = 1; 9 | repeated Mutant members = 2; 10 | } 11 | -------------------------------------------------------------------------------- /checker/decls/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | licenses = ["notice"], # Apache 2.0 6 | ) 7 | 8 | go_library( 9 | name = "go_default_library", 10 | srcs = [ 11 | "decls.go", 12 | ], 13 | importpath = "github.com/google/cel-go/checker/decls", 14 | deps = [ 15 | "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", 16 | "@org_golang_google_protobuf//types/known/emptypb:go_default_library", 17 | "@org_golang_google_protobuf//types/known/structpb:go_default_library", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /checker/mapping.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package checker 16 | 17 | import ( 18 | "github.com/google/cel-go/common/types" 19 | ) 20 | 21 | type mapping struct { 22 | mapping map[string]*types.Type 23 | } 24 | 25 | func newMapping() *mapping { 26 | return &mapping{ 27 | mapping: make(map[string]*types.Type), 28 | } 29 | } 30 | 31 | func (m *mapping) add(from, to *types.Type) { 32 | m.mapping[FormatCELType(from)] = to 33 | } 34 | 35 | func (m *mapping) find(from *types.Type) (*types.Type, bool) { 36 | if r, found := m.mapping[FormatCELType(from)]; found { 37 | return r, found 38 | } 39 | return nil, false 40 | } 41 | 42 | func (m *mapping) copy() *mapping { 43 | c := newMapping() 44 | 45 | for k, v := range m.mapping { 46 | c.mapping[k] = v 47 | } 48 | return c 49 | } 50 | -------------------------------------------------------------------------------- /codelab/README.md: -------------------------------------------------------------------------------- 1 | ### Welcome to the CEL Codelab! 2 | --- 3 | 4 | Find the codelab instructions [here](https://codelabs.developers.google.com/codelabs/cel-go/#0). It requires some knowledge of GoLang and Protobuf. 5 | 6 | If you get stuck, check out the [solutions](https://github.com/google/cel-go/blob/master/codelab/solution/codelab.go). 7 | 8 | If you find a bug or want to make an improvement, PRs and issues are welcome. Please follow the [contributing guidelines](https://github.com/google/cel-go/blob/master/CONTRIBUTING.md). 9 | -------------------------------------------------------------------------------- /codelab/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/google/cel-go/codelab 2 | 3 | go 1.22.0 4 | 5 | toolchain go1.22.5 6 | 7 | require ( 8 | github.com/golang/glog v1.2.4 9 | github.com/google/cel-go v0.21.0 10 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 11 | google.golang.org/protobuf v1.34.2 12 | ) 13 | 14 | require ( 15 | cel.dev/expr v0.22.1 // indirect 16 | github.com/antlr4-go/antlr/v4 v4.13.0 // indirect 17 | github.com/stoewer/go-strcase v1.2.0 // indirect 18 | golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect 19 | google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect 20 | ) 21 | 22 | replace github.com/google/cel-go => ../. 23 | -------------------------------------------------------------------------------- /common/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | licenses = ["notice"], # Apache 2.0 6 | ) 7 | 8 | go_library( 9 | name = "go_default_library", 10 | srcs = [ 11 | "cost.go", 12 | "doc.go", 13 | "error.go", 14 | "errors.go", 15 | "location.go", 16 | "source.go", 17 | ], 18 | importpath = "github.com/google/cel-go/common", 19 | deps = [ 20 | "//common/runes:go_default_library", 21 | "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", 22 | ], 23 | ) 24 | 25 | go_test( 26 | name = "go_default_test", 27 | size = "small", 28 | srcs = [ 29 | "doc_test.go", 30 | "errors_test.go", 31 | "source_test.go", 32 | ], 33 | embed = [ 34 | ":go_default_library", 35 | ], 36 | ) 37 | -------------------------------------------------------------------------------- /common/containers/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | licenses = ["notice"], # Apache 2.0 6 | ) 7 | 8 | go_library( 9 | name = "go_default_library", 10 | srcs = [ 11 | "container.go", 12 | ], 13 | importpath = "github.com/google/cel-go/common/containers", 14 | deps = [ 15 | "//common/ast:go_default_library", 16 | ], 17 | ) 18 | 19 | go_test( 20 | name = "go_default_test", 21 | size = "small", 22 | srcs = [ 23 | "container_test.go", 24 | ], 25 | embed = [ 26 | ":go_default_library", 27 | ], 28 | deps = [ 29 | "//common/ast:go_default_library", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /common/debug/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | licenses = ["notice"], # Apache 2.0 6 | ) 7 | 8 | go_library( 9 | name = "go_default_library", 10 | srcs = [ 11 | "debug.go", 12 | ], 13 | importpath = "github.com/google/cel-go/common/debug", 14 | deps = [ 15 | "//common:go_default_library", 16 | "//common/ast:go_default_library", 17 | "//common/types:go_default_library", 18 | "//common/types/ref:go_default_library", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /common/decls/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | licenses = ["notice"], # Apache 2.0 6 | ) 7 | 8 | go_library( 9 | name = "go_default_library", 10 | srcs = [ 11 | "decls.go", 12 | ], 13 | importpath = "github.com/google/cel-go/common/decls", 14 | deps = [ 15 | "//checker/decls:go_default_library", 16 | "//common:go_default_library", 17 | "//common/functions:go_default_library", 18 | "//common/operators:go_default_library", 19 | "//common/types:go_default_library", 20 | "//common/types/ref:go_default_library", 21 | "//common/types/traits:go_default_library", 22 | "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", 23 | ], 24 | ) 25 | 26 | go_test( 27 | name = "go_default_test", 28 | srcs = [ 29 | "decls_test.go", 30 | ], 31 | embed = [":go_default_library"], 32 | deps = [ 33 | "//checker/decls:go_default_library", 34 | "//common/overloads:go_default_library", 35 | "//common/types:go_default_library", 36 | "//common/types/ref:go_default_library", 37 | "//common/types/traits:go_default_library", 38 | "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", 39 | "@org_golang_google_protobuf//proto:go_default_library", 40 | ], 41 | ) 42 | -------------------------------------------------------------------------------- /common/env/testdata/subset_env.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2025 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "subset-env" 16 | stdlib: 17 | exclude_macros: 18 | - map 19 | - filter 20 | exclude_functions: 21 | - name: "_+_" 22 | overloads: 23 | - id: add_bytes 24 | - id: add_list 25 | - id: add_string 26 | - name: "matches" 27 | - name: "timestamp" 28 | overloads: 29 | - id: "string_to_timestamp" 30 | - name: "duration" 31 | overloads: 32 | - id: "string_to_duration" 33 | variables: 34 | - name: "x" 35 | type_name: "int" 36 | - name: "y" 37 | type_name: "double" 38 | - name: "z" 39 | type_name: "uint" 40 | -------------------------------------------------------------------------------- /common/functions/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | licenses = ["notice"], # Apache 2.0 6 | ) 7 | 8 | go_library( 9 | name = "go_default_library", 10 | srcs = [ 11 | "functions.go", 12 | ], 13 | importpath = "github.com/google/cel-go/common/functions", 14 | deps = [ 15 | "//common/types/ref:go_default_library", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /common/operators/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | licenses = ["notice"], # Apache 2.0 6 | ) 7 | 8 | go_library( 9 | name = "go_default_library", 10 | srcs = [ 11 | "operators.go", 12 | ], 13 | importpath = "github.com/google/cel-go/common/operators", 14 | ) 15 | -------------------------------------------------------------------------------- /common/overloads/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | licenses = ["notice"], # Apache 2.0 6 | ) 7 | 8 | go_library( 9 | name = "go_default_library", 10 | srcs = [ 11 | "overloads.go", 12 | ], 13 | importpath = "github.com/google/cel-go/common/overloads", 14 | ) 15 | -------------------------------------------------------------------------------- /common/runes/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | licenses = ["notice"], # Apache 2.0 6 | ) 7 | 8 | go_library( 9 | name = "go_default_library", 10 | srcs = [ 11 | "buffer.go", 12 | ], 13 | importpath = "github.com/google/cel-go/common/runes", 14 | ) 15 | 16 | go_test( 17 | name = "go_default_test", 18 | size = "small", 19 | srcs = [ 20 | "buffer_test.go", 21 | ], 22 | embed = [ 23 | ":go_default_library", 24 | ], 25 | ) 26 | -------------------------------------------------------------------------------- /common/stdlib/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | licenses = ["notice"], # Apache 2.0 6 | ) 7 | 8 | go_library( 9 | name = "go_default_library", 10 | srcs = [ 11 | "standard.go", 12 | ], 13 | importpath = "github.com/google/cel-go/common/stdlib", 14 | deps = [ 15 | "//common:go_default_library", 16 | "//common/decls:go_default_library", 17 | "//common/functions:go_default_library", 18 | "//common/operators:go_default_library", 19 | "//common/overloads:go_default_library", 20 | "//common/types:go_default_library", 21 | "//common/types/ref:go_default_library", 22 | "//common/types/traits:go_default_library", 23 | ], 24 | ) -------------------------------------------------------------------------------- /common/types/any_value.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "reflect" 19 | 20 | anypb "google.golang.org/protobuf/types/known/anypb" 21 | ) 22 | 23 | // anyValueType constant representing the reflected type of google.protobuf.Any. 24 | var anyValueType = reflect.TypeOf(&anypb.Any{}) 25 | -------------------------------------------------------------------------------- /common/types/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package types contains the types, traits, and utilities common to all 16 | // components of expression handling. 17 | package types 18 | -------------------------------------------------------------------------------- /common/types/format.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | 7 | "github.com/google/cel-go/common/types/ref" 8 | "github.com/google/cel-go/common/types/traits" 9 | ) 10 | 11 | type formattable interface { 12 | format(*strings.Builder) 13 | } 14 | 15 | // Format formats the value as a string. The result is only intended for human consumption and ignores errors. 16 | // Do not depend on the output being stable. It may change at any time. 17 | func Format(val ref.Val) string { 18 | var sb strings.Builder 19 | formatTo(&sb, val) 20 | return sb.String() 21 | } 22 | 23 | func formatTo(sb *strings.Builder, val ref.Val) { 24 | if fmtable, ok := val.(formattable); ok { 25 | fmtable.format(sb) 26 | return 27 | } 28 | // All of the builtins implement formattable. Try to deal with traits. 29 | if l, ok := val.(traits.Lister); ok { 30 | formatList(l, sb) 31 | return 32 | } 33 | if m, ok := val.(traits.Mapper); ok { 34 | formatMap(m, sb) 35 | return 36 | } 37 | // This could be an error, unknown, opaque or object. 38 | // Unfortunately we have no consistent way of inspecting 39 | // opaque and object. So we just fallback to fmt.Stringer 40 | // and hope it is relavent. 41 | fmt.Fprintf(sb, "%s", val) 42 | } 43 | -------------------------------------------------------------------------------- /common/types/json_value.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "reflect" 19 | 20 | structpb "google.golang.org/protobuf/types/known/structpb" 21 | ) 22 | 23 | // JSON type constants representing the reflected types of protobuf JSON values. 24 | var ( 25 | jsonValueType = reflect.TypeOf(&structpb.Value{}) 26 | jsonListValueType = reflect.TypeOf(&structpb.ListValue{}) 27 | jsonStructType = reflect.TypeOf(&structpb.Struct{}) 28 | jsonNullType = reflect.TypeOf(structpb.NullValue_NULL_VALUE) 29 | ) 30 | -------------------------------------------------------------------------------- /common/types/ref/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | licenses = ["notice"], # Apache 2.0 6 | ) 7 | 8 | go_library( 9 | name = "go_default_library", 10 | srcs = [ 11 | "provider.go", 12 | "reference.go", 13 | ], 14 | importpath = "github.com/google/cel-go/common/types/ref", 15 | deps = [ 16 | "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", 17 | "@org_golang_google_protobuf//proto:go_default_library", 18 | "@org_golang_google_protobuf//reflect/protoreflect:go_default_library", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /common/types/traits/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | licenses = ["notice"], # Apache 2.0 6 | ) 7 | 8 | go_library( 9 | name = "go_default_library", 10 | srcs = [ 11 | "comparer.go", 12 | "container.go", 13 | "field_tester.go", 14 | "indexer.go", 15 | "iterator.go", 16 | "lister.go", 17 | "mapper.go", 18 | "matcher.go", 19 | "math.go", 20 | "receiver.go", 21 | "sizer.go", 22 | "traits.go", 23 | "zeroer.go", 24 | ], 25 | importpath = "github.com/google/cel-go/common/types/traits", 26 | deps = [ 27 | "//common/types/ref:go_default_library", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /common/types/traits/comparer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package traits 16 | 17 | import ( 18 | "github.com/google/cel-go/common/types/ref" 19 | ) 20 | 21 | // Comparer interface for ordering comparisons between values in order to 22 | // support '<', '<=', '>=', '>' overloads. 23 | type Comparer interface { 24 | // Compare this value to the input other value, returning an Int: 25 | // 26 | // this < other -> Int(-1) 27 | // this == other -> Int(0) 28 | // this > other -> Int(1) 29 | // 30 | // If the comparison cannot be made or is not supported, an error should 31 | // be returned. 32 | Compare(other ref.Val) ref.Val 33 | } 34 | -------------------------------------------------------------------------------- /common/types/traits/container.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package traits 16 | 17 | import "github.com/google/cel-go/common/types/ref" 18 | 19 | // Container interface which permits containment tests such as 'a in b'. 20 | type Container interface { 21 | // Contains returns true if the value exists within the object. 22 | Contains(value ref.Val) ref.Val 23 | } 24 | -------------------------------------------------------------------------------- /common/types/traits/field_tester.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package traits 16 | 17 | import ( 18 | "github.com/google/cel-go/common/types/ref" 19 | ) 20 | 21 | // FieldTester indicates if a defined field on an object type is set to a 22 | // non-default value. 23 | // 24 | // For use with the `has()` macro. 25 | type FieldTester interface { 26 | // IsSet returns true if the field is defined and set to a non-default 27 | // value. The method will return false if defined and not set, and an error 28 | // if the field is not defined. 29 | IsSet(field ref.Val) ref.Val 30 | } 31 | -------------------------------------------------------------------------------- /common/types/traits/indexer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package traits 16 | 17 | import ( 18 | "github.com/google/cel-go/common/types/ref" 19 | ) 20 | 21 | // Indexer permits random access of elements by index 'a[b()]'. 22 | type Indexer interface { 23 | // Get the value at the specified index or error. 24 | Get(index ref.Val) ref.Val 25 | } 26 | -------------------------------------------------------------------------------- /common/types/traits/lister.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package traits 16 | 17 | import "github.com/google/cel-go/common/types/ref" 18 | 19 | // Lister interface which aggregates the traits of a list. 20 | type Lister interface { 21 | ref.Val 22 | Adder 23 | Container 24 | Indexer 25 | Iterable 26 | Sizer 27 | } 28 | 29 | // MutableLister interface which emits an immutable result after an intermediate computation. 30 | // 31 | // Note, this interface is intended only to be used within Comprehensions where the mutable 32 | // value is not directly observable within the user-authored CEL expression. 33 | type MutableLister interface { 34 | Lister 35 | ToImmutableList() Lister 36 | } 37 | -------------------------------------------------------------------------------- /common/types/traits/matcher.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package traits 16 | 17 | import "github.com/google/cel-go/common/types/ref" 18 | 19 | // Matcher interface for supporting 'matches()' overloads. 20 | type Matcher interface { 21 | // Match returns true if the pattern matches the current value. 22 | Match(pattern ref.Val) ref.Val 23 | } 24 | -------------------------------------------------------------------------------- /common/types/traits/receiver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package traits 16 | 17 | import "github.com/google/cel-go/common/types/ref" 18 | 19 | // Receiver interface for routing instance method calls within a value. 20 | type Receiver interface { 21 | // Receive accepts a function name, overload id, and arguments and returns 22 | // a value. 23 | Receive(function string, overload string, args []ref.Val) ref.Val 24 | } 25 | -------------------------------------------------------------------------------- /common/types/traits/sizer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package traits 16 | 17 | import ( 18 | "github.com/google/cel-go/common/types/ref" 19 | ) 20 | 21 | // Sizer interface for supporting 'size()' overloads. 22 | type Sizer interface { 23 | // Size returns the number of elements or length of the value. 24 | Size() ref.Val 25 | } 26 | -------------------------------------------------------------------------------- /common/types/traits/zeroer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package traits 16 | 17 | // Zeroer interface for testing whether a CEL value is a zero value for its type. 18 | type Zeroer interface { 19 | // IsZeroValue indicates whether the object is the zero value for the type. 20 | IsZeroValue() bool 21 | } 22 | -------------------------------------------------------------------------------- /common/types/type_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/google/cel-go/common/types/ref" 21 | ) 22 | 23 | func TestType_ConvertToType(t *testing.T) { 24 | stdTypes := []ref.Val{ 25 | BoolType, 26 | BytesType, 27 | DoubleType, 28 | DurationType, 29 | IntType, 30 | ListType, 31 | MapType, 32 | NullType, 33 | StringType, 34 | TimestampType, 35 | TypeType, 36 | UintType, 37 | } 38 | for _, stdType := range stdTypes { 39 | cnv := stdType.ConvertToType(TypeType) 40 | if !cnv.Equal(TypeType).(Bool) { 41 | t.Errorf("Got %v, wanted 'type'", cnv) 42 | } 43 | } 44 | } 45 | 46 | func TestType_Type(t *testing.T) { 47 | if TypeType.Type() != TypeType { 48 | t.Error("type of type is not type.") 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /common/types/util_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import "testing" 18 | 19 | func BenchmarkIsUnknownOrError(b *testing.B) { 20 | err := NewErr("test") 21 | unk := &Unknown{} 22 | for i := 0; i < b.N; i++ { 23 | if !(IsUnknownOrError(unk) && IsUnknownOrError(err) && !IsUnknownOrError(IntOne)) { 24 | b.Fatal("IsUnknownOrError() provided an incorrect result.") 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /conformance/conformance_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | exec $@ 4 | -------------------------------------------------------------------------------- /conformance/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/google/cel-go/conformance 2 | 3 | go 1.22.0 4 | 5 | require ( 6 | cel.dev/expr v0.24.0 7 | github.com/bazelbuild/rules_go v0.49.0 8 | github.com/google/cel-go v0.21.0 9 | github.com/google/go-cmp v0.6.0 10 | google.golang.org/protobuf v1.34.2 11 | ) 12 | 13 | require ( 14 | github.com/antlr4-go/antlr/v4 v4.13.0 // indirect 15 | github.com/stoewer/go-strcase v1.2.0 // indirect 16 | golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect 17 | golang.org/x/text v0.22.0 // indirect 18 | google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect 19 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 // indirect 20 | ) 21 | 22 | replace github.com/google/cel-go => ./.. 23 | -------------------------------------------------------------------------------- /examples/simple_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package examples 16 | 17 | import ( 18 | "fmt" 19 | "log" 20 | 21 | "github.com/google/cel-go/cel" 22 | ) 23 | 24 | func ExampleSimple() { 25 | env, err := cel.NewEnv(cel.Variable("name", cel.StringType)) 26 | if err != nil { 27 | log.Fatalf("environment creation error: %v\n", err) 28 | } 29 | ast, iss := env.Compile(`"Hello world! I'm " + name + "."`) 30 | // Check iss for compilation errors. 31 | if iss.Err() != nil { 32 | log.Fatalln(iss.Err()) 33 | } 34 | prg, err := env.Program(ast) 35 | if err != nil { 36 | log.Fatalln(err) 37 | } 38 | out, _, err := prg.Eval(map[string]any{ 39 | "name": "CEL", 40 | }) 41 | if err != nil { 42 | log.Fatalln(err) 43 | } 44 | fmt.Println(out) 45 | // Output:Hello world! I'm CEL. 46 | } 47 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/google/cel-go 2 | 3 | go 1.22.0 4 | 5 | toolchain go1.23.0 6 | 7 | require ( 8 | cel.dev/expr v0.24.0 9 | github.com/antlr4-go/antlr/v4 v4.13.0 10 | github.com/stoewer/go-strcase v1.2.0 11 | google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 12 | google.golang.org/protobuf v1.34.2 13 | gopkg.in/yaml.v3 v3.0.1 14 | ) 15 | 16 | require ( 17 | golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect 18 | golang.org/x/text v0.22.0 19 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 // indirect 20 | ) 21 | -------------------------------------------------------------------------------- /interpreter/functions/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | package( 4 | default_visibility = ["//visibility:public"], 5 | licenses = ["notice"], # Apache 2.0 6 | ) 7 | 8 | go_library( 9 | name = "go_default_library", 10 | srcs = [ 11 | "functions.go", 12 | ], 13 | importpath = "github.com/google/cel-go/interpreter/functions", 14 | deps = [ 15 | "//common/functions:go_default_library", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /parser/errors.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package parser 16 | 17 | import ( 18 | "github.com/google/cel-go/common" 19 | ) 20 | 21 | // parseErrors is a specialization of Errors. 22 | type parseErrors struct { 23 | errs *common.Errors 24 | } 25 | 26 | // errorCount indicates the number of errors reported. 27 | func (e *parseErrors) errorCount() int { 28 | return len(e.errs.GetErrors()) 29 | } 30 | 31 | func (e *parseErrors) internalError(message string) { 32 | e.errs.ReportErrorAtID(0, common.NoLocation, "%s", message) 33 | } 34 | 35 | func (e *parseErrors) syntaxError(l common.Location, message string) { 36 | e.errs.ReportErrorAtID(0, l, "Syntax error: %s", message) 37 | } 38 | 39 | func (e *parseErrors) reportErrorAtID(id int64, l common.Location, message string, args ...any) { 40 | e.errs.ReportErrorAtID(id, l, message, args...) 41 | } 42 | -------------------------------------------------------------------------------- /parser/gen/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | package( 4 | default_visibility = ["//:__subpackages__"], 5 | licenses = ["notice"], # Apache 2.0 6 | ) 7 | 8 | go_library( 9 | name = "go_default_library", 10 | srcs = [ 11 | "cel_base_listener.go", 12 | "cel_base_visitor.go", 13 | "cel_lexer.go", 14 | "cel_listener.go", 15 | "cel_parser.go", 16 | "cel_visitor.go", 17 | ], 18 | data = [ 19 | "CEL.tokens", 20 | "CELLexer.tokens", 21 | ], 22 | importpath = "github.com/google/cel-go/parser/gen", 23 | deps = [ 24 | "@com_github_antlr4_go_antlr_v4//:go_default_library", 25 | ], 26 | ) 27 | -------------------------------------------------------------------------------- /parser/gen/CEL.tokens: -------------------------------------------------------------------------------- 1 | EQUALS=1 2 | NOT_EQUALS=2 3 | IN=3 4 | LESS=4 5 | LESS_EQUALS=5 6 | GREATER_EQUALS=6 7 | GREATER=7 8 | LOGICAL_AND=8 9 | LOGICAL_OR=9 10 | LBRACKET=10 11 | RPRACKET=11 12 | LBRACE=12 13 | RBRACE=13 14 | LPAREN=14 15 | RPAREN=15 16 | DOT=16 17 | COMMA=17 18 | MINUS=18 19 | EXCLAM=19 20 | QUESTIONMARK=20 21 | COLON=21 22 | PLUS=22 23 | STAR=23 24 | SLASH=24 25 | PERCENT=25 26 | CEL_TRUE=26 27 | CEL_FALSE=27 28 | NUL=28 29 | WHITESPACE=29 30 | COMMENT=30 31 | NUM_FLOAT=31 32 | NUM_INT=32 33 | NUM_UINT=33 34 | STRING=34 35 | BYTES=35 36 | IDENTIFIER=36 37 | ESC_IDENTIFIER=37 38 | '=='=1 39 | '!='=2 40 | 'in'=3 41 | '<'=4 42 | '<='=5 43 | '>='=6 44 | '>'=7 45 | '&&'=8 46 | '||'=9 47 | '['=10 48 | ']'=11 49 | '{'=12 50 | '}'=13 51 | '('=14 52 | ')'=15 53 | '.'=16 54 | ','=17 55 | '-'=18 56 | '!'=19 57 | '?'=20 58 | ':'=21 59 | '+'=22 60 | '*'=23 61 | '/'=24 62 | '%'=25 63 | 'true'=26 64 | 'false'=27 65 | 'null'=28 66 | -------------------------------------------------------------------------------- /parser/gen/CELLexer.tokens: -------------------------------------------------------------------------------- 1 | EQUALS=1 2 | NOT_EQUALS=2 3 | IN=3 4 | LESS=4 5 | LESS_EQUALS=5 6 | GREATER_EQUALS=6 7 | GREATER=7 8 | LOGICAL_AND=8 9 | LOGICAL_OR=9 10 | LBRACKET=10 11 | RPRACKET=11 12 | LBRACE=12 13 | RBRACE=13 14 | LPAREN=14 15 | RPAREN=15 16 | DOT=16 17 | COMMA=17 18 | MINUS=18 19 | EXCLAM=19 20 | QUESTIONMARK=20 21 | COLON=21 22 | PLUS=22 23 | STAR=23 24 | SLASH=24 25 | PERCENT=25 26 | CEL_TRUE=26 27 | CEL_FALSE=27 28 | NUL=28 29 | WHITESPACE=29 30 | COMMENT=30 31 | NUM_FLOAT=31 32 | NUM_INT=32 33 | NUM_UINT=33 34 | STRING=34 35 | BYTES=35 36 | IDENTIFIER=36 37 | ESC_IDENTIFIER=37 38 | '=='=1 39 | '!='=2 40 | 'in'=3 41 | '<'=4 42 | '<='=5 43 | '>='=6 44 | '>'=7 45 | '&&'=8 46 | '||'=9 47 | '['=10 48 | ']'=11 49 | '{'=12 50 | '}'=13 51 | '('=14 52 | ')'=15 53 | '.'=16 54 | ','=17 55 | '-'=18 56 | '!'=19 57 | '?'=20 58 | ':'=21 59 | '+'=22 60 | '*'=23 61 | '/'=24 62 | '%'=25 63 | 'true'=26 64 | 'false'=27 65 | 'null'=28 66 | -------------------------------------------------------------------------------- /parser/gen/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package gen contains all of the ANTLR-generated sources used by the cel-go parser. 16 | package gen 17 | -------------------------------------------------------------------------------- /parser/gen/generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | # 3 | # Copyright 2018 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # To regenerate the CEL lexer/parser statically do the following: 18 | # 1. Download the latest anltr tool from https://www.antlr.org/download.html 19 | # 2. Copy the downloaded jar to the gen directory. It will have a name 20 | # like antlr--complete.jar. 21 | # 3. Modify the script below to refer to the current ANTLR version. 22 | # 4. Execute the generation script from the gen directory. 23 | # 5. Delete the jar and commit the regenerated sources. 24 | 25 | #!/bin/sh 26 | 27 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 28 | 29 | # Generate AntLR artifacts. 30 | java -Xmx500M -cp ${DIR}/antlr-4.13.1-complete.jar org.antlr.v4.Tool \ 31 | -Dlanguage=Go \ 32 | -package gen \ 33 | -o ${DIR} \ 34 | -visitor ${DIR}/CEL.g4 35 | 36 | -------------------------------------------------------------------------------- /policy/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package policy 16 | 17 | import ( 18 | "github.com/google/cel-go/cel" 19 | "github.com/google/cel-go/common/env" 20 | "github.com/google/cel-go/ext" 21 | ) 22 | 23 | // FromConfig configures a CEL policy environment from a config file. 24 | // 25 | // This option supports all extensions supported by policies, whereas the cel.FromConfig supports 26 | // a set of configuration ConfigOptionFactory values to handle extensions and other config features 27 | // which may be defined outside of the `cel` package. 28 | func FromConfig(config *env.Config) cel.EnvOption { 29 | return cel.FromConfig(config, ext.ExtensionOptionFactory) 30 | } 31 | -------------------------------------------------------------------------------- /policy/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/google/cel-go/policy 2 | 3 | go 1.22.0 4 | 5 | require ( 6 | github.com/google/cel-go v0.22.0 7 | google.golang.org/protobuf v1.34.2 8 | gopkg.in/yaml.v3 v3.0.1 9 | ) 10 | 11 | require ( 12 | cel.dev/expr v0.23.1 // indirect 13 | github.com/antlr4-go/antlr/v4 v4.13.1 // indirect 14 | github.com/stoewer/go-strcase v1.3.0 // indirect 15 | golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 // indirect 16 | golang.org/x/text v0.22.0 // indirect 17 | google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect 18 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 // indirect 19 | ) 20 | 21 | replace github.com/google/cel-go => ../. 22 | -------------------------------------------------------------------------------- /policy/test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2025 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 16 | 17 | package( 18 | default_visibility = [ 19 | "//policy:__subpackages__" 20 | ], 21 | licenses = ["notice"], 22 | ) 23 | 24 | exports_files([ 25 | "cel_test_runner.go", 26 | ]) 27 | 28 | go_library( 29 | name = "test", 30 | testonly = True, 31 | srcs = [ 32 | "cel_test_runner.go", 33 | "k8s_cel_test_runner.go", 34 | ], 35 | deps = [ 36 | "//cel:go_default_library", 37 | "//common/types:go_default_library", 38 | "//common/types/ref:go_default_library", 39 | "//policy:go_default_library", 40 | "//tools/celtest:go_default_library", 41 | ], 42 | ) 43 | -------------------------------------------------------------------------------- /policy/test/k8s_cel_test_runner.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package test 16 | 17 | import ( 18 | "os" 19 | "testing" 20 | 21 | "github.com/google/cel-go/policy" 22 | "github.com/google/cel-go/tools/celtest" 23 | ) 24 | 25 | // TestK8sCEL triggers compilation and test execution of a k8s policy which 26 | // contains custom policy tags. Custom parser options are used to configure the 27 | // parser to handle the custom policy tags. Tests are triggered with a list of 28 | // custom CEL environment options. 29 | func TestK8sCEL(t *testing.T) { 30 | parserOpt := policy.ParserOption(testK8sPolicyParser) 31 | testResourcesDir := os.Getenv("RUNFILES_DIR") 32 | testRunnerOpt := celtest.TestRunnerOptionsFromFlags(testResourcesDir, nil, parserOpt) 33 | celtest.TriggerTests(t, testRunnerOpt) 34 | } 35 | 36 | func testK8sPolicyParser(p *policy.Parser) (*policy.Parser, error) { 37 | p.TagVisitor = policy.K8sTestTagHandler() 38 | return p, nil 39 | } 40 | -------------------------------------------------------------------------------- /policy/testdata/context_pb/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "context_pb" 16 | container: "google.expr.proto3" 17 | extensions: 18 | - name: "strings" 19 | version: 2 20 | context_variable: 21 | type_name: "google.expr.proto3.test.TestAllTypes" 22 | -------------------------------------------------------------------------------- /policy/testdata/context_pb/policy.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "context_pb" 16 | 17 | imports: 18 | - name: google.expr.proto3.test.TestAllTypes 19 | - name: google.expr.proto3.test.TestAllTypes.NestedEnum 20 | - name: | 21 | google.expr.proto3.test.ImportedGlobalEnum 22 | 23 | rule: 24 | match: 25 | - condition: > 26 | single_int32 > TestAllTypes{single_int64: 10}.single_int64 27 | output: | 28 | "invalid spec, got single_int32=%d, wanted <= 10".format([single_int32]) 29 | - condition: > 30 | standalone_enum == NestedEnum.BAR || 31 | ImportedGlobalEnum.IMPORT_BAR in imported_enums 32 | output: | 33 | "invalid spec, neither nested nor imported enums may refer to BAR or IMPORT_BAR" 34 | -------------------------------------------------------------------------------- /policy/testdata/context_pb/tests.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | description: "Protobuf input tests" 16 | section: 17 | - name: "valid" 18 | tests: 19 | - name: "good spec" 20 | context_expr: "test.TestAllTypes{single_int32: 10}" 21 | output: 22 | expr: "optional.none()" 23 | - name: "invalid" 24 | tests: 25 | - name: "bad spec" 26 | context_expr: "test.TestAllTypes{single_int32: 11}" 27 | output: 28 | value: "invalid spec, got single_int32=11, wanted <= 10" 29 | -------------------------------------------------------------------------------- /policy/testdata/k8s/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: k8s 16 | extensions: 17 | - name: "strings" 18 | version: 2 19 | variables: 20 | - name: "resource.labels" 21 | type_name: "map" 22 | params: 23 | - type_name: "string" 24 | - type_name: "string" 25 | - name: "resource.containers" 26 | type_name: "list" 27 | params: 28 | - type_name: "string" 29 | - name: "resource.namespace" 30 | type_name: "string" 31 | -------------------------------------------------------------------------------- /policy/testdata/k8s/policy.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: k8s 16 | kind: ValidatingAdmissionPolicy 17 | metadata: 18 | name: "policy.cel.dev" 19 | spec: 20 | failurePolicy: Fail 21 | matchConstraints: 22 | resourceRules: 23 | - apiGroups: ["services"] 24 | apiVersions: ["v3"] 25 | operations: ["CREATE", "UPDATE"] 26 | variables: 27 | - name: env 28 | expression: "resource.labels.?environment.orValue('prod')" 29 | - name: break_glass 30 | expression: "resource.labels.?break_glass.orValue('false') == 'true'" 31 | validations: 32 | - expression: > 33 | variables.break_glass || 34 | resource.containers.all(c, c.startsWith(variables.env + '.')) 35 | messageExpression: > 36 | 'only %s containers are allowed in namespace %s' 37 | .format([variables.env, resource.namespace]) 38 | -------------------------------------------------------------------------------- /policy/testdata/k8s/tests.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | description: K8s admission control tests 16 | section: 17 | - name: "invalid" 18 | tests: 19 | - name: "restricted_container" 20 | input: 21 | resource.namespace: 22 | value: "dev.cel" 23 | resource.labels: 24 | value: 25 | environment: "staging" 26 | resource.containers: 27 | value: 28 | - staging.dev.cel.container1 29 | - staging.dev.cel.container2 30 | - preprod.dev.cel.container3 31 | output: 32 | value: "only staging containers are allowed in namespace dev.cel" 33 | -------------------------------------------------------------------------------- /policy/testdata/limits/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "limits" 16 | extensions: 17 | - name: "strings" 18 | version: latest 19 | variables: 20 | - name: "now" 21 | type: 22 | type_name: "google.protobuf.Timestamp" 23 | -------------------------------------------------------------------------------- /policy/testdata/limits/tests.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | description: Limits related tests 16 | section: 17 | - name: "now_after_hours" 18 | tests: 19 | - name: "7pm" 20 | input: 21 | now: 22 | expr: "timestamp('2024-07-30T00:30:00Z')" 23 | output: 24 | value: "hello, me" 25 | - name: "8pm" 26 | input: 27 | now: 28 | expr: "timestamp('2024-07-30T20:30:00Z')" 29 | output: 30 | value: "goodbye, me!" 31 | - name: "9pm" 32 | input: 33 | now: 34 | expr: "timestamp('2024-07-30T21:30:00Z')" 35 | output: 36 | value: "goodbye, me!!" 37 | - name: "11pm" 38 | input: 39 | now: 40 | expr: "timestamp('2024-07-30T23:30:00Z')" 41 | output: 42 | value: "goodbye, me!!!" 43 | -------------------------------------------------------------------------------- /policy/testdata/nested_incompatible_outputs/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "nested_rule" 16 | -------------------------------------------------------------------------------- /policy/testdata/nested_incompatible_outputs/policy.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: nested_incompatible_outputs 16 | rule: 17 | match: 18 | - condition: "1 < 0" 19 | output: "true" 20 | - condition: "1 > 0" 21 | rule: 22 | match: 23 | - output: "'false'" 24 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "nested_rule" 16 | variables: 17 | - name: "resource" 18 | type_name: "map" 19 | params: 20 | - type_name: "string" 21 | - type_name: "dyn" 22 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule/tests.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | description: Nested rule conformance tests 16 | section: 17 | - name: "banned" 18 | tests: 19 | - name: "restricted_origin" 20 | input: 21 | resource: 22 | value: 23 | origin: "ir" 24 | output: 25 | expr: "{'banned': true}" 26 | - name: "by_default" 27 | input: 28 | resource: 29 | value: 30 | origin: "de" 31 | output: 32 | expr: "{'banned': true}" 33 | - name: "permitted" 34 | tests: 35 | - name: "valid_origin" 36 | input: 37 | resource: 38 | value: 39 | origin: "uk" 40 | output: 41 | expr: "{'banned': false}" 42 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule2/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "nested_rule2" 16 | variables: 17 | - name: "resource" 18 | type: 19 | type_name: "map" 20 | params: 21 | - type_name: "string" 22 | - type_name: "dyn" 23 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule3/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "nested_rule3" 16 | variables: 17 | - name: "resource" 18 | type: 19 | type_name: "map" 20 | params: 21 | - type_name: "string" 22 | - type_name: "dyn" 23 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule4/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "nested_rule4" 16 | variables: 17 | - name: x 18 | type: 19 | type_name: int 20 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule4/policy.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: nested_rule4 16 | rule: 17 | match: 18 | - condition: x > 0 19 | rule: 20 | match: 21 | - rule: 22 | match: 23 | - output: "true" 24 | - output: "false" 25 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule4/tests.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | description: "Nested rule tests which explore optional vs non-optional returns" 16 | section: 17 | - name: "valid" 18 | tests: 19 | - name: "x=0" 20 | input: 21 | x: 22 | value: 0 23 | output: 24 | value: false 25 | - name: "x=2" 26 | input: 27 | x: 28 | value: 2 29 | output: 30 | value: true 31 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule5/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "nested_rule5" 16 | variables: 17 | - name: x 18 | type: 19 | type_name: int 20 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule5/policy.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: nested_rule5 16 | rule: 17 | match: 18 | - condition: x > 0 19 | rule: 20 | match: 21 | - rule: 22 | match: 23 | - condition: "x > 2" 24 | output: "true" 25 | - condition: x > 1 26 | rule: 27 | match: 28 | - condition: "x >= 2" 29 | output: "true" 30 | - output: "false" 31 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule5/tests.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | description: "Nested rule tests which explore optional vs non-optional returns" 16 | section: 17 | - name: "valid" 18 | tests: 19 | - name: "x=0" 20 | input: 21 | x: 22 | value: 0 23 | output: 24 | value: false 25 | - name: "x=1" 26 | input: 27 | x: 28 | value: 1 29 | output: 30 | expr: "optional.none()" 31 | - name: "x=2" 32 | input: 33 | x: 34 | value: 2 35 | output: 36 | expr: "optional.none()" 37 | - name: "x=3" 38 | input: 39 | x: 40 | value: 3 41 | output: 42 | value: true 43 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule6/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "nested_rule6" 16 | variables: 17 | - name: x 18 | type: 19 | type_name: int 20 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule6/policy.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: nested_rule6 16 | rule: 17 | match: 18 | - rule: 19 | match: 20 | - rule: 21 | match: 22 | - condition: "x > 2" 23 | output: "true" 24 | - rule: 25 | match: 26 | - condition: "x > 3" 27 | output: "true" 28 | - output: "false" 29 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule6/tests.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | description: "Nested rule tests which explore optional vs non-optional returns" 16 | section: 17 | - name: "valid" 18 | tests: 19 | - name: "x=0" 20 | input: 21 | x: 22 | value: 0 23 | output: 24 | value: false 25 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule7/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "nested_rule7" 16 | variables: 17 | - name: x 18 | type: 19 | type_name: int 20 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule7/policy.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: nested_rule7 16 | rule: 17 | match: 18 | - rule: 19 | match: 20 | - rule: 21 | match: 22 | - condition: "x > 2" 23 | output: "true" 24 | - rule: 25 | match: 26 | - condition: "x > 3" 27 | output: "true" 28 | - condition: "x > 1" 29 | output: "false" 30 | -------------------------------------------------------------------------------- /policy/testdata/nested_rule7/tests.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | description: "Nested rule tests which explore optional vs non-optional returns" 16 | section: 17 | - name: "valid" 18 | tests: 19 | - name: "x=1" 20 | input: 21 | x: 22 | value: 1 23 | output: 24 | expr: "optional.none()" 25 | - name: "x=2" 26 | input: 27 | x: 28 | value: 2 29 | output: 30 | value: false 31 | - name: "x=3" 32 | input: 33 | x: 34 | value: 3 35 | output: 36 | value: true 37 | - name: "x=4" 38 | input: 39 | x: 40 | value: 4 41 | output: 42 | value: true 43 | -------------------------------------------------------------------------------- /policy/testdata/pb/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "pb" 16 | container: "google.expr.proto3" 17 | extensions: 18 | - name: "strings" 19 | version: 2 20 | variables: 21 | - name: "spec" 22 | type_name: "google.expr.proto3.test.TestAllTypes" 23 | -------------------------------------------------------------------------------- /policy/testdata/pb/policy.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "pb" 16 | 17 | imports: 18 | - name: google.expr.proto3.test.TestAllTypes 19 | - name: google.expr.proto3.test.TestAllTypes.NestedEnum 20 | - name: | 21 | google.expr.proto3.test.ImportedGlobalEnum 22 | 23 | rule: 24 | match: 25 | - condition: > 26 | spec.single_int32 > TestAllTypes{single_int64: 10}.single_int64 27 | output: | 28 | "invalid spec, got single_int32=%d, wanted <= 10".format([spec.single_int32]) 29 | - condition: > 30 | spec.standalone_enum == NestedEnum.BAR || 31 | ImportedGlobalEnum.IMPORT_BAR in spec.imported_enums 32 | output: | 33 | "invalid spec, neither nested nor imported enums may refer to BAR or IMPORT_BAR" 34 | -------------------------------------------------------------------------------- /policy/testdata/pb/tests.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | description: "Protobuf input tests" 16 | section: 17 | - name: "valid" 18 | tests: 19 | - name: "good spec" 20 | input: 21 | spec: 22 | expr: > 23 | test.TestAllTypes{single_int32: 10} 24 | output: 25 | expr: "optional.none()" 26 | - name: "invalid" 27 | tests: 28 | - name: "bad spec" 29 | input: 30 | spec: 31 | expr: > 32 | test.TestAllTypes{single_int32: 11} 33 | output: 34 | value: "invalid spec, got single_int32=11, wanted <= 10" 35 | -------------------------------------------------------------------------------- /policy/testdata/required_labels/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "labels" 16 | extensions: 17 | - name: "strings" 18 | version: 2 19 | - name: "two-var-comprehensions" 20 | variables: 21 | - name: "spec" 22 | type_name: "map" 23 | params: 24 | - type_name: "string" 25 | - type_name: "dyn" 26 | - name: "resource" 27 | type_name: "map" 28 | params: 29 | - type_name: "string" 30 | - type_name: "dyn" 31 | -------------------------------------------------------------------------------- /policy/testdata/required_labels/policy.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "required_labels" 16 | rule: 17 | variables: 18 | - name: want 19 | expression: spec.labels 20 | - name: missing 21 | expression: variables.want.filter(l, !(l in resource.labels)) 22 | - name: invalid 23 | expression: > 24 | resource.labels.transformList(l, value, 25 | l in variables.want && value != variables.want[l], l) 26 | match: 27 | - condition: variables.missing.size() > 0 28 | output: | 29 | "missing one or more required labels: %s".format([variables.missing]) 30 | - condition: variables.invalid.size() > 0 31 | output: | 32 | "invalid values provided on one or more labels: %s".format([variables.invalid]) 33 | -------------------------------------------------------------------------------- /policy/testdata/restricted_destinations/base_config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "labels" 16 | extensions: 17 | - name: "lists" 18 | - name: "sets" 19 | variables: 20 | - name: "destination.ip" 21 | type_name: "string" 22 | - name: "origin.ip" 23 | type_name: "string" 24 | - name: "spec.restricted_destinations" 25 | type_name: "list" 26 | params: 27 | - type_name: "string" 28 | - name: "spec.origin" 29 | type_name: "string" 30 | - name: "request" 31 | type_name: "map" 32 | params: 33 | - type_name: "string" 34 | - type_name: "dyn" 35 | - name: "resource" 36 | type_name: "map" 37 | params: 38 | - type_name: "string" 39 | - type_name: "dyn" 40 | -------------------------------------------------------------------------------- /policy/testdata/restricted_destinations/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "labels" 16 | extensions: 17 | - name: "lists" 18 | - name: "sets" 19 | variables: 20 | - name: "destination.ip" 21 | type_name: "string" 22 | - name: "origin.ip" 23 | type_name: "string" 24 | - name: "spec.restricted_destinations" 25 | type_name: "list" 26 | params: 27 | - type_name: "string" 28 | - name: "spec.origin" 29 | type_name: "string" 30 | - name: "request" 31 | type_name: "map" 32 | params: 33 | - type_name: "string" 34 | - type_name: "dyn" 35 | - name: "resource" 36 | type_name: "map" 37 | params: 38 | - type_name: "string" 39 | - type_name: "dyn" 40 | functions: 41 | - name: "locationCode" 42 | overloads: 43 | - id: "locationCode_string" 44 | args: 45 | - type_name: "string" 46 | return: 47 | type_name: "string" 48 | -------------------------------------------------------------------------------- /policy/testdata/restricted_destinations/partial_config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "labels" 16 | functions: 17 | - name: "locationCode" 18 | overloads: 19 | - id: "locationCode_string" 20 | args: 21 | - type_name: "string" 22 | return: 23 | type_name: "string" 24 | -------------------------------------------------------------------------------- /policy/testdata/unnest/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "unnest" 16 | variables: 17 | - name: values 18 | type_name: list 19 | params: 20 | - type_name: int 21 | -------------------------------------------------------------------------------- /policy/testdata/unnest/policy.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: unnest 16 | rule: 17 | variables: 18 | - name: even_greater 19 | expression: > 20 | values.filter(x, x > 2) 21 | match: 22 | - condition: > 23 | variables.even_greater.size() == 0 ? false : 24 | variables.even_greater.all(x, x % 2 == 0) 25 | output: > 26 | "some divisible by 2" 27 | - condition: "values.map(x, x * 3).exists(x, x % 4 == 0)" 28 | output: > 29 | "at least one divisible by 4" 30 | - condition: "values.map(x, x * x * x).exists(x, x % 6 == 0)" 31 | output: > 32 | "at least one power of 6" 33 | -------------------------------------------------------------------------------- /repl/appengine/.gcloudignore: -------------------------------------------------------------------------------- 1 | # This file specifies files that are *not* uploaded to Google Cloud 2 | # using gcloud. It follows the same syntax as .gitignore, with the addition of 3 | # "#!include" directives (which insert the entries of the given .gitignore-style 4 | # file at that point). 5 | # 6 | # For more information, run: 7 | # $ gcloud topic gcloudignore 8 | # 9 | .gcloudignore 10 | # If you would like to upload your .git directory, .gitignore file or files 11 | # from your .gitignore file, remove the corresponding line 12 | # below: 13 | .git 14 | .gitignore 15 | 16 | .angular 17 | .vscode 18 | web/node_modules 19 | web/src 20 | 21 | # Binaries for programs and plugins 22 | *.exe 23 | *.exe~ 24 | *.dll 25 | *.so 26 | *.dylib 27 | # Test binary, build with `go test -c` 28 | *.test 29 | # Output of the go coverage tool, specifically when used with LiteIDE 30 | *.out -------------------------------------------------------------------------------- /repl/appengine/README.md: -------------------------------------------------------------------------------- 1 | # CEL REPL Web 2 | Provides a simple web interface for working with the CEL REPL. 3 | 4 | The two main components are 1) a Go application that implements a service 5 | wrapping the REPL and serving static web content 2) an angular based web page 6 | that provides an interface around the API. 7 | 8 | The REPL service is stateless -- it initializes a new REPL instance and applies 9 | the requested commands in order on each request. 10 | 11 | ## Development 12 | 13 | Node.js and Go (>=1.18) are required to run the application. 14 | 15 | To run the application in development mode, run the npm watch script 16 | and run the Go server as follows: 17 | 18 | ``` 19 | # from the `repl/appengine/web` directory: 20 | npm run watch 21 | 22 | # from the repl/appengine directory: 23 | go run ./main --serve_static ./web/dist/web 24 | ``` 25 | 26 | ## Deploy on google cloud appengine 27 | 28 | 1. Build the angular application with `npm run build`. 29 | 30 | 1. Follow the instructions here: 31 | (https://cloud.google.com/appengine/docs/standard/go/building-app). Make sure to 32 | follow the instructions for setting up your gcloud cli, and the appengine 33 | support in cloud console for your project. -------------------------------------------------------------------------------- /repl/appengine/app.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | runtime: go118 16 | 17 | main: ./main 18 | 19 | handlers: 20 | - url: /ng 21 | static_dir: web/dist/web 22 | 23 | - url: /ng/ 24 | static_files: web/dist/web/index.html 25 | upload: web/dist/web/index.html 26 | 27 | - url: /.* 28 | secure: always 29 | redirect_http_response_code: 301 30 | script: auto 31 | -------------------------------------------------------------------------------- /repl/appengine/app/app.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package app provides a simple JSON API for using the REPL in a web application. 16 | package app 17 | 18 | import ( 19 | "log" 20 | "net/http" 21 | ) 22 | 23 | // NewAppMux returns an http.ServeMux that handles requests for the REPL app. 24 | // 25 | // Optionally serves the static website content from directory staticDir (if 26 | // non-empty). 27 | func NewAppMux(staticDir string) *http.ServeMux { 28 | mux := http.NewServeMux() 29 | mux.Handle("/", http.RedirectHandler("/ng/", 301)) 30 | mux.HandleFunc("/api", NewJSONHandler()) 31 | if staticDir != "" { 32 | log.Printf("serving static from '%s'", staticDir) 33 | mux.Handle("/ng/", 34 | http.StripPrefix("/ng", 35 | http.FileServer(http.Dir(staticDir)))) 36 | } 37 | return mux 38 | } 39 | -------------------------------------------------------------------------------- /repl/appengine/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/google/cel-go/repl/appengine 2 | 3 | go 1.22.0 4 | 5 | require github.com/google/cel-go/repl v0.0.0-20230406155237-b081aea03865 6 | 7 | require ( 8 | cel.dev/expr v0.16.1 // indirect 9 | github.com/antlr4-go/antlr/v4 v4.13.0 // indirect 10 | github.com/google/cel-go v0.0.0-00010101000000-000000000000 // indirect 11 | github.com/stoewer/go-strcase v1.3.0 // indirect 12 | golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect 13 | golang.org/x/text v0.16.0 // indirect 14 | google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect 15 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 // indirect 16 | google.golang.org/protobuf v1.34.2 // indirect 17 | ) 18 | 19 | replace github.com/google/cel-go => ../../. 20 | 21 | replace github.com/google/cel-go/repl => ../. 22 | -------------------------------------------------------------------------------- /repl/appengine/main/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 16 | 17 | package( 18 | licenses = ["notice"], # Apache 2.0 19 | ) 20 | 21 | go_binary( 22 | name = "main", 23 | embed = [":go_default_library"], 24 | importpath = "github.com/google/cel-go/repl/appengine/main", 25 | visibility = ["//visibility:public"], 26 | ) 27 | 28 | go_library( 29 | name = "go_default_library", 30 | srcs = ["main.go"], 31 | importpath = "github.com/google/cel-go/repl/main", 32 | visibility = ["//visibility:private"], 33 | deps = [ 34 | "//repl/appengine/app:go_default_library", 35 | ], 36 | ) 37 | -------------------------------------------------------------------------------- /repl/appengine/main/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // package main provides an entry point for the REPL web server. 16 | package main 17 | 18 | import ( 19 | "flag" 20 | "log" 21 | "net/http" 22 | "os" 23 | 24 | "github.com/google/cel-go/repl/appengine/app" 25 | ) 26 | 27 | var port string 28 | var serveStatic string 29 | 30 | func init() { 31 | port = os.Getenv("PORT") 32 | if port == "" { 33 | port = "8080" 34 | log.Printf("Defaulting to port %s", port) 35 | } 36 | flag.StringVar(&serveStatic, "serve_static", "", "serve static files from binary using argument as root") 37 | flag.Parse() 38 | } 39 | 40 | type context struct{} 41 | 42 | func main() { 43 | mux := app.NewAppMux(serveStatic) 44 | log.Printf("Listening on port %s", port) 45 | http.Handle("/", mux) 46 | if err := http.ListenAndServe(":"+port, nil); err != nil { 47 | log.Fatal(err) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /repl/appengine/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "web/assets", 4 | "allowJs": true, 5 | "target": "es5" 6 | }, 7 | "include": ["./web/src/**/*"] 8 | } -------------------------------------------------------------------------------- /repl/appengine/web/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | 18 | [*.html] 19 | trim_trailing_whitespace = true 20 | -------------------------------------------------------------------------------- /repl/appengine/web/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es2021": true 5 | }, 6 | "extends": [ 7 | "eslint:recommended", 8 | "plugin:@typescript-eslint/recommended" 9 | ], 10 | "overrides": [ 11 | ], 12 | "parser": "@typescript-eslint/parser", 13 | "parserOptions": { 14 | "ecmaVersion": "latest", 15 | "sourceType": "module" 16 | }, 17 | "plugins": [ 18 | "@typescript-eslint" 19 | ], 20 | "rules": { 21 | "semi": 1 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /repl/appengine/web/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # Compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | /bazel-out 8 | 9 | # Node 10 | /node_modules 11 | npm-debug.log 12 | yarn-error.log 13 | 14 | # IDEs and editors 15 | .idea/ 16 | .project 17 | .classpath 18 | .c9/ 19 | *.launch 20 | .settings/ 21 | *.sublime-workspace 22 | 23 | # Visual Studio Code 24 | .vscode/* 25 | !.vscode/settings.json 26 | !.vscode/tasks.json 27 | !.vscode/launch.json 28 | !.vscode/extensions.json 29 | .history/* 30 | 31 | # Miscellaneous 32 | /.angular/cache 33 | .sass-cache/ 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | testem.log 38 | /typings 39 | 40 | # System files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /repl/appengine/web/README.md: -------------------------------------------------------------------------------- 1 | # Web 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 15.0.1. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 28 | -------------------------------------------------------------------------------- /repl/appengine/web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development", 9 | "test": "ng test" 10 | }, 11 | "private": true, 12 | "dependencies": { 13 | "@angular/animations": "^18.2.6", 14 | "@angular/cdk": "^18.2.6", 15 | "@angular/common": "^18.2.6", 16 | "@angular/compiler": "^18.2.6", 17 | "@angular/core": "^18.2.6", 18 | "@angular/forms": "^18.2.6", 19 | "@angular/material": "^18.2.6", 20 | "@angular/platform-browser": "^18.2.6", 21 | "@angular/platform-browser-dynamic": "^18.2.6", 22 | "@angular/router": "^18.2.6", 23 | "rxjs": "~7.5.0", 24 | "tslib": "^2.3.0", 25 | "zone.js": "~0.14.10" 26 | }, 27 | "devDependencies": { 28 | "@angular-devkit/build-angular": "^19.1.3", 29 | "@angular/cli": "~18.2.6", 30 | "@angular/compiler-cli": "^18.2.6", 31 | "@types/jasmine": "~4.3.0", 32 | "@typescript-eslint/eslint-plugin": "^5.53.0", 33 | "@typescript-eslint/parser": "^5.53.0", 34 | "eslint": "^8.34.0", 35 | "jasmine-core": "~4.5.0", 36 | "karma": "~6.4.0", 37 | "karma-chrome-launcher": "~3.1.0", 38 | "karma-coverage": "~2.2.0", 39 | "karma-jasmine": "~5.1.0", 40 | "karma-jasmine-html-reporter": "~2.0.0", 41 | "typescript": "~5.4.5" 42 | } 43 | } -------------------------------------------------------------------------------- /repl/appengine/web/src/app/app-component.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Component, ViewChild } from '@angular/core'; 18 | import { ReplConsoleComponent } from './repl_console/repl-console-component'; 19 | 20 | 21 | /** 22 | * Top level component for the CEL REPL app. 23 | */ 24 | @Component({ 25 | standalone: false, 26 | selector: 'app-root', 27 | templateUrl: './app-component.html', 28 | styleUrls: ['./app-component.scss'] 29 | }) 30 | export class AppComponent { 31 | @ViewChild(ReplConsoleComponent) 32 | private console!: ReplConsoleComponent; 33 | 34 | submitConsole() { 35 | this.console.submit(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /repl/appengine/web/src/app/reference_panel/reference-panel-component.scss: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /repl/appengine/web/src/app/reference_panel/reference-panel-module.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { NgModule } from '@angular/core'; 18 | import { CommonModule } from '@angular/common'; 19 | import { ReferencePanelComponent } from './reference-panel-component'; 20 | import { MatButtonModule } from '@angular/material/button'; 21 | import { MatExpansionModule } from '@angular/material/expansion'; 22 | import { MatFormFieldModule } from '@angular/material/form-field'; 23 | import { MatListModule } from '@angular/material/list'; 24 | 25 | @NgModule({ 26 | declarations: [ 27 | ReferencePanelComponent 28 | ], 29 | imports: [ 30 | CommonModule, 31 | MatButtonModule, 32 | MatExpansionModule, 33 | MatFormFieldModule, 34 | MatListModule, 35 | ], 36 | exports: [ 37 | ReferencePanelComponent 38 | ] 39 | }) 40 | export class ReferencePanelModule { } 41 | -------------------------------------------------------------------------------- /repl/appengine/web/src/app/repl_console/repl-console-component.scss: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | .repl-console-wrapper input { 19 | font-family: monospace; 20 | } 21 | 22 | .statement-block { 23 | width: 100%; 24 | min-width: inherit; 25 | margin-top: 1rem; 26 | margin-bottom: 1rem; 27 | } 28 | 29 | .statement-container { 30 | width: 100%; 31 | } 32 | 33 | .statement-container mat-hint { 34 | font-size: 1rem; 35 | } 36 | 37 | .reset-wrapper { 38 | position: absolute; 39 | right: 2rem; 40 | top: 4rem; 41 | } -------------------------------------------------------------------------------- /repl/appengine/web/src/app/repl_console/repl-result-detail-component.html: -------------------------------------------------------------------------------- 1 | 16 | 17 |
18 |
19 |
{{lastResponse!.issue}}
20 |
21 |
22 |
{{lastResponse!.replOutput}}
23 |
24 |
25 |
26 | Eval Time: {{formatTime(evalTime)}} 27 |
-------------------------------------------------------------------------------- /repl/appengine/web/src/app/repl_console/repl-result-detail-component.scss: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | .repl-result-detail pre, .repl-result-detail code { 18 | font-size: 1.1rem; 19 | } -------------------------------------------------------------------------------- /repl/appengine/web/src/app/repl_console/repl-result-detail-component.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 18 | 19 | import { ReplResultDetailComponent } from './repl-result-detail-component'; 20 | 21 | describe('ReplResultDetailComponent', () => { 22 | let component: ReplResultDetailComponent; 23 | let fixture: ComponentFixture; 24 | 25 | beforeEach(async () => { 26 | await TestBed.configureTestingModule({ 27 | declarations: [ ReplResultDetailComponent ] 28 | }) 29 | .compileComponents(); 30 | 31 | fixture = TestBed.createComponent(ReplResultDetailComponent); 32 | component = fixture.componentInstance; 33 | fixture.detectChanges(); 34 | }); 35 | 36 | it('should create', () => { 37 | expect(component).toBeTruthy(); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /repl/appengine/web/src/app/repl_console/repl-result-detail-component.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Component, Input } from '@angular/core'; 18 | import { CommandResponse } from '../shared/repl-api-service'; 19 | 20 | /** 21 | * Simple component for detailing the output of the last command from the REPL 22 | * API. 23 | */ 24 | @Component({ 25 | standalone: false, 26 | selector: 'app-repl-result-detail', 27 | templateUrl: './repl-result-detail-component.html', 28 | styleUrls: ['./repl-result-detail-component.scss'] 29 | }) 30 | export class ReplResultDetailComponent { 31 | @Input() lastResponse? : CommandResponse; 32 | @Input() evalTime? : number; 33 | 34 | formatTime(ns : number) : string { 35 | const ms = ns / 1000000; 36 | 37 | return ms.toPrecision(3) + "ms"; 38 | } 39 | } -------------------------------------------------------------------------------- /repl/appengine/web/src/app/shared/repl-api-service.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { TestBed } from '@angular/core/testing'; 18 | import { provideHttpClientTesting } from '@angular/common/http/testing'; 19 | 20 | import { ReplApiService } from './repl-api-service'; 21 | import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; 22 | 23 | describe('ReplApiService', () => { 24 | let service: ReplApiService; 25 | 26 | beforeEach(() => { 27 | TestBed.configureTestingModule({ 28 | imports: [], 29 | providers: [provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()] 30 | }); 31 | service = TestBed.inject(ReplApiService); 32 | }); 33 | 34 | it('should be created', () => { 35 | expect(service).toBeTruthy(); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /repl/appengine/web/src/app/shared/repl-example-service.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Injectable } from '@angular/core'; 18 | import { Subject } from 'rxjs'; 19 | import { EvaluateRequest } from './repl-api-service'; 20 | 21 | /** 22 | * Representation of an example REPL session. 23 | */ 24 | export declare interface Example { 25 | request: EvaluateRequest; 26 | } 27 | 28 | /** 29 | * Service for setting an active example. 30 | */ 31 | @Injectable({ 32 | providedIn: 'root' 33 | }) 34 | export class ReplExampleService { 35 | 36 | private exampleSource = new Subject(); 37 | 38 | /** 39 | * Observable for posted examples. 40 | */ 41 | examplePosted$ = this.exampleSource.asObservable(); 42 | 43 | /** 44 | * Post an example to be displayed. 45 | */ 46 | postExample(example: Example) { 47 | this.exampleSource.next(example); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /repl/appengine/web/src/app/shared/shared-module.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { NgModule } from '@angular/core'; 18 | import { CommonModule } from '@angular/common'; 19 | import { TrimPipe } from './trim-pipe'; 20 | 21 | 22 | @NgModule({ 23 | declarations: [ 24 | TrimPipe 25 | ], 26 | exports: [ 27 | TrimPipe 28 | ], 29 | imports: [ 30 | CommonModule 31 | ] 32 | }) 33 | export class SharedModule { } 34 | -------------------------------------------------------------------------------- /repl/appengine/web/src/app/shared/trim-pipe.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { TrimPipe } from './trim-pipe'; 18 | 19 | describe('TrimPipe', () => { 20 | it('create an instance', () => { 21 | const pipe = new TrimPipe(); 22 | expect(pipe).toBeTruthy(); 23 | }); 24 | 25 | it('trims long string', () => { 26 | const pipe = new TrimPipe(); 27 | expect(pipe.transform("test123456789", 7)).toBe("test..."); 28 | }); 29 | 30 | it('does not trim short string', () => { 31 | const pipe = new TrimPipe(); 32 | expect(pipe.transform("test", 7)).toBe("test"); 33 | }); 34 | }); 35 | -------------------------------------------------------------------------------- /repl/appengine/web/src/app/shared/trim-pipe.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { Pipe, PipeTransform } from '@angular/core'; 18 | 19 | /** 20 | * Pipe for templates that caps the length of input string (if trimmed, marking 21 | * with an elipsis). 22 | */ 23 | @Pipe({ 24 | standalone: false, 25 | name: 'trim' 26 | }) 27 | export class TrimPipe implements PipeTransform { 28 | 29 | transform(value: string, length : number): string { 30 | return value.length < length ? 31 | value : 32 | value.substring(0, length - 3) + "..."; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /repl/appengine/web/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/cel-go/c55aebf5346fcd5c06dc56fd6b817015fc008ee4/repl/appengine/web/src/assets/.gitkeep -------------------------------------------------------------------------------- /repl/appengine/web/src/assets/github.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /repl/appengine/web/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/cel-go/c55aebf5346fcd5c06dc56fd6b817015fc008ee4/repl/appengine/web/src/favicon.ico -------------------------------------------------------------------------------- /repl/appengine/web/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | CEL REPL 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /repl/appengine/web/src/main.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { platformBrowser } from '@angular/platform-browser'; 18 | 19 | import { AppModule } from './app/app-module'; 20 | 21 | 22 | platformBrowser().bootstrapModule(AppModule) 23 | .catch(err => {console.error(err);}); 24 | -------------------------------------------------------------------------------- /repl/appengine/web/src/styles.scss: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* Global styles. */ 18 | 19 | html { 20 | font-size: 100%; 21 | } 22 | 23 | body { 24 | font-size: 1em; 25 | margin: 0; 26 | font-family: Roboto, "Helvetica Neue", sans-serif; 27 | } 28 | -------------------------------------------------------------------------------- /repl/appengine/web/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts" 10 | ], 11 | "include": [ 12 | "src/**/*.d.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /repl/appengine/web/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "forceConsistentCasingInFileNames": true, 8 | "strict": true, 9 | "noImplicitOverride": true, 10 | "noPropertyAccessFromIndexSignature": true, 11 | "noImplicitReturns": true, 12 | "noFallthroughCasesInSwitch": true, 13 | "sourceMap": true, 14 | "declaration": false, 15 | "downlevelIteration": true, 16 | "experimentalDecorators": true, 17 | "moduleResolution": "node", 18 | "importHelpers": true, 19 | "target": "ES2022", 20 | "module": "ES2022", 21 | "useDefineForClassFields": false, 22 | "lib": [ 23 | "ES2022", 24 | "dom" 25 | ] 26 | }, 27 | "angularCompilerOptions": { 28 | "enableI18nLegacyMessageIdFormat": false, 29 | "strictInjectionParameters": true, 30 | "strictInputAccessModifiers": true, 31 | "strictTemplates": true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /repl/appengine/web/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "include": [ 11 | "src/**/*.spec.ts", 12 | "src/**/*.d.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /repl/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/google/cel-go/repl 2 | 3 | go 1.22.0 4 | 5 | require ( 6 | cel.dev/expr v0.23.1 7 | github.com/antlr4-go/antlr/v4 v4.13.0 8 | github.com/chzyer/readline v1.5.1 9 | github.com/google/cel-go v0.0.0-00010101000000-000000000000 10 | google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 11 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 12 | google.golang.org/protobuf v1.34.2 13 | ) 14 | 15 | require ( 16 | github.com/stoewer/go-strcase v1.3.0 // indirect 17 | golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect 18 | golang.org/x/sys v0.21.0 // indirect 19 | golang.org/x/text v0.22.0 // indirect 20 | ) 21 | 22 | replace github.com/google/cel-go => ../. 23 | 24 | replace cel.dev/expr => ../../cel-spec 25 | -------------------------------------------------------------------------------- /repl/main/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 16 | 17 | package( 18 | licenses = ["notice"], # Apache 2.0 19 | ) 20 | 21 | go_binary( 22 | name = "main", 23 | embed = [":go_default_library"], 24 | importpath = "github.com/google/cel-go/repl/main", 25 | visibility = ["//visibility:public"], 26 | ) 27 | 28 | go_library( 29 | name = "go_default_library", 30 | srcs = ["main.go"], 31 | importpath = "github.com/google/cel-go/repl/main", 32 | visibility = ["//visibility:private"], 33 | deps = [ 34 | "//repl:go_default_library", 35 | "@com_github_chzyer_readline//:go_default_library", 36 | ], 37 | ) 38 | -------------------------------------------------------------------------------- /repl/parser/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 16 | 17 | package( 18 | default_visibility = ["//repl:__subpackages__"], 19 | licenses = ["notice"], # Apache 2.0 20 | ) 21 | 22 | go_library( 23 | name = "go_default_library", 24 | srcs = glob(["*.go"], exclude=["*_test.go"]), 25 | data = glob(["*.tokens"]), 26 | importpath = "github.com/google/cel-go/repl/parser", 27 | deps = [ 28 | "@com_github_antlr4_go_antlr_v4//:go_default_library", 29 | ], 30 | ) 31 | 32 | go_test( 33 | name = "go_default_test", 34 | srcs = ["commands_test.go"], 35 | embed = [":go_default_library"], 36 | deps = [ 37 | "@com_github_antlr4_go_antlr_v4//:go_default_library", 38 | ], 39 | ) 40 | -------------------------------------------------------------------------------- /repl/parser/Commands.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | T__4=5 6 | T__5=6 7 | T__6=7 8 | T__7=8 9 | COMMAND=9 10 | FLAG=10 11 | ARROW=11 12 | EQUAL_ASSIGN=12 13 | EQUALS=13 14 | NOT_EQUALS=14 15 | IN=15 16 | LESS=16 17 | LESS_EQUALS=17 18 | GREATER_EQUALS=18 19 | GREATER=19 20 | LOGICAL_AND=20 21 | LOGICAL_OR=21 22 | LBRACKET=22 23 | RPRACKET=23 24 | LBRACE=24 25 | RBRACE=25 26 | LPAREN=26 27 | RPAREN=27 28 | DOT=28 29 | COMMA=29 30 | MINUS=30 31 | EXCLAM=31 32 | QUESTIONMARK=32 33 | COLON=33 34 | PLUS=34 35 | STAR=35 36 | SLASH=36 37 | PERCENT=37 38 | CEL_TRUE=38 39 | CEL_FALSE=39 40 | NUL=40 41 | WHITESPACE=41 42 | COMMENT=42 43 | NUM_FLOAT=43 44 | NUM_INT=44 45 | NUM_UINT=45 46 | STRING=46 47 | BYTES=47 48 | IDENTIFIER=48 49 | '%help'=1 50 | '%?'=2 51 | '%let'=3 52 | '%declare'=4 53 | '%delete'=5 54 | '%compile'=6 55 | '%parse'=7 56 | '%eval'=8 57 | '->'=11 58 | '='=12 59 | '=='=13 60 | '!='=14 61 | 'in'=15 62 | '<'=16 63 | '<='=17 64 | '>='=18 65 | '>'=19 66 | '&&'=20 67 | '||'=21 68 | '['=22 69 | ']'=23 70 | '{'=24 71 | '}'=25 72 | '('=26 73 | ')'=27 74 | '.'=28 75 | ','=29 76 | '-'=30 77 | '!'=31 78 | '?'=32 79 | ':'=33 80 | '+'=34 81 | '*'=35 82 | '/'=36 83 | '%'=37 84 | 'true'=38 85 | 'false'=39 86 | 'null'=40 87 | -------------------------------------------------------------------------------- /repl/parser/CommandsLexer.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | T__4=5 6 | T__5=6 7 | T__6=7 8 | T__7=8 9 | COMMAND=9 10 | FLAG=10 11 | ARROW=11 12 | EQUAL_ASSIGN=12 13 | EQUALS=13 14 | NOT_EQUALS=14 15 | IN=15 16 | LESS=16 17 | LESS_EQUALS=17 18 | GREATER_EQUALS=18 19 | GREATER=19 20 | LOGICAL_AND=20 21 | LOGICAL_OR=21 22 | LBRACKET=22 23 | RPRACKET=23 24 | LBRACE=24 25 | RBRACE=25 26 | LPAREN=26 27 | RPAREN=27 28 | DOT=28 29 | COMMA=29 30 | MINUS=30 31 | EXCLAM=31 32 | QUESTIONMARK=32 33 | COLON=33 34 | PLUS=34 35 | STAR=35 36 | SLASH=36 37 | PERCENT=37 38 | CEL_TRUE=38 39 | CEL_FALSE=39 40 | NUL=40 41 | WHITESPACE=41 42 | COMMENT=42 43 | NUM_FLOAT=43 44 | NUM_INT=44 45 | NUM_UINT=45 46 | STRING=46 47 | BYTES=47 48 | IDENTIFIER=48 49 | '%help'=1 50 | '%?'=2 51 | '%let'=3 52 | '%declare'=4 53 | '%delete'=5 54 | '%compile'=6 55 | '%parse'=7 56 | '%eval'=8 57 | '->'=11 58 | '='=12 59 | '=='=13 60 | '!='=14 61 | 'in'=15 62 | '<'=16 63 | '<='=17 64 | '>='=18 65 | '>'=19 66 | '&&'=20 67 | '||'=21 68 | '['=22 69 | ']'=23 70 | '{'=24 71 | '}'=25 72 | '('=26 73 | ')'=27 74 | '.'=28 75 | ','=29 76 | '-'=30 77 | '!'=31 78 | '?'=32 79 | ':'=33 80 | '+'=34 81 | '*'=35 82 | '/'=36 83 | '%'=37 84 | 'true'=38 85 | 'false'=39 86 | 'null'=40 87 | -------------------------------------------------------------------------------- /repl/parser/regen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ANTLR_JAR="antlr-4.13.1-complete.jar" 4 | export CLASSPATH=".:$ANTLR_JAR:$CLASSPATH" 5 | antlr4="java -Xmx500M -cp \"$ANTLR_JAR:$CLASSPATH\" org.antlr.v4.Tool" 6 | 7 | $antlr4 \ 8 | -Dlanguage=Go \ 9 | -lib ../../parser/gen \ 10 | -package parser \ 11 | -visitor \ 12 | ./Commands.g4 13 | -------------------------------------------------------------------------------- /scripts/verify-vendor.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2023 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -o errexit 18 | set -o nounset 19 | set -o pipefail 20 | 21 | tmp="$(mktemp -d)" 22 | go mod vendor -o "$tmp" 23 | if ! _out="$(diff -Naupr vendor $tmp)"; then 24 | echo "Verify vendor failed" >&2 25 | echo "If you're seeing this locally, run the below command to fix your go.mod:" >&2 26 | echo "go mod vendor" >&2 27 | exit 1 28 | fi 29 | -------------------------------------------------------------------------------- /test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | package( 4 | default_visibility = [ 5 | "//cel:__subpackages__", 6 | "//checker:__subpackages__", 7 | "//common:__subpackages__", 8 | "//ext:__subpackages__", 9 | "//interpreter:__subpackages__", 10 | "//parser:__subpackages__", 11 | "//server:__subpackages__", 12 | "//tools:__subpackages__", 13 | "//policy:__subpackages__", 14 | ], 15 | licenses = ["notice"], # Apache 2.0 16 | ) 17 | 18 | go_library( 19 | name = "go_default_library", 20 | srcs = [ 21 | "compare.go", 22 | "expr.go", 23 | "suite.go", 24 | ], 25 | importpath = "github.com/google/cel-go/test", 26 | deps = [ 27 | "//common/operators:go_default_library", 28 | "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", 29 | "@org_golang_google_protobuf//proto:go_default_library", 30 | "@org_golang_google_protobuf//types/known/structpb:go_default_library", 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /test/bench/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | package( 4 | licenses = ["notice"], # Apache 2.0 5 | ) 6 | 7 | go_library( 8 | name = "go_default_library", 9 | srcs = [ 10 | "bench.go", 11 | ], 12 | importpath = "github.com/google/cel-go/test/bench", 13 | deps = [ 14 | "//cel:go_default_library", 15 | "//ext:go_default_library", 16 | "//common/types:go_default_library", 17 | "//common/types/ref:go_default_library", 18 | ], 19 | ) 20 | 21 | go_test( 22 | name = "go_default_test", 23 | srcs = [ 24 | "bench_test.go", 25 | ], 26 | embed = [ 27 | ":go_default_library", 28 | ], 29 | deps = [ 30 | "//cel:go_default_library", 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /test/bench/bench_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package bench 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/google/cel-go/cel" 21 | ) 22 | 23 | func BenchmarkReferenceCases(b *testing.B) { 24 | stdenv, err := cel.NewEnv() 25 | if err != nil { 26 | b.Fatalf("cel.NewEnv() failed: %v", err) 27 | } 28 | RunReferenceCases(b, stdenv) 29 | } 30 | 31 | func BenchmarkReferenceCheckerCases(b *testing.B) { 32 | RunReferenceDynamicEnvCases(b) 33 | } 34 | -------------------------------------------------------------------------------- /test/compare.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package test 16 | 17 | import ( 18 | "fmt" 19 | "strings" 20 | ) 21 | 22 | // Compare compares two strings, a for actual, e for expected, and returns true or false. The comparison is done, 23 | // by filtering out whitespace (i.e. space, tabs and newline). 24 | func Compare(a string, e string) bool { 25 | return stripWhitespace(a) == stripWhitespace(e) 26 | } 27 | 28 | // DiffMessage creates a diff dump message for test failures. 29 | func DiffMessage(context string, actual interface{}, expected interface{}) string { 30 | return fmt.Sprintf("%s: \ngot %v, \nwanted %v", context, actual, expected) 31 | } 32 | 33 | func stripWhitespace(a string) string { 34 | a = strings.Replace(a, " ", "", -1) 35 | a = strings.Replace(a, "\n", "", -1) 36 | a = strings.Replace(a, "\t", "", -1) 37 | return strings.Replace(a, "\r", "", -1) 38 | } 39 | -------------------------------------------------------------------------------- /test/proto2pb/test_extensions.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package google.expr.proto2.test; 4 | 5 | option go_package = "github.com/google/cel-go/test/proto2pb"; 6 | 7 | import "google/protobuf/wrappers.proto"; 8 | import "test/proto2pb/test_all_types.proto"; 9 | 10 | // Package scoped extensions. 11 | extend ExampleType { 12 | optional ExampleType nested_example = 100; 13 | optional int32 int32_ext = 101; 14 | optional google.protobuf.Int32Value int32_wrapper_ext = 102; 15 | } 16 | 17 | // Message scoped extensions. 18 | message ExternalMessageType { 19 | extend ExampleType { 20 | optional int64 int64_ext = 201; 21 | } 22 | } -------------------------------------------------------------------------------- /test/proto3pb/test_import.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package google.expr.proto3.test; 4 | 5 | option go_package = "github.com/google/cel-go/test/proto3pb"; 6 | 7 | enum ImportedGlobalEnum { 8 | IMPORT_FOO = 0; 9 | IMPORT_BAR = 1; 10 | IMPORT_BAZ = 2; 11 | } 12 | -------------------------------------------------------------------------------- /tools/BUILD.bazel: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | licenses(["notice"]) # Apache 2.0 4 | 5 | exports_files(["LICENSE"]) 6 | -------------------------------------------------------------------------------- /tools/celtest/testdata/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2025 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "simple expression config" 16 | variables: 17 | - name: "i" 18 | type_name: "int" 19 | - name: "j" 20 | type_name: "int" 21 | - name: "a" 22 | type_name: "bool" 23 | -------------------------------------------------------------------------------- /tools/celtest/testdata/custom_policy.celpolicy: -------------------------------------------------------------------------------- 1 | # Copyright 2025 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: "custom_policy" 16 | variable_types: 17 | - variable_name: "variable1" 18 | variable_type: "int" 19 | - variable_name: "variable2" 20 | variable_type: "string" 21 | rule: 22 | match: 23 | - condition: | 24 | variable1 == 1 || variable2 == "known" 25 | output: "true" 26 | - output: "false" 27 | -------------------------------------------------------------------------------- /tools/celtest/testdata/custom_policy_tests.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2025 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | description: "Custom policy tests" 16 | section: 17 | - name: "output true" 18 | tests: 19 | - name: "variable 1 match" 20 | input: 21 | variable1: 22 | value: 1 23 | output: 24 | value: true 25 | - name: "variable 2 match" 26 | input: 27 | variable1: 28 | value: 2 29 | variable2: 30 | value: "known" 31 | output: 32 | value: true 33 | - name: "output false" 34 | tests: 35 | - name: "variable mismatch" 36 | input: 37 | variable1: 38 | value: 2 39 | variable2: 40 | value: "unknown" 41 | output: 42 | value: false 43 | -------------------------------------------------------------------------------- /tools/celtest/testdata/raw_expr.cel: -------------------------------------------------------------------------------- 1 | a || i + fn(j) == 42 -------------------------------------------------------------------------------- /tools/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/google/cel-go/tools 2 | 3 | go 1.23.0 4 | 5 | require ( 6 | cel.dev/expr v0.23.1 7 | github.com/bazelbuild/rules_go v0.54.0 8 | github.com/google/cel-go v0.22.0 9 | github.com/google/cel-go/policy v0.0.0-20250311174852-f5ea07b389a1 10 | github.com/google/go-cmp v0.6.0 11 | google.golang.org/genproto/googleapis/api v0.0.0-20250311190419-81fb87f6b8bf 12 | google.golang.org/protobuf v1.36.5 13 | gopkg.in/yaml.v3 v3.0.1 14 | ) 15 | 16 | require ( 17 | github.com/antlr4-go/antlr/v4 v4.13.1 // indirect 18 | github.com/stoewer/go-strcase v1.3.0 // indirect 19 | golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 // indirect 20 | golang.org/x/text v0.22.0 // indirect 21 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250311190419-81fb87f6b8bf // indirect 22 | ) 23 | 24 | replace github.com/google/cel-go => ../. 25 | -------------------------------------------------------------------------------- /vendor/cel.dev/expr/.bazelversion: -------------------------------------------------------------------------------- 1 | 7.3.2 2 | # Keep this pinned version in parity with cel-go 3 | -------------------------------------------------------------------------------- /vendor/cel.dev/expr/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pb.go linguist-generated=true 2 | *.pb.go -diff -merge 3 | -------------------------------------------------------------------------------- /vendor/cel.dev/expr/.gitignore: -------------------------------------------------------------------------------- 1 | bazel-* 2 | MODULE.bazel.lock 3 | -------------------------------------------------------------------------------- /vendor/cel.dev/expr/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | licenses(["notice"]) # Apache 2.0 6 | 7 | go_library( 8 | name = "expr", 9 | srcs = [ 10 | "checked.pb.go", 11 | "eval.pb.go", 12 | "explain.pb.go", 13 | "syntax.pb.go", 14 | "value.pb.go", 15 | ], 16 | importpath = "cel.dev/expr", 17 | visibility = ["//visibility:public"], 18 | deps = [ 19 | "@org_golang_google_genproto_googleapis_rpc//status:go_default_library", 20 | "@org_golang_google_protobuf//reflect/protoreflect", 21 | "@org_golang_google_protobuf//runtime/protoimpl", 22 | "@org_golang_google_protobuf//types/known/anypb", 23 | "@org_golang_google_protobuf//types/known/durationpb", 24 | "@org_golang_google_protobuf//types/known/emptypb", 25 | "@org_golang_google_protobuf//types/known/structpb", 26 | "@org_golang_google_protobuf//types/known/timestamppb", 27 | ], 28 | ) 29 | 30 | alias( 31 | name = "go_default_library", 32 | actual = ":expr", 33 | visibility = ["//visibility:public"], 34 | ) 35 | -------------------------------------------------------------------------------- /vendor/cel.dev/expr/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | ## Version 0.1.1 (adapted from 0.3b-angular) 3 | 4 | As contributors and maintainers of the Common Expression Language 5 | (CEL) project, we pledge to respect everyone who contributes by 6 | posting issues, updating documentation, submitting pull requests, 7 | providing feedback in comments, and any other activities. 8 | 9 | Communication through any of CEL's channels (GitHub, Gitter, IRC, 10 | mailing lists, Google+, Twitter, etc.) must be constructive and never 11 | resort to personal attacks, trolling, public or private harassment, 12 | insults, or other unprofessional conduct. 13 | 14 | We promise to extend courtesy and respect to everyone involved in this 15 | project regardless of gender, gender identity, sexual orientation, 16 | disability, age, race, ethnicity, religion, or level of experience. We 17 | expect anyone contributing to the project to do the same. 18 | 19 | If any member of the community violates this code of conduct, the 20 | maintainers of the CEL project may take action, removing issues, 21 | comments, and PRs or blocking accounts as deemed appropriate. 22 | 23 | If you are subject to or witness unacceptable behavior, or have any 24 | other concerns, please email us at 25 | [cel-conduct@google.com](mailto:cel-conduct@google.com). 26 | -------------------------------------------------------------------------------- /vendor/cel.dev/expr/MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | # CEL Language Council 2 | 3 | | Name | Company | Area of Expertise | 4 | |-----------------|--------------|-------------------| 5 | | Alfred Fuller | Facebook | cel-cpp, cel-spec | 6 | | Jim Larson | Google | cel-go, cel-spec | 7 | | Matthais Blume | Google | cel-spec | 8 | | Tristan Swadell | Google | cel-go, cel-spec | 9 | 10 | ## Emeritus 11 | 12 | * Sanjay Ghemawat (Google) 13 | * Wolfgang Grieskamp (Facebook) 14 | -------------------------------------------------------------------------------- /vendor/cel.dev/expr/WORKSPACE.bzlmod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/cel-go/c55aebf5346fcd5c06dc56fd6b817015fc008ee4/vendor/cel.dev/expr/WORKSPACE.bzlmod -------------------------------------------------------------------------------- /vendor/cel.dev/expr/cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: 'gcr.io/cloud-builders/bazel:7.3.2' 3 | entrypoint: bazel 4 | args: ['build', '...'] 5 | id: bazel-build 6 | waitFor: ['-'] 7 | timeout: 15m 8 | options: 9 | machineType: 'N1_HIGHCPU_32' 10 | -------------------------------------------------------------------------------- /vendor/cel.dev/expr/regen_go_proto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | bazel build //proto/cel/expr/conformance/... 3 | files=($(bazel aquery 'kind(proto, //proto/cel/expr/conformance/...)' | grep Outputs | grep "[.]pb[.]go" | sed 's/Outputs: \[//' | sed 's/\]//' | tr "," "\n")) 4 | for src in ${files[@]}; 5 | do 6 | dst=$(echo $src | sed 's/\(.*\/cel.dev\/expr\/\(.*\)\)/\2/') 7 | echo "copying $dst" 8 | $(cp $src $dst) 9 | done 10 | -------------------------------------------------------------------------------- /vendor/cel.dev/expr/regen_go_proto_canonical_protos.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | bazel build //proto/cel/expr:all 3 | 4 | rm -vf ./*.pb.go 5 | 6 | files=( $(bazel cquery //proto/cel/expr:expr_go_proto --output=starlark --starlark:expr="'\n'.join([f.path for f in target.output_groups.go_generated_srcs.to_list()])") ) 7 | for src in "${files[@]}"; 8 | do 9 | cp -v "${src}" ./ 10 | done 11 | -------------------------------------------------------------------------------- /vendor/github.com/antlr4-go/antlr/v4/.gitignore: -------------------------------------------------------------------------------- 1 | ### Go template 2 | 3 | # Binaries for programs and plugins 4 | *.exe 5 | *.exe~ 6 | *.dll 7 | *.so 8 | *.dylib 9 | 10 | # Test binary, built with `go test -c` 11 | *.test 12 | 13 | 14 | # Go workspace file 15 | go.work 16 | 17 | # No Goland stuff in this repo 18 | .idea 19 | -------------------------------------------------------------------------------- /vendor/github.com/antlr4-go/antlr/v4/atn_simulator.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. 2 | // Use of this file is governed by the BSD 3-clause license that 3 | // can be found in the LICENSE.txt file in the project root. 4 | 5 | package antlr 6 | 7 | var ATNSimulatorError = NewDFAState(0x7FFFFFFF, NewATNConfigSet(false)) 8 | 9 | type IATNSimulator interface { 10 | SharedContextCache() *PredictionContextCache 11 | ATN() *ATN 12 | DecisionToDFA() []*DFA 13 | } 14 | 15 | type BaseATNSimulator struct { 16 | atn *ATN 17 | sharedContextCache *PredictionContextCache 18 | decisionToDFA []*DFA 19 | } 20 | 21 | func (b *BaseATNSimulator) getCachedContext(context *PredictionContext) *PredictionContext { 22 | if b.sharedContextCache == nil { 23 | return context 24 | } 25 | 26 | //visited := NewJMap[*PredictionContext, *PredictionContext, Comparator[*PredictionContext]](pContextEqInst, PredictionVisitedCollection, "Visit map in getCachedContext()") 27 | visited := NewVisitRecord() 28 | return getCachedBasePredictionContext(context, b.sharedContextCache, visited) 29 | } 30 | 31 | func (b *BaseATNSimulator) SharedContextCache() *PredictionContextCache { 32 | return b.sharedContextCache 33 | } 34 | 35 | func (b *BaseATNSimulator) ATN() *ATN { 36 | return b.atn 37 | } 38 | 39 | func (b *BaseATNSimulator) DecisionToDFA() []*DFA { 40 | return b.decisionToDFA 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/antlr4-go/antlr/v4/atn_type.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. 2 | // Use of this file is governed by the BSD 3-clause license that 3 | // can be found in the LICENSE.txt file in the project root. 4 | 5 | package antlr 6 | 7 | // Represent the type of recognizer an ATN applies to. 8 | const ( 9 | ATNTypeLexer = 0 10 | ATNTypeParser = 1 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/antlr4-go/antlr/v4/char_stream.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. 2 | // Use of this file is governed by the BSD 3-clause license that 3 | // can be found in the LICENSE.txt file in the project root. 4 | 5 | package antlr 6 | 7 | type CharStream interface { 8 | IntStream 9 | GetText(int, int) string 10 | GetTextFromTokens(start, end Token) string 11 | GetTextFromInterval(Interval) string 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/antlr4-go/antlr/v4/file_stream.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. 2 | // Use of this file is governed by the BSD 3-clause license that 3 | // can be found in the LICENSE.txt file in the project root. 4 | 5 | package antlr 6 | 7 | import ( 8 | "bufio" 9 | "os" 10 | ) 11 | 12 | // This is an InputStream that is loaded from a file all at once 13 | // when you construct the object. 14 | 15 | type FileStream struct { 16 | InputStream 17 | filename string 18 | } 19 | 20 | //goland:noinspection GoUnusedExportedFunction 21 | func NewFileStream(fileName string) (*FileStream, error) { 22 | 23 | f, err := os.Open(fileName) 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | defer func(f *os.File) { 29 | errF := f.Close() 30 | if errF != nil { 31 | } 32 | }(f) 33 | 34 | reader := bufio.NewReader(f) 35 | fInfo, err := f.Stat() 36 | if err != nil { 37 | return nil, err 38 | } 39 | 40 | fs := &FileStream{ 41 | InputStream: InputStream{ 42 | index: 0, 43 | name: fileName, 44 | }, 45 | filename: fileName, 46 | } 47 | 48 | // Pre-build the buffer and read runes efficiently 49 | // 50 | fs.data = make([]rune, 0, fInfo.Size()) 51 | for { 52 | r, _, err := reader.ReadRune() 53 | if err != nil { 54 | break 55 | } 56 | fs.data = append(fs.data, r) 57 | } 58 | fs.size = len(fs.data) // Size in runes 59 | 60 | // All done. 61 | // 62 | return fs, nil 63 | } 64 | 65 | func (f *FileStream) GetSourceName() string { 66 | return f.filename 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/antlr4-go/antlr/v4/int_stream.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. 2 | // Use of this file is governed by the BSD 3-clause license that 3 | // can be found in the LICENSE.txt file in the project root. 4 | 5 | package antlr 6 | 7 | type IntStream interface { 8 | Consume() 9 | LA(int) int 10 | Mark() int 11 | Release(marker int) 12 | Index() int 13 | Seek(index int) 14 | Size() int 15 | GetSourceName() string 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/antlr4-go/antlr/v4/nostatistics.go: -------------------------------------------------------------------------------- 1 | //go:build !antlr.stats 2 | 3 | package antlr 4 | 5 | // This file is compiled when the build configuration antlr.stats is not enabled. 6 | // which then allows the compiler to optimize out all the code that is not used. 7 | const collectStats = false 8 | 9 | // goRunStats is a dummy struct used when build configuration antlr.stats is not enabled. 10 | type goRunStats struct { 11 | } 12 | 13 | var Statistics = &goRunStats{} 14 | 15 | func (s *goRunStats) AddJStatRec(_ *JStatRec) { 16 | // Do nothing - compiler will optimize this out (hopefully) 17 | } 18 | 19 | func (s *goRunStats) CollectionAnomalies() { 20 | // Do nothing - compiler will optimize this out (hopefully) 21 | } 22 | 23 | func (s *goRunStats) Reset() { 24 | // Do nothing - compiler will optimize this out (hopefully) 25 | } 26 | 27 | func (s *goRunStats) Report(dir string, prefix string) error { 28 | // Do nothing - compiler will optimize this out (hopefully) 29 | return nil 30 | } 31 | 32 | func (s *goRunStats) Analyze() { 33 | // Do nothing - compiler will optimize this out (hopefully) 34 | } 35 | 36 | type statsOption func(*goRunStats) error 37 | 38 | func (s *goRunStats) Configure(options ...statsOption) error { 39 | // Do nothing - compiler will optimize this out (hopefully) 40 | return nil 41 | } 42 | 43 | func WithTopN(topN int) statsOption { 44 | return func(s *goRunStats) error { 45 | return nil 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/antlr4-go/antlr/v4/stats_data.go: -------------------------------------------------------------------------------- 1 | package antlr 2 | 3 | // A JStatRec is a record of a particular use of a [JStore], [JMap] or JPCMap] collection. Typically, it will be 4 | // used to look for unused collections that wre allocated anyway, problems with hash bucket clashes, and anomalies 5 | // such as huge numbers of Gets with no entries found GetNoEnt. You can refer to the CollectionAnomalies() function 6 | // for ideas on what can be gleaned from these statistics about collections. 7 | type JStatRec struct { 8 | Source CollectionSource 9 | MaxSize int 10 | CurSize int 11 | Gets int 12 | GetHits int 13 | GetMisses int 14 | GetHashConflicts int 15 | GetNoEnt int 16 | Puts int 17 | PutHits int 18 | PutMisses int 19 | PutHashConflicts int 20 | MaxSlotSize int 21 | Description string 22 | CreateStack []byte 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/antlr4-go/antlr/v4/token_source.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. 2 | // Use of this file is governed by the BSD 3-clause license that 3 | // can be found in the LICENSE.txt file in the project root. 4 | 5 | package antlr 6 | 7 | type TokenSource interface { 8 | NextToken() Token 9 | Skip() 10 | More() 11 | GetLine() int 12 | GetCharPositionInLine() int 13 | GetInputStream() CharStream 14 | GetSourceName() string 15 | setTokenFactory(factory TokenFactory) 16 | GetTokenFactory() TokenFactory 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/antlr4-go/antlr/v4/token_stream.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. 2 | // Use of this file is governed by the BSD 3-clause license that 3 | // can be found in the LICENSE.txt file in the project root. 4 | 5 | package antlr 6 | 7 | type TokenStream interface { 8 | IntStream 9 | 10 | LT(k int) Token 11 | Reset() 12 | 13 | Get(index int) Token 14 | GetTokenSource() TokenSource 15 | SetTokenSource(TokenSource) 16 | 17 | GetAllText() string 18 | GetTextFromInterval(Interval) string 19 | GetTextFromRuleContext(RuleContext) string 20 | GetTextFromTokens(Token, Token) string 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/antlr4-go/antlr/v4/trace_listener.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. 2 | // Use of this file is governed by the BSD 3-clause license that 3 | // can be found in the LICENSE.txt file in the project root. 4 | 5 | package antlr 6 | 7 | import "fmt" 8 | 9 | type TraceListener struct { 10 | parser *BaseParser 11 | } 12 | 13 | func NewTraceListener(parser *BaseParser) *TraceListener { 14 | tl := new(TraceListener) 15 | tl.parser = parser 16 | return tl 17 | } 18 | 19 | func (t *TraceListener) VisitErrorNode(_ ErrorNode) { 20 | } 21 | 22 | func (t *TraceListener) EnterEveryRule(ctx ParserRuleContext) { 23 | fmt.Println("enter " + t.parser.GetRuleNames()[ctx.GetRuleIndex()] + ", LT(1)=" + t.parser.input.LT(1).GetText()) 24 | } 25 | 26 | func (t *TraceListener) VisitTerminal(node TerminalNode) { 27 | fmt.Println("consume " + fmt.Sprint(node.GetSymbol()) + " rule " + t.parser.GetRuleNames()[t.parser.ctx.GetRuleIndex()]) 28 | } 29 | 30 | func (t *TraceListener) ExitEveryRule(ctx ParserRuleContext) { 31 | fmt.Println("exit " + t.parser.GetRuleNames()[ctx.GetRuleIndex()] + ", LT(1)=" + t.parser.input.LT(1).GetText()) 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/stoewer/go-strcase/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | vendor 8 | doc 9 | 10 | # Temporary files 11 | *~ 12 | *.swp 13 | 14 | # Editor and IDE config 15 | .idea 16 | *.iml 17 | .vscode 18 | -------------------------------------------------------------------------------- /vendor/github.com/stoewer/go-strcase/.golangci.yml: -------------------------------------------------------------------------------- 1 | run: 2 | deadline: 10m 3 | 4 | linters: 5 | enable: 6 | - dupl 7 | - goconst 8 | - gocyclo 9 | - godox 10 | - gosec 11 | - interfacer 12 | - lll 13 | - maligned 14 | - misspell 15 | - prealloc 16 | - stylecheck 17 | - unconvert 18 | - unparam 19 | - errcheck 20 | - golint 21 | - gofmt 22 | disable: [] 23 | fast: false 24 | 25 | issues: 26 | exclude-use-default: false 27 | -------------------------------------------------------------------------------- /vendor/github.com/stoewer/go-strcase/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017, Adrian Stoewer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/stoewer/go-strcase/camel.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, A. Stoewer 2 | // All rights reserved. 3 | 4 | package strcase 5 | 6 | import ( 7 | "strings" 8 | ) 9 | 10 | // UpperCamelCase converts a string into camel case starting with a upper case letter. 11 | func UpperCamelCase(s string) string { 12 | return camelCase(s, true) 13 | } 14 | 15 | // LowerCamelCase converts a string into camel case starting with a lower case letter. 16 | func LowerCamelCase(s string) string { 17 | return camelCase(s, false) 18 | } 19 | 20 | func camelCase(s string, upper bool) string { 21 | s = strings.TrimSpace(s) 22 | buffer := make([]rune, 0, len(s)) 23 | 24 | stringIter(s, func(prev, curr, next rune) { 25 | if !isDelimiter(curr) { 26 | if isDelimiter(prev) || (upper && prev == 0) { 27 | buffer = append(buffer, toUpper(curr)) 28 | } else if isLower(prev) { 29 | buffer = append(buffer, curr) 30 | } else { 31 | buffer = append(buffer, toLower(curr)) 32 | } 33 | } 34 | }) 35 | 36 | return string(buffer) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/stoewer/go-strcase/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, A. Stoewer 2 | // All rights reserved. 3 | 4 | // Package strcase converts between different kinds of naming formats such as camel case 5 | // (CamelCase), snake case (snake_case) or kebab case (kebab-case). The package is designed 6 | // to work only with strings consisting of standard ASCII letters. Unicode is currently not 7 | // supported. 8 | package strcase 9 | -------------------------------------------------------------------------------- /vendor/github.com/stoewer/go-strcase/kebab.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, A. Stoewer 2 | // All rights reserved. 3 | 4 | package strcase 5 | 6 | // KebabCase converts a string into kebab case. 7 | func KebabCase(s string) string { 8 | return delimiterCase(s, '-', false) 9 | } 10 | 11 | // UpperKebabCase converts a string into kebab case with capital letters. 12 | func UpperKebabCase(s string) string { 13 | return delimiterCase(s, '-', true) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/exp/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/format/format.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package format contains types for defining language-specific formatting of 6 | // values. 7 | // 8 | // This package is internal now, but will eventually be exposed after the API 9 | // settles. 10 | package format // import "golang.org/x/text/internal/format" 11 | 12 | import ( 13 | "fmt" 14 | 15 | "golang.org/x/text/language" 16 | ) 17 | 18 | // State represents the printer state passed to custom formatters. It provides 19 | // access to the fmt.State interface and the sentence and language-related 20 | // context. 21 | type State interface { 22 | fmt.State 23 | 24 | // Language reports the requested language in which to render a message. 25 | Language() language.Tag 26 | 27 | // TODO: consider this and removing rune from the Format method in the 28 | // Formatter interface. 29 | // 30 | // Verb returns the format variant to render, analogous to the types used 31 | // in fmt. Use 'v' for the default or only variant. 32 | // Verb() rune 33 | 34 | // TODO: more info: 35 | // - sentence context such as linguistic features passed by the translator. 36 | } 37 | 38 | // Formatter is analogous to fmt.Formatter. 39 | type Formatter interface { 40 | Format(state State, verb rune) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package internal contains non-exported functionality that are used by 6 | // packages in the text repository. 7 | package internal // import "golang.org/x/text/internal" 8 | 9 | import ( 10 | "sort" 11 | 12 | "golang.org/x/text/language" 13 | ) 14 | 15 | // SortTags sorts tags in place. 16 | func SortTags(tags []language.Tag) { 17 | sort.Sort(sorter(tags)) 18 | } 19 | 20 | type sorter []language.Tag 21 | 22 | func (s sorter) Len() int { 23 | return len(s) 24 | } 25 | 26 | func (s sorter) Swap(i, j int) { 27 | s[i], s[j] = s[j], s[i] 28 | } 29 | 30 | func (s sorter) Less(i, j int) bool { 31 | return s[i].String() < s[j].String() 32 | } 33 | 34 | // UniqueTags sorts and filters duplicate tags in place and returns a slice with 35 | // only unique tags. 36 | func UniqueTags(tags []language.Tag) []language.Tag { 37 | if len(tags) <= 1 { 38 | return tags 39 | } 40 | SortTags(tags) 41 | k := 0 42 | for i := 1; i < len(tags); i++ { 43 | if tags[k].String() < tags[i].String() { 44 | k++ 45 | tags[k] = tags[i] 46 | } 47 | } 48 | return tags[:k+1] 49 | } 50 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/language/common.go: -------------------------------------------------------------------------------- 1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. 2 | 3 | package language 4 | 5 | // This file contains code common to the maketables.go and the package code. 6 | 7 | // AliasType is the type of an alias in AliasMap. 8 | type AliasType int8 9 | 10 | const ( 11 | Deprecated AliasType = iota 12 | Macro 13 | Legacy 14 | 15 | AliasTypeUnknown AliasType = -1 16 | ) 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/language/compact.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package language 6 | 7 | // CompactCoreInfo is a compact integer with the three core tags encoded. 8 | type CompactCoreInfo uint32 9 | 10 | // GetCompactCore generates a uint32 value that is guaranteed to be unique for 11 | // different language, region, and script values. 12 | func GetCompactCore(t Tag) (cci CompactCoreInfo, ok bool) { 13 | if t.LangID > langNoIndexOffset { 14 | return 0, false 15 | } 16 | cci |= CompactCoreInfo(t.LangID) << (8 + 12) 17 | cci |= CompactCoreInfo(t.ScriptID) << 12 18 | cci |= CompactCoreInfo(t.RegionID) 19 | return cci, true 20 | } 21 | 22 | // Tag generates a tag from c. 23 | func (c CompactCoreInfo) Tag() Tag { 24 | return Tag{ 25 | LangID: Language(c >> 20), 26 | RegionID: Region(c & 0x3ff), 27 | ScriptID: Script(c>>12) & 0xff, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/language/coverage.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package language 6 | 7 | // BaseLanguages returns the list of all supported base languages. It generates 8 | // the list by traversing the internal structures. 9 | func BaseLanguages() []Language { 10 | base := make([]Language, 0, NumLanguages) 11 | for i := 0; i < langNoIndexOffset; i++ { 12 | // We included "und" already for the value 0. 13 | if i != nonCanonicalUnd { 14 | base = append(base, Language(i)) 15 | } 16 | } 17 | i := langNoIndexOffset 18 | for _, v := range langNoIndex { 19 | for k := 0; k < 8; k++ { 20 | if v&1 == 1 { 21 | base = append(base, Language(i)) 22 | } 23 | v >>= 1 24 | i++ 25 | } 26 | } 27 | return base 28 | } 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/language/tags.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package language 6 | 7 | // MustParse is like Parse, but panics if the given BCP 47 tag cannot be parsed. 8 | // It simplifies safe initialization of Tag values. 9 | func MustParse(s string) Tag { 10 | t, err := Parse(s) 11 | if err != nil { 12 | panic(err) 13 | } 14 | return t 15 | } 16 | 17 | // MustParseBase is like ParseBase, but panics if the given base cannot be parsed. 18 | // It simplifies safe initialization of Base values. 19 | func MustParseBase(s string) Language { 20 | b, err := ParseBase(s) 21 | if err != nil { 22 | panic(err) 23 | } 24 | return b 25 | } 26 | 27 | // MustParseScript is like ParseScript, but panics if the given script cannot be 28 | // parsed. It simplifies safe initialization of Script values. 29 | func MustParseScript(s string) Script { 30 | scr, err := ParseScript(s) 31 | if err != nil { 32 | panic(err) 33 | } 34 | return scr 35 | } 36 | 37 | // MustParseRegion is like ParseRegion, but panics if the given region cannot be 38 | // parsed. It simplifies safe initialization of Region values. 39 | func MustParseRegion(s string) Region { 40 | r, err := ParseRegion(s) 41 | if err != nil { 42 | panic(err) 43 | } 44 | return r 45 | } 46 | 47 | // Und is the root language. 48 | var Und Tag 49 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/number/roundingmode_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type RoundingMode"; DO NOT EDIT. 2 | 3 | package number 4 | 5 | import "strconv" 6 | 7 | func _() { 8 | // An "invalid array index" compiler error signifies that the constant values have changed. 9 | // Re-run the stringer command to generate them again. 10 | var x [1]struct{} 11 | _ = x[ToNearestEven-0] 12 | _ = x[ToNearestZero-1] 13 | _ = x[ToNearestAway-2] 14 | _ = x[ToPositiveInf-3] 15 | _ = x[ToNegativeInf-4] 16 | _ = x[ToZero-5] 17 | _ = x[AwayFromZero-6] 18 | _ = x[numModes-7] 19 | } 20 | 21 | const _RoundingMode_name = "ToNearestEvenToNearestZeroToNearestAwayToPositiveInfToNegativeInfToZeroAwayFromZeronumModes" 22 | 23 | var _RoundingMode_index = [...]uint8{0, 13, 26, 39, 52, 65, 71, 83, 91} 24 | 25 | func (i RoundingMode) String() string { 26 | if i >= RoundingMode(len(_RoundingMode_index)-1) { 27 | return "RoundingMode(" + strconv.FormatInt(int64(i), 10) + ")" 28 | } 29 | return _RoundingMode_name[_RoundingMode_index[i]:_RoundingMode_index[i+1]] 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/message/catalog.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package message 6 | 7 | // TODO: some types in this file will need to be made public at some time. 8 | // Documentation and method names will reflect this by using the exported name. 9 | 10 | import ( 11 | "golang.org/x/text/language" 12 | "golang.org/x/text/message/catalog" 13 | ) 14 | 15 | // MatchLanguage reports the matched tag obtained from language.MatchStrings for 16 | // the Matcher of the DefaultCatalog. 17 | func MatchLanguage(preferred ...string) language.Tag { 18 | c := DefaultCatalog 19 | tag, _ := language.MatchStrings(c.Matcher(), preferred...) 20 | return tag 21 | } 22 | 23 | // DefaultCatalog is used by SetString. 24 | var DefaultCatalog catalog.Catalog = defaultCatalog 25 | 26 | var defaultCatalog = catalog.NewBuilder() 27 | 28 | // SetString calls SetString on the initial default Catalog. 29 | func SetString(tag language.Tag, key string, msg string) error { 30 | return defaultCatalog.SetString(tag, key, msg) 31 | } 32 | 33 | // Set calls Set on the initial default Catalog. 34 | func Set(tag language.Tag, key string, msg ...catalog.Message) error { 35 | return defaultCatalog.Set(tag, key, msg...) 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/message/catalog/go19.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build go1.9 6 | 7 | package catalog 8 | 9 | import "golang.org/x/text/internal/catmsg" 10 | 11 | // A Message holds a collection of translations for the same phrase that may 12 | // vary based on the values of substitution arguments. 13 | type Message = catmsg.Message 14 | 15 | type firstInSequence = catmsg.FirstOf 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/message/catalog/gopre19.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !go1.9 6 | 7 | package catalog 8 | 9 | import "golang.org/x/text/internal/catmsg" 10 | 11 | // A Message holds a collection of translations for the same phrase that may 12 | // vary based on the values of substitution arguments. 13 | type Message interface { 14 | catmsg.Message 15 | } 16 | 17 | func firstInSequence(m []Message) catmsg.Message { 18 | a := []catmsg.Message{} 19 | for _, m := range m { 20 | a = append(a, m) 21 | } 22 | return catmsg.FirstOf(a) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/encoding/protojson/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package protojson marshals and unmarshals protocol buffer messages as JSON 6 | // format. It follows the guide at 7 | // https://protobuf.dev/programming-guides/proto3#json. 8 | // 9 | // This package produces a different output than the standard [encoding/json] 10 | // package, which does not operate correctly on protocol buffer messages. 11 | package protojson 12 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/encoding/prototext/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package prototext marshals and unmarshals protocol buffer messages as the 6 | // textproto format. 7 | package prototext 8 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/descopts/options.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package descopts contains the nil pointers to concrete descriptor options. 6 | // 7 | // This package exists as a form of reverse dependency injection so that certain 8 | // packages (e.g., internal/filedesc and internal/filetype can avoid a direct 9 | // dependency on the descriptor proto package). 10 | package descopts 11 | 12 | import pref "google.golang.org/protobuf/reflect/protoreflect" 13 | 14 | // These variables are set by the init function in descriptor.pb.go via logic 15 | // in internal/filetype. In other words, so long as the descriptor proto package 16 | // is linked in, these variables will be populated. 17 | // 18 | // Each variable is populated with a nil pointer to the options struct. 19 | var ( 20 | File pref.ProtoMessage 21 | Enum pref.ProtoMessage 22 | EnumValue pref.ProtoMessage 23 | Message pref.ProtoMessage 24 | Field pref.ProtoMessage 25 | Oneof pref.ProtoMessage 26 | ExtensionRange pref.ProtoMessage 27 | Service pref.ProtoMessage 28 | Method pref.ProtoMessage 29 | ) 30 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/editiondefaults/defaults.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package editiondefaults contains the binary representation of the editions 6 | // defaults. 7 | package editiondefaults 8 | 9 | import _ "embed" 10 | 11 | //go:embed editions_defaults.binpb 12 | var Defaults []byte 13 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/cel-go/c55aebf5346fcd5c06dc56fd6b817015fc008ee4/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/editionssupport/editions.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package editionssupport defines constants for editions that are supported. 6 | package editionssupport 7 | 8 | import descriptorpb "google.golang.org/protobuf/types/descriptorpb" 9 | 10 | const ( 11 | Minimum = descriptorpb.Edition_EDITION_PROTO2 12 | Maximum = descriptorpb.Edition_EDITION_2023 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/errors/is_go112.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !go1.13 6 | // +build !go1.13 7 | 8 | package errors 9 | 10 | import "reflect" 11 | 12 | // Is is a copy of Go 1.13's errors.Is for use with older Go versions. 13 | func Is(err, target error) bool { 14 | if target == nil { 15 | return err == target 16 | } 17 | 18 | isComparable := reflect.TypeOf(target).Comparable() 19 | for { 20 | if isComparable && err == target { 21 | return true 22 | } 23 | if x, ok := err.(interface{ Is(error) bool }); ok && x.Is(target) { 24 | return true 25 | } 26 | if err = unwrap(err); err == nil { 27 | return false 28 | } 29 | } 30 | } 31 | 32 | func unwrap(err error) error { 33 | u, ok := err.(interface { 34 | Unwrap() error 35 | }) 36 | if !ok { 37 | return nil 38 | } 39 | return u.Unwrap() 40 | } 41 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/errors/is_go113.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build go1.13 6 | // +build go1.13 7 | 8 | package errors 9 | 10 | import "errors" 11 | 12 | // Is is errors.Is. 13 | func Is(err, target error) bool { return errors.Is(err, target) } 14 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/flags/flags.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package flags provides a set of flags controlled by build tags. 6 | package flags 7 | 8 | // ProtoLegacy specifies whether to enable support for legacy functionality 9 | // such as MessageSets, weak fields, and various other obscure behavior 10 | // that is necessary to maintain backwards compatibility with proto1 or 11 | // the pre-release variants of proto2 and proto3. 12 | // 13 | // This is disabled by default unless built with the "protolegacy" tag. 14 | // 15 | // WARNING: The compatibility agreement covers nothing provided by this flag. 16 | // As such, functionality may suddenly be removed or changed at our discretion. 17 | const ProtoLegacy = protoLegacy 18 | 19 | // LazyUnmarshalExtensions specifies whether to lazily unmarshal extensions. 20 | // 21 | // Lazy extension unmarshaling validates the contents of message-valued 22 | // extension fields at unmarshal time, but defers creating the message 23 | // structure until the extension is first accessed. 24 | const LazyUnmarshalExtensions = ProtoLegacy 25 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/flags/proto_legacy_disable.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !protolegacy 6 | // +build !protolegacy 7 | 8 | package flags 9 | 10 | const protoLegacy = false 11 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/flags/proto_legacy_enable.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build protolegacy 6 | // +build protolegacy 7 | 8 | package flags 9 | 10 | const protoLegacy = true 11 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/genid/any_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-protos. DO NOT EDIT. 6 | 7 | package genid 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | const File_google_protobuf_any_proto = "google/protobuf/any.proto" 14 | 15 | // Names for google.protobuf.Any. 16 | const ( 17 | Any_message_name protoreflect.Name = "Any" 18 | Any_message_fullname protoreflect.FullName = "google.protobuf.Any" 19 | ) 20 | 21 | // Field names for google.protobuf.Any. 22 | const ( 23 | Any_TypeUrl_field_name protoreflect.Name = "type_url" 24 | Any_Value_field_name protoreflect.Name = "value" 25 | 26 | Any_TypeUrl_field_fullname protoreflect.FullName = "google.protobuf.Any.type_url" 27 | Any_Value_field_fullname protoreflect.FullName = "google.protobuf.Any.value" 28 | ) 29 | 30 | // Field numbers for google.protobuf.Any. 31 | const ( 32 | Any_TypeUrl_field_number protoreflect.FieldNumber = 1 33 | Any_Value_field_number protoreflect.FieldNumber = 2 34 | ) 35 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/genid/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package genid contains constants for declarations in descriptor.proto 6 | // and the well-known types. 7 | package genid 8 | 9 | import protoreflect "google.golang.org/protobuf/reflect/protoreflect" 10 | 11 | const GoogleProtobuf_package protoreflect.FullName = "google.protobuf" 12 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/genid/duration_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-protos. DO NOT EDIT. 6 | 7 | package genid 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | const File_google_protobuf_duration_proto = "google/protobuf/duration.proto" 14 | 15 | // Names for google.protobuf.Duration. 16 | const ( 17 | Duration_message_name protoreflect.Name = "Duration" 18 | Duration_message_fullname protoreflect.FullName = "google.protobuf.Duration" 19 | ) 20 | 21 | // Field names for google.protobuf.Duration. 22 | const ( 23 | Duration_Seconds_field_name protoreflect.Name = "seconds" 24 | Duration_Nanos_field_name protoreflect.Name = "nanos" 25 | 26 | Duration_Seconds_field_fullname protoreflect.FullName = "google.protobuf.Duration.seconds" 27 | Duration_Nanos_field_fullname protoreflect.FullName = "google.protobuf.Duration.nanos" 28 | ) 29 | 30 | // Field numbers for google.protobuf.Duration. 31 | const ( 32 | Duration_Seconds_field_number protoreflect.FieldNumber = 1 33 | Duration_Nanos_field_number protoreflect.FieldNumber = 2 34 | ) 35 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/genid/empty_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-protos. DO NOT EDIT. 6 | 7 | package genid 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | const File_google_protobuf_empty_proto = "google/protobuf/empty.proto" 14 | 15 | // Names for google.protobuf.Empty. 16 | const ( 17 | Empty_message_name protoreflect.Name = "Empty" 18 | Empty_message_fullname protoreflect.FullName = "google.protobuf.Empty" 19 | ) 20 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/genid/field_mask_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-protos. DO NOT EDIT. 6 | 7 | package genid 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | const File_google_protobuf_field_mask_proto = "google/protobuf/field_mask.proto" 14 | 15 | // Names for google.protobuf.FieldMask. 16 | const ( 17 | FieldMask_message_name protoreflect.Name = "FieldMask" 18 | FieldMask_message_fullname protoreflect.FullName = "google.protobuf.FieldMask" 19 | ) 20 | 21 | // Field names for google.protobuf.FieldMask. 22 | const ( 23 | FieldMask_Paths_field_name protoreflect.Name = "paths" 24 | 25 | FieldMask_Paths_field_fullname protoreflect.FullName = "google.protobuf.FieldMask.paths" 26 | ) 27 | 28 | // Field numbers for google.protobuf.FieldMask. 29 | const ( 30 | FieldMask_Paths_field_number protoreflect.FieldNumber = 1 31 | ) 32 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/genid/go_features_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-protos. DO NOT EDIT. 6 | 7 | package genid 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | const File_google_protobuf_go_features_proto = "google/protobuf/go_features.proto" 14 | 15 | // Names for google.protobuf.GoFeatures. 16 | const ( 17 | GoFeatures_message_name protoreflect.Name = "GoFeatures" 18 | GoFeatures_message_fullname protoreflect.FullName = "google.protobuf.GoFeatures" 19 | ) 20 | 21 | // Field names for google.protobuf.GoFeatures. 22 | const ( 23 | GoFeatures_LegacyUnmarshalJsonEnum_field_name protoreflect.Name = "legacy_unmarshal_json_enum" 24 | 25 | GoFeatures_LegacyUnmarshalJsonEnum_field_fullname protoreflect.FullName = "google.protobuf.GoFeatures.legacy_unmarshal_json_enum" 26 | ) 27 | 28 | // Field numbers for google.protobuf.GoFeatures. 29 | const ( 30 | GoFeatures_LegacyUnmarshalJsonEnum_field_number protoreflect.FieldNumber = 1 31 | ) 32 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/genid/goname.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package genid 6 | 7 | // Go names of implementation-specific struct fields in generated messages. 8 | const ( 9 | State_goname = "state" 10 | 11 | SizeCache_goname = "sizeCache" 12 | SizeCacheA_goname = "XXX_sizecache" 13 | 14 | WeakFields_goname = "weakFields" 15 | WeakFieldsA_goname = "XXX_weak" 16 | 17 | UnknownFields_goname = "unknownFields" 18 | UnknownFieldsA_goname = "XXX_unrecognized" 19 | 20 | ExtensionFields_goname = "extensionFields" 21 | ExtensionFieldsA_goname = "XXX_InternalExtensions" 22 | ExtensionFieldsB_goname = "XXX_extensions" 23 | 24 | WeakFieldPrefix_goname = "XXX_weak_" 25 | ) 26 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/genid/map_entry.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package genid 6 | 7 | import protoreflect "google.golang.org/protobuf/reflect/protoreflect" 8 | 9 | // Generic field names and numbers for synthetic map entry messages. 10 | const ( 11 | MapEntry_Key_field_name protoreflect.Name = "key" 12 | MapEntry_Value_field_name protoreflect.Name = "value" 13 | 14 | MapEntry_Key_field_number protoreflect.FieldNumber = 1 15 | MapEntry_Value_field_number protoreflect.FieldNumber = 2 16 | ) 17 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/genid/source_context_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-protos. DO NOT EDIT. 6 | 7 | package genid 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | const File_google_protobuf_source_context_proto = "google/protobuf/source_context.proto" 14 | 15 | // Names for google.protobuf.SourceContext. 16 | const ( 17 | SourceContext_message_name protoreflect.Name = "SourceContext" 18 | SourceContext_message_fullname protoreflect.FullName = "google.protobuf.SourceContext" 19 | ) 20 | 21 | // Field names for google.protobuf.SourceContext. 22 | const ( 23 | SourceContext_FileName_field_name protoreflect.Name = "file_name" 24 | 25 | SourceContext_FileName_field_fullname protoreflect.FullName = "google.protobuf.SourceContext.file_name" 26 | ) 27 | 28 | // Field numbers for google.protobuf.SourceContext. 29 | const ( 30 | SourceContext_FileName_field_number protoreflect.FieldNumber = 1 31 | ) 32 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/genid/timestamp_gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Code generated by generate-protos. DO NOT EDIT. 6 | 7 | package genid 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | const File_google_protobuf_timestamp_proto = "google/protobuf/timestamp.proto" 14 | 15 | // Names for google.protobuf.Timestamp. 16 | const ( 17 | Timestamp_message_name protoreflect.Name = "Timestamp" 18 | Timestamp_message_fullname protoreflect.FullName = "google.protobuf.Timestamp" 19 | ) 20 | 21 | // Field names for google.protobuf.Timestamp. 22 | const ( 23 | Timestamp_Seconds_field_name protoreflect.Name = "seconds" 24 | Timestamp_Nanos_field_name protoreflect.Name = "nanos" 25 | 26 | Timestamp_Seconds_field_fullname protoreflect.FullName = "google.protobuf.Timestamp.seconds" 27 | Timestamp_Nanos_field_fullname protoreflect.FullName = "google.protobuf.Timestamp.nanos" 28 | ) 29 | 30 | // Field numbers for google.protobuf.Timestamp. 31 | const ( 32 | Timestamp_Seconds_field_number protoreflect.FieldNumber = 1 33 | Timestamp_Nanos_field_number protoreflect.FieldNumber = 2 34 | ) 35 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/genid/wrappers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package genid 6 | 7 | import protoreflect "google.golang.org/protobuf/reflect/protoreflect" 8 | 9 | // Generic field name and number for messages in wrappers.proto. 10 | const ( 11 | WrapperValue_Value_field_name protoreflect.Name = "value" 12 | WrapperValue_Value_field_number protoreflect.FieldNumber = 1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/impl/codec_map_go111.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !go1.12 6 | // +build !go1.12 7 | 8 | package impl 9 | 10 | import "reflect" 11 | 12 | type mapIter struct { 13 | v reflect.Value 14 | keys []reflect.Value 15 | } 16 | 17 | // mapRange provides a less-efficient equivalent to 18 | // the Go 1.12 reflect.Value.MapRange method. 19 | func mapRange(v reflect.Value) *mapIter { 20 | return &mapIter{v: v} 21 | } 22 | 23 | func (i *mapIter) Next() bool { 24 | if i.keys == nil { 25 | i.keys = i.v.MapKeys() 26 | } else { 27 | i.keys = i.keys[1:] 28 | } 29 | return len(i.keys) > 0 30 | } 31 | 32 | func (i *mapIter) Key() reflect.Value { 33 | return i.keys[0] 34 | } 35 | 36 | func (i *mapIter) Value() reflect.Value { 37 | return i.v.MapIndex(i.keys[0]) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/impl/codec_map_go112.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build go1.12 6 | // +build go1.12 7 | 8 | package impl 9 | 10 | import "reflect" 11 | 12 | func mapRange(v reflect.Value) *reflect.MapIter { return v.MapRange() } 13 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/impl/codec_unsafe.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !purego && !appengine 6 | // +build !purego,!appengine 7 | 8 | package impl 9 | 10 | // When using unsafe pointers, we can just treat enum values as int32s. 11 | 12 | var ( 13 | coderEnumNoZero = coderInt32NoZero 14 | coderEnum = coderInt32 15 | coderEnumPtr = coderInt32Ptr 16 | coderEnumSlice = coderInt32Slice 17 | coderEnumPackedSlice = coderInt32PackedSlice 18 | ) 19 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/impl/enum.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package impl 6 | 7 | import ( 8 | "reflect" 9 | 10 | "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | type EnumInfo struct { 14 | GoReflectType reflect.Type // int32 kind 15 | Desc protoreflect.EnumDescriptor 16 | } 17 | 18 | func (t *EnumInfo) New(n protoreflect.EnumNumber) protoreflect.Enum { 19 | return reflect.ValueOf(n).Convert(t.GoReflectType).Interface().(protoreflect.Enum) 20 | } 21 | func (t *EnumInfo) Descriptor() protoreflect.EnumDescriptor { return t.Desc } 22 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/pragma/pragma.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package pragma provides types that can be embedded into a struct to 6 | // statically enforce or prevent certain language properties. 7 | package pragma 8 | 9 | import "sync" 10 | 11 | // NoUnkeyedLiterals can be embedded in a struct to prevent unkeyed literals. 12 | type NoUnkeyedLiterals struct{} 13 | 14 | // DoNotImplement can be embedded in an interface to prevent trivial 15 | // implementations of the interface. 16 | // 17 | // This is useful to prevent unauthorized implementations of an interface 18 | // so that it can be extended in the future for any protobuf language changes. 19 | type DoNotImplement interface{ ProtoInternal(DoNotImplement) } 20 | 21 | // DoNotCompare can be embedded in a struct to prevent comparability. 22 | type DoNotCompare [0]func() 23 | 24 | // DoNotCopy can be embedded in a struct to help prevent shallow copies. 25 | // This does not rely on a Go language feature, but rather a special case 26 | // within the vet checker. 27 | // 28 | // See https://golang.org/issues/8005. 29 | type DoNotCopy [0]sync.Mutex 30 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/set/ints.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package set provides simple set data structures for uint64s. 6 | package set 7 | 8 | import "math/bits" 9 | 10 | // int64s represents a set of integers within the range of 0..63. 11 | type int64s uint64 12 | 13 | func (bs *int64s) Len() int { 14 | return bits.OnesCount64(uint64(*bs)) 15 | } 16 | func (bs *int64s) Has(n uint64) bool { 17 | return uint64(*bs)&(uint64(1)< 0 18 | } 19 | func (bs *int64s) Set(n uint64) { 20 | *(*uint64)(bs) |= uint64(1) << n 21 | } 22 | func (bs *int64s) Clear(n uint64) { 23 | *(*uint64)(bs) &^= uint64(1) << n 24 | } 25 | 26 | // Ints represents a set of integers within the range of 0..math.MaxUint64. 27 | type Ints struct { 28 | lo int64s 29 | hi map[uint64]struct{} 30 | } 31 | 32 | func (bs *Ints) Len() int { 33 | return bs.lo.Len() + len(bs.hi) 34 | } 35 | func (bs *Ints) Has(n uint64) bool { 36 | if n < 64 { 37 | return bs.lo.Has(n) 38 | } 39 | _, ok := bs.hi[n] 40 | return ok 41 | } 42 | func (bs *Ints) Set(n uint64) { 43 | if n < 64 { 44 | bs.lo.Set(n) 45 | return 46 | } 47 | if bs.hi == nil { 48 | bs.hi = make(map[uint64]struct{}) 49 | } 50 | bs.hi[n] = struct{}{} 51 | } 52 | func (bs *Ints) Clear(n uint64) { 53 | if n < 64 { 54 | bs.lo.Clear(n) 55 | return 56 | } 57 | delete(bs.hi, n) 58 | } 59 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/internal/strs/strings_pure.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build purego || appengine 6 | // +build purego appengine 7 | 8 | package strs 9 | 10 | import pref "google.golang.org/protobuf/reflect/protoreflect" 11 | 12 | func UnsafeString(b []byte) string { 13 | return string(b) 14 | } 15 | 16 | func UnsafeBytes(s string) []byte { 17 | return []byte(s) 18 | } 19 | 20 | type Builder struct{} 21 | 22 | func (*Builder) AppendFullName(prefix pref.FullName, name pref.Name) pref.FullName { 23 | return prefix.Append(name) 24 | } 25 | 26 | func (*Builder) MakeString(b []byte) string { 27 | return string(b) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/proto/proto_methods.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // The protoreflect build tag disables use of fast-path methods. 6 | //go:build !protoreflect 7 | // +build !protoreflect 8 | 9 | package proto 10 | 11 | import ( 12 | "google.golang.org/protobuf/reflect/protoreflect" 13 | "google.golang.org/protobuf/runtime/protoiface" 14 | ) 15 | 16 | const hasProtoMethods = true 17 | 18 | func protoMethods(m protoreflect.Message) *protoiface.Methods { 19 | return m.ProtoMethods() 20 | } 21 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/proto/proto_reflect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // The protoreflect build tag disables use of fast-path methods. 6 | //go:build protoreflect 7 | // +build protoreflect 8 | 9 | package proto 10 | 11 | import ( 12 | "google.golang.org/protobuf/reflect/protoreflect" 13 | "google.golang.org/protobuf/runtime/protoiface" 14 | ) 15 | 16 | const hasProtoMethods = false 17 | 18 | func protoMethods(m protoreflect.Message) *protoiface.Methods { 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/proto/reset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package proto 6 | 7 | import ( 8 | "fmt" 9 | 10 | "google.golang.org/protobuf/reflect/protoreflect" 11 | ) 12 | 13 | // Reset clears every field in the message. 14 | // The resulting message shares no observable memory with its previous state 15 | // other than the memory for the message itself. 16 | func Reset(m Message) { 17 | if mr, ok := m.(interface{ Reset() }); ok && hasProtoMethods { 18 | mr.Reset() 19 | return 20 | } 21 | resetMessage(m.ProtoReflect()) 22 | } 23 | 24 | func resetMessage(m protoreflect.Message) { 25 | if !m.IsValid() { 26 | panic(fmt.Sprintf("cannot reset invalid %v message", m.Descriptor().FullName())) 27 | } 28 | 29 | // Clear all known fields. 30 | fds := m.Descriptor().Fields() 31 | for i := 0; i < fds.Len(); i++ { 32 | m.Clear(fds.Get(i)) 33 | } 34 | 35 | // Clear extension fields. 36 | m.Range(func(fd protoreflect.FieldDescriptor, _ protoreflect.Value) bool { 37 | m.Clear(fd) 38 | return true 39 | }) 40 | 41 | // Clear unknown fields. 42 | m.SetUnknown(nil) 43 | } 44 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/proto/wrappers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package proto 6 | 7 | // Bool stores v in a new bool value and returns a pointer to it. 8 | func Bool(v bool) *bool { return &v } 9 | 10 | // Int32 stores v in a new int32 value and returns a pointer to it. 11 | func Int32(v int32) *int32 { return &v } 12 | 13 | // Int64 stores v in a new int64 value and returns a pointer to it. 14 | func Int64(v int64) *int64 { return &v } 15 | 16 | // Float32 stores v in a new float32 value and returns a pointer to it. 17 | func Float32(v float32) *float32 { return &v } 18 | 19 | // Float64 stores v in a new float64 value and returns a pointer to it. 20 | func Float64(v float64) *float64 { return &v } 21 | 22 | // Uint32 stores v in a new uint32 value and returns a pointer to it. 23 | func Uint32(v uint32) *uint32 { return &v } 24 | 25 | // Uint64 stores v in a new uint64 value and returns a pointer to it. 26 | func Uint64(v uint64) *uint64 { return &v } 27 | 28 | // String stores v in a new string value and returns a pointer to it. 29 | func String(v string) *string { return &v } 30 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/reflect/protoreflect/value_pure.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build purego || appengine 6 | // +build purego appengine 7 | 8 | package protoreflect 9 | 10 | import "google.golang.org/protobuf/internal/pragma" 11 | 12 | type valueType int 13 | 14 | const ( 15 | nilType valueType = iota 16 | boolType 17 | int32Type 18 | int64Type 19 | uint32Type 20 | uint64Type 21 | float32Type 22 | float64Type 23 | stringType 24 | bytesType 25 | enumType 26 | ifaceType 27 | ) 28 | 29 | // value is a union where only one type can be represented at a time. 30 | // This uses a distinct field for each type. This is type safe in Go, but 31 | // occupies more memory than necessary (72B). 32 | type value struct { 33 | pragma.DoNotCompare // 0B 34 | 35 | typ valueType // 8B 36 | num uint64 // 8B 37 | str string // 16B 38 | bin []byte // 24B 39 | iface any // 16B 40 | } 41 | 42 | func valueOfString(v string) Value { 43 | return Value{typ: stringType, str: v} 44 | } 45 | func valueOfBytes(v []byte) Value { 46 | return Value{typ: bytesType, bin: v} 47 | } 48 | func valueOfIface(v any) Value { 49 | return Value{typ: ifaceType, iface: v} 50 | } 51 | 52 | func (v Value) getString() string { 53 | return v.str 54 | } 55 | func (v Value) getBytes() []byte { 56 | return v.bin 57 | } 58 | func (v Value) getIface() any { 59 | return v.iface 60 | } 61 | -------------------------------------------------------------------------------- /vendor/google.golang.org/protobuf/runtime/protoiface/legacy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package protoiface 6 | 7 | type MessageV1 interface { 8 | Reset() 9 | String() string 10 | ProtoMessage() 11 | } 12 | 13 | type ExtensionRangeV1 struct { 14 | Start, End int32 // both inclusive 15 | } 16 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v3/NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2011-2016 Canonical Ltd. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | --------------------------------------------------------------------------------