exprruntime

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultHTTPClient

func DefaultHTTPClient() *http.Client

DefaultHTTPClient returns an HTTP client with reasonable timeouts.

func NeedsCELCompat

func NeedsCELCompat(s string) bool

func ParseValidationEnvAllowlist

func ParseValidationEnvAllowlist(parts []string) map[string]struct{}

ParseValidationEnvAllowlist converts CLI flag fragments into a set of names.

func RewriteCELCompat

func RewriteCELCompat(input string) (string, error)

RewriteCELCompat rewrites the CEL-shaped expression syntax used by existing configs into Expr syntax. It is intentionally narrow; unsupported CEL syntax should fail at Expr compile with both original and rewritten expressions.

Types

type EvalOptions

type EvalOptions struct {
	Debug bool
}

type EvalResult

type EvalResult struct {
	Value any
	Debug map[string]any
}

type Program

type Program = *compiledProgram

Program is the compiled expression representation used by validation, filters, and prefilters.

type Runtime

type Runtime struct {
	STSEndpoint      string
	GCPTokenEndpoint string
	AllowedEnv       map[string]struct{}
	// contains filtered or unexported fields
}

Runtime holds compiled Expr programs and validation services (if needed).

func New

func New(httpClient *http.Client) (*Runtime, error)

func (*Runtime) CompileFilter

func (e *Runtime) CompileFilter(expression string, tokenizer *tiktoken.Tiktoken) (Program, error)

func (*Runtime) CompilePrefilter

func (e *Runtime) CompilePrefilter(expression string) (Program, error)

func (*Runtime) CompileValidation

func (e *Runtime) CompileValidation(expression string) (Program, error)

func (*Runtime) Eval

func (e *Runtime) Eval(prg Program, finding, captures map[string]string) (any, error)

func (*Runtime) EvalFilter

func (e *Runtime) EvalFilter(prg Program, finding, attributes map[string]string) (bool, error)

Compile and runtime bindings expose the same names. Dynamic values are layered onto a shallow copy so compiled programs can share static function bindings.

func (*Runtime) EvalPrefilter

func (e *Runtime) EvalPrefilter(prg Program, attributes map[string]string) (bool, error)

func (*Runtime) EvalValidation

func (e *Runtime) EvalValidation(ctx context.Context, prg Program, finding, captures, attributes map[string]string, opts EvalOptions) (EvalResult, error)

func (*Runtime) EvalWithAttributes

func (e *Runtime) EvalWithAttributes(prg Program, finding, captures, attributes map[string]string) (any, error)

func (*Runtime) EvalWithContext

func (e *Runtime) EvalWithContext(ctx context.Context, prg Program, finding, captures, attributes map[string]string) (any, error)

func (*Runtime) SetHTTPClient

func (e *Runtime) SetHTTPClient(c *http.Client)

func (*Runtime) SetTokenizerProvider

func (e *Runtime) SetTokenizerProvider(provider func() *tiktoken.Tiktoken)

Jump to

Keyboard shortcuts

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