MCPcopy Create free account
hub / github.com/cel-expr/cel-go / checkLoadedASTDepth

Function checkLoadedASTDepth

cel/io.go:106–111  ·  view source on GitHub ↗

checkLoadedASTDepth guards ASTs that enter through the proto conversion helpers (ParsedExprToAst / CheckedExprToAst) against nesting deeper than the parser's recursion limit. Those entry points bypass the parser, so without this check a deeply nested loaded AST could exhaust the Go stack during late

(a *ast.AST)

Source from the content-addressed store, hash-verified

104// Embedders that fully control their AST inputs can skip this by building the AST through the
105// common/ast package directly instead of these conversion helpers.
106func checkLoadedASTDepth(a *ast.AST) error {
107 if ast.ExceedsDepth(a, defaultMaxASTDepth) {
108 return fmt.Errorf("input exceeds maximum expression nesting depth: %d", defaultMaxASTDepth)
109 }
110 return nil
111}
112
113// AstToParsedExpr converts an Ast to an protobuf ParsedExpr value.
114func AstToParsedExpr(a *Ast) (*exprpb.ParsedExpr, error) {

Callers 2

Calls 1

ExceedsDepthFunction · 0.92

Tested by

no test coverage detected