| 152 | } |
| 153 | |
| 154 | absl::StatusOr<std::unique_ptr<Runtime>> ConfigureRuntimeImpl( |
| 155 | bool resolve_references, Options evaluation_options) { |
| 156 | RuntimeOptions options; |
| 157 | switch (evaluation_options) { |
| 158 | case Options::kDefault: |
| 159 | options.short_circuiting = true; |
| 160 | break; |
| 161 | case Options::kExhaustive: |
| 162 | options.short_circuiting = false; |
| 163 | break; |
| 164 | case Options::kFoldConstants: |
| 165 | options.enable_comprehension_list_append = true; |
| 166 | options.short_circuiting = true; |
| 167 | break; |
| 168 | } |
| 169 | options.enable_qualified_type_identifiers = resolve_references; |
| 170 | options.container = "cel.expr.conformance.proto3"; |
| 171 | CEL_ASSIGN_OR_RETURN(cel::RuntimeBuilder runtime_builder, |
| 172 | CreateStandardRuntimeBuilder( |
| 173 | google::protobuf::DescriptorPool::generated_pool(), options)); |
| 174 | if (resolve_references) { |
| 175 | CEL_RETURN_IF_ERROR(EnableReferenceResolver( |
| 176 | runtime_builder, ReferenceResolverEnabled::kAlways)); |
| 177 | } |
| 178 | if (evaluation_options == Options::kFoldConstants) { |
| 179 | CEL_RETURN_IF_ERROR(extensions::EnableConstantFolding(runtime_builder)); |
| 180 | CEL_RETURN_IF_ERROR(extensions::EnableRegexPrecompilation(runtime_builder)); |
| 181 | } |
| 182 | |
| 183 | auto s = UnaryFunctionAdapter<bool, const StringValue&>::Register( |
| 184 | "IsPrivate", false, &IsPrivateIpv4Impl, |
| 185 | runtime_builder.function_registry()); |
| 186 | CEL_RETURN_IF_ERROR(s); |
| 187 | s.Update(UnaryFunctionAdapter<bool, const StringValue&>::Register( |
| 188 | "net.IsPrivate", false, &IsPrivateIpv4Impl, |
| 189 | runtime_builder.function_registry())); |
| 190 | CEL_RETURN_IF_ERROR(s); |
| 191 | |
| 192 | return std::move(runtime_builder).Build(); |
| 193 | } |
| 194 | |
| 195 | class EvaluatorMemorySafetyTest : public testing::TestWithParam<ParamType> { |
| 196 | public: |
no test coverage detected