const homogeneousValidatorName … const HomogeneousAggregateLiteralExemptFunctions … // ASTValidators configures a set of ASTValidator instances into the target environment. // // Validators are applied in the order in which the are specified and are treated as singletons. // The same ASTValidator with a given name will not be applied more than once. func ASTValidators(validators ...ASTValidator) EnvOption { … } type ASTValidator … type ValidatorConfig … type MutableValidatorConfig … type ASTValidatorConfigurer … type validatorConfig … // newValidatorConfig initializes the validator config with default values for core CEL validators. func newValidatorConfig() *validatorConfig { … } // GetOrDefault returns the configured value for the name, if present, else the input default value. // // Note, the type-agreement between the input default and configured value is not checked on read. func (config *validatorConfig) GetOrDefault(name string, value any) any { … } // Set configures a validator option with the given name and value. // // If the value had previously been set, the new value must have the same reflection type as the old one, // or the call will error. func (config *validatorConfig) Set(name string, value any) error { … } // ExtendedValidations collects a set of common AST validations which reduce the likelihood of runtime errors. // // - Validate duration and timestamp literals // - Ensure regex strings are valid // - Disable mixed type list and map literals func ExtendedValidations() EnvOption { … } // ValidateDurationLiterals ensures that duration literal arguments are valid immediately after type-check. func ValidateDurationLiterals() ASTValidator { … } // ValidateTimestampLiterals ensures that timestamp literal arguments are valid immediately after type-check. func ValidateTimestampLiterals() ASTValidator { … } // ValidateRegexLiterals ensures that regex patterns are validated after type-check. func ValidateRegexLiterals() ASTValidator { … } // ValidateHomogeneousAggregateLiterals checks that all list and map literals entries have the same types, i.e. // no mixed list element types or mixed map key or map value types. // // Note: the string format call relies on a mixed element type list for ease of use, so this check skips all // literals which occur within string format calls. func ValidateHomogeneousAggregateLiterals() ASTValidator { … } // ValidateComprehensionNestingLimit ensures that comprehension nesting does not exceed the specified limit. // // This validator can be useful for preventing arbitrarily nested comprehensions which can take high polynomial // time to complete. // // Note, this limit does not apply to comprehensions with an empty iteration range, as these comprehensions have // no actual looping cost. The cel.bind() utilizes the comprehension structure to perform local variable // assignments and supplies an empty iteration range, so they won't count against the nesting limit either. func ValidateComprehensionNestingLimit(limit int) ASTValidator { … } type argChecker … func newFormatValidator(funcName string, argNum int, check argChecker) formatValidator { … } type formatValidator … // Name returns the unique name of this function format validator. func (v formatValidator) Name() string { … } // Validate searches the AST for uses of a given function name with a constant argument and performs a check // on whether the argument is a valid literal value. func (v formatValidator) Validate(e *Env, _ ValidatorConfig, a *ast.AST, iss *Issues) { … } func evalCall(env *Env, call, arg ast.Expr) error { … } func compileRegex(_ *Env, _, arg ast.Expr) error { … } type homogeneousAggregateLiteralValidator … // Name returns the unique name of the homogeneous type validator. func (homogeneousAggregateLiteralValidator) Name() string { … } // Validate validates that all lists and map literals have homogeneous types, i.e. don't contain dyn types. // // This validator makes an exception for list and map literals which occur at any level of nesting within // string format calls. func (v homogeneousAggregateLiteralValidator) Validate(_ *Env, c ValidatorConfig, a *ast.AST, iss *Issues) { … } func inExemptFunction(e ast.NavigableExpr, exemptFunctions []string) bool { … } func isOptionalIndex(i int, optIndices []int32) bool { … } func (homogeneousAggregateLiteralValidator) typeMismatch(iss *Issues, id int64, expected, actual *Type) { … } type nestingLimitValidator … func (v nestingLimitValidator) Name() string { … } func (v nestingLimitValidator) Validate(e *Env, _ ValidatorConfig, a *ast.AST, iss *Issues) { … }