Documentation
¶
Overview ¶
Package rtengine contains the rule type engine
Index ¶
- func NewRuleEvaluator(ctx context.Context, ruletype *minderv1.RuleType, provider interfaces.Provider, ...) (interfaces.Evaluator, error)
- type RuleMeta
- type RuleTypeEngine
- func (r *RuleTypeEngine) Eval(ctx context.Context, entity protoreflect.ProtoMessage, ruleDef map[string]any, ...) (res *interfaces.EvaluationResult, finalErr error)
- func (r *RuleTypeEngine) GetID() string
- func (r *RuleTypeEngine) GetRuleInstanceValidator() *profiles.RuleValidator
- func (r *RuleTypeEngine) GetRuleType() *minderv1.RuleType
- func (r *RuleTypeEngine) WithCustomIngester(ing interfaces.Ingester) *RuleTypeEngine
- func (r *RuleTypeEngine) WithIngesterCache(ingestCache ingestcache.Cache) *RuleTypeEngine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRuleEvaluator ¶ added in v0.1.1
func NewRuleEvaluator( ctx context.Context, ruletype *minderv1.RuleType, provider interfaces.Provider, opts ...interfaces.Option, ) (interfaces.Evaluator, error)
NewRuleEvaluator creates an Evaluator from the specified RuleType. The external caller is responsible for populating the ingested data in the Evaluator's Eval() method; the provider is used only for certain PR-based file content checks (trusty, vulncheck, and homoglyphs). Unlike NewRuleTypeEngine, ingestion data is not cached within the library.
Types ¶
type RuleMeta ¶
type RuleMeta struct {
// Name is the name of the rule
Name string
// Project is the ID of the project that this rule is for
Project string
}
RuleMeta is the metadata for a rule TODO: We probably should care about a version
type RuleTypeEngine ¶
type RuleTypeEngine struct {
Meta RuleMeta
// contains filtered or unexported fields
}
RuleTypeEngine is the engine for a rule type. It builds the multiple sections of the rule type and instantiates the needed drivers for them.
func NewRuleTypeEngine ¶
func NewRuleTypeEngine( ctx context.Context, ruletype *minderv1.RuleType, provider interfaces.Provider, opts ...interfaces.Option, ) (*RuleTypeEngine, error)
NewRuleTypeEngine creates a new rule type engine
func (*RuleTypeEngine) Eval ¶
func (r *RuleTypeEngine) Eval( ctx context.Context, entity protoreflect.ProtoMessage, ruleDef map[string]any, ruleParams map[string]any, params interfaces.ResultSink, ) (res *interfaces.EvaluationResult, finalErr error)
Eval runs the rule type engine against the given entity
func (*RuleTypeEngine) GetID ¶
func (r *RuleTypeEngine) GetID() string
GetID returns the ID of the rule type. The ID is meant to be a serializable unique identifier for the rule type.
func (*RuleTypeEngine) GetRuleInstanceValidator ¶
func (r *RuleTypeEngine) GetRuleInstanceValidator() *profiles.RuleValidator
GetRuleInstanceValidator returns the rule instance validator for this rule type. By instance we mean a rule that has been instantiated in a profile from a given rule type.
func (*RuleTypeEngine) GetRuleType ¶
func (r *RuleTypeEngine) GetRuleType() *minderv1.RuleType
GetRuleType returns the rule type PB structure.
func (*RuleTypeEngine) WithCustomIngester ¶
func (r *RuleTypeEngine) WithCustomIngester(ing interfaces.Ingester) *RuleTypeEngine
WithCustomIngester sets a custom ingester for the rule type engine. This is handy for testing but should not be used in production.
func (*RuleTypeEngine) WithIngesterCache ¶
func (r *RuleTypeEngine) WithIngesterCache(ingestCache ingestcache.Cache) *RuleTypeEngine
WithIngesterCache sets the ingester cache for the rule type engine