filterv2

package
v1.12.19 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RegisteredEnums = []EnumRegistration{
	{
		Name:     "ProjectSourceType",
		Prefix:   "PROJECT_SOURCE_TYPE_",
		ValueMap: packagev1.ProjectSourceType_value,
	},
	{
		Name:     "Ecosystem",
		Prefix:   "ECOSYSTEM_",
		ValueMap: packagev1.Ecosystem_value,
	},
}

RegisteredEnums contains all enum types that should be exposed to CEL Uses the protobuf-generated Type_value maps to avoid manual maintenance and drift

Functions

func NewEvaluator

func NewEvaluator(name string, opts ...Option) (*filterEvaluator, error)

NewEvaluator creates a new CEL evaluator for the policy system v2

Types

type EnumRegistration

type EnumRegistration struct {
	Name     string           // Name used in CEL expressions (e.g., "ProjectSourceType")
	Prefix   string           // Common prefix to strip from constant names
	ValueMap map[string]int32 // Reference to protobuf-generated enum value map
}

EnumRegistration contains all the information needed to generate enum constants

type Evaluator

type Evaluator interface {
	// AddPolicy adds a policy to the evaluator
	AddPolicy(policy *policyv1.Policy) error

	// EvaluatePackage evaluates a package against the policies
	EvaluatePackage(pkg *models.Package) (*FilterEvaluationResult, error)
}

Evaluator interface for the new policy system using Insights v2 data model

type FilterEvaluationResult

type FilterEvaluationResult struct {
	// contains filtered or unexported fields
}

FilterEvaluationResult represents the result of evaluating a filter

func (*FilterEvaluationResult) GetMatchedProgram

func (r *FilterEvaluationResult) GetMatchedProgram() (*FilterProgram, error)

func (*FilterEvaluationResult) Matched

func (r *FilterEvaluationResult) Matched() bool

type FilterProgram

type FilterProgram struct {
	// contains filtered or unexported fields
}

FilterProgram holds a rule and its compiled CEL program for fast evaluation of the expression

func (*FilterProgram) GetPolicy

func (p *FilterProgram) GetPolicy() *policyv1.Policy

func (*FilterProgram) GetRule

func (p *FilterProgram) GetRule() *policyv1.Rule

func (*FilterProgram) Name

func (p *FilterProgram) Name() string

type Option

type Option func(*filterEvaluator)

Option is a function type that can be used to configure the evaluator

func WithIgnoreError

func WithIgnoreError(ignore bool) Option

WithIgnoreError configures the evaluator to ignore errors during evaluation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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