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

Method Validate

cel/validator.go:499–526  ·  view source on GitHub ↗

Validate implements the ASTValidator interface method.

(e *Env, _ ValidatorConfig, a *ast.AST, iss *Issues)

Source from the content-addressed store, hash-verified

497
498// Validate implements the ASTValidator interface method.
499func (v bindNestingLimitValidator) Validate(e *Env, _ ValidatorConfig, a *ast.AST, iss *Issues) {
500 root := ast.NavigateAST(a)
501 comprehensions := ast.MatchDescendants(root, ast.KindMatcher(ast.ComprehensionKind))
502 var celBinds []ast.NavigableExpr
503 for _, comp := range comprehensions {
504 if isCelBind(comp) {
505 celBinds = append(celBinds, comp)
506 }
507 }
508 if len(celBinds) <= v.limit {
509 return
510 }
511 for _, comp := range celBinds {
512 count := 0
513 e := comp
514 hasParent := true
515 for hasParent {
516 if isCelBind(e) {
517 count++
518 if count > v.limit {
519 iss.ReportErrorAtID(comp.ID(), "cel.bind exceeds nesting limit")
520 break
521 }
522 }
523 e, hasParent = e.Parent()
524 }
525 }
526}
527
528func isEmptyRangeComprehension(e ast.NavigableExpr) bool {
529 if e.Kind() != ast.ComprehensionKind {

Callers

nothing calls this directly

Calls 7

NavigateASTFunction · 0.92
MatchDescendantsFunction · 0.92
KindMatcherFunction · 0.92
isCelBindFunction · 0.85
ReportErrorAtIDMethod · 0.65
IDMethod · 0.65
ParentMethod · 0.65

Tested by

no test coverage detected