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