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

Method Validate

cel/validator.go:507–534  ·  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

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

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