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

Method Validate

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

514
515// Validate implements the ASTValidator interface method.
516func (v bindNestingLimitValidator) Validate(e *Env, _ ValidatorConfig, a *ast.AST, iss *Issues) {
517 root := ast.NavigateAST(a)
518 comprehensions := ast.MatchDescendants(root, ast.KindMatcher(ast.ComprehensionKind))
519 var celBinds []ast.NavigableExpr
520 for _, comp := range comprehensions {
521 if isCelBind(comp) {
522 celBinds = append(celBinds, comp)
523 }
524 }
525 if len(celBinds) <= v.limit {
526 return
527 }
528 for _, comp := range celBinds {
529 count := 0
530 e := comp
531 hasParent := true
532 for hasParent {
533 if isCelBind(e) {
534 count++
535 if count > v.limit {
536 iss.ReportErrorAtID(comp.ID(), "cel.bind exceeds nesting limit")
537 break
538 }
539 }
540 e, hasParent = e.Parent()
541 }
542 }
543}
544
545func (v regexProgramSizeLimitValidator) Validate(e *Env, _ ValidatorConfig, a *ast.AST, iss *Issues) {
546 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