cel

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VarNamePredicate  = "predicate"
	VarNamePredicates = "predicates"
	VarNameContext    = "context"
	VarNameOutputs    = "outputs"
	VarNameSubject    = "subject"
)

Variables

View Source
var Class = class.Class("cel@v0")

Functions

This section is empty.

Types

type CelEvaluatorImplementation

type CelEvaluatorImplementation interface {
	CompileCode(*cel.Env, string) (*cel.Ast, error)
	CreateEnvironment(*options.EvaluatorOptions, map[string]Plugin) (*cel.Env, error)
	BuildVariables(*options.EvaluatorOptions, map[string]Plugin, *papi.Tenet, *evalcontext.EvaluationContext, []attestation.Predicate) (*map[string]any, error)
	EnsurePredicates(*papi.Tenet, *map[string]any) (*papi.EvalResult, error)
	EvaluateOutputs(*cel.Env, map[string]*cel.Ast, *map[string]any) (map[string]any, error)
	Evaluate(*cel.Env, *cel.Ast, *map[string]any) (*papi.EvalResult, error)
	Assert(*papi.ResultSet) bool
	BuildSelectorVariables(*options.EvaluatorOptions, map[string]Plugin, *evalcontext.EvaluationContext, *papi.Policy, attestation.Subject, *papi.ChainedPredicate, attestation.Predicate) (*map[string]any, error)
	EvaluateChainedSelector(*cel.Env, *cel.Ast, *map[string]any) ([]attestation.Subject, error)
}

type EvaluationError

type EvaluationError struct {
	Message   string
	EvalError error
}

EvaluationError captures error details when executing CEL code

func (*EvaluationError) Error

func (ee *EvaluationError) Error() string

type Evaluator

type Evaluator struct {
	Environment *cel.Env
	Plugins     map[string]Plugin
	// contains filtered or unexported fields
}

Evaluator implements the evaluator.Evaluator interface to evaluate CEL code

func New

func New(funcs ...options.OptFunc) (*Evaluator, error)

New creates a new CEL evaluator with the default options

func NewWithOptions

func NewWithOptions(opts *options.EvaluatorOptions) (*Evaluator, error)

func (*Evaluator) ExecChainedSelector

func (e *Evaluator) ExecChainedSelector(
	ctx context.Context, opts *options.EvaluatorOptions, chained *papi.ChainedPredicate, predicate attestation.Predicate,
) ([]attestation.Subject, error)

func (*Evaluator) ExecTenet

func (e *Evaluator) ExecTenet(
	ctx context.Context, opts *options.EvaluatorOptions, tenet *papi.Tenet, predicates []attestation.Predicate,
) (*papi.EvalResult, error)

Exec executes each tenet and returns the combined results

func (*Evaluator) RegisterPlugin

func (e *Evaluator) RegisterPlugin(plugin api.Plugin) error

RegisterPlugin registers a plugin expanding the CEL API available at eval time

type Plugin

type Plugin interface {
	// CanRegisterDataFor implements the plugin api function that flags if
	// the plugin is compatible with a class of evaluator
	CanRegisterFor(class.Class) bool

	// EnvVariables returns the data (as a cel.Variable list) that will be
	// registered as global variables in the evaluation environment
	Library() cel.EnvOption

	// VarValues returns the values of the variables handled by the plugin
	VarValues(*papi.Policy, attestation.Subject, []attestation.Predicate) map[string]any
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL