1 // Copyright 2020 gRPC authors. 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 #ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_EVALUATOR_CORE_H 16 #define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_EVALUATOR_CORE_H 17 18 #include <grpc/support/port_platform.h> 19 20 #include <memory> 21 #include <set> 22 #include <vector> 23 24 #include "absl/status/statusor.h" 25 26 #include "google/api/expr/v1alpha1/syntax.upb.h" 27 #include "src/core/lib/security/authorization/mock_cel/activation.h" 28 #include "src/core/lib/security/authorization/mock_cel/cel_expression.h" 29 #include "src/core/lib/security/authorization/mock_cel/cel_value.h" 30 31 namespace grpc_core { 32 namespace mock_cel { 33 34 // This is a temporary stub implementation of CEL APIs. 35 // Once gRPC imports the CEL library, this file will be removed. 36 37 class ExecutionPath { 38 public: 39 ExecutionPath() = default; 40 }; 41 42 // Implementation of the CelExpression that utilizes flattening 43 // of the expression tree. 44 class CelExpressionFlatImpl : public CelExpression { 45 // Constructs CelExpressionFlatImpl instance. 46 // path is flat execution path that is based upon 47 // flattened AST tree. Max iterations dictates the maximum number of 48 // iterations in the comprehension expressions (use 0 to disable the upper 49 // bound). 50 public: 51 CelExpressionFlatImpl(const google_api_expr_v1alpha1_Expr* root_expr, 52 ExecutionPath path, int max_iterations, 53 std::set<std::string> iter_variable_names, 54 bool enable_unknowns = false, 55 bool enable_unknown_function_results = false) {} 56 57 // Implementation of CelExpression evaluate method. Evaluate(const BaseActivation & activation)58 absl::StatusOr<CelValue> Evaluate( 59 const BaseActivation& activation) const override { 60 return CelValue::CreateNull(); 61 } 62 }; 63 64 } // namespace mock_cel 65 } // namespace grpc_core 66 67 #endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_EVALUATOR_CORE_H