Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrFailedToReadBundle = errors.New("failed to load bundle")
ErrFailedToReadBundle indicates that an error occurred while consuming a bundle.Reader.
var FailedToCompile = errors.New("Failed to compile rules")
FailedToCompile indicates that more than the maximum number of errors occurred during the compilation stage.
var FailedToLoadRegoAPI = errors.New("Failed to load the snyk Rego API")
FailedToLoadRegoAPI indicates that an error occurred while initializing the snyk Rego API.
var FailedToLoadRules = errors.New("Failed to load rules")
FailedToLoadRules indicates that an error occurred while consuming the rego and data producers provided to the engine.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// InitializationErrors contains any errors that occurred during initialization.
InitializationErrors []error
// contains filtered or unexported fields
}
Engine is responsible for evaluating some States with a given set of rules.
func NewEngine ¶
func NewEngine(ctx context.Context, options *EngineOptions) *Engine
NewEngine constructs a new Engine instance.
type EngineOptions ¶
type EngineOptions struct {
// Providers contains functions that produce parsed OPA modules or data documents.
Providers []data.Provider
// Providers contains bundle.Reader objects that produce parsed bundles.
BundleReaders []bundle.Reader
// Logger is an optional instance of the logger.Logger interface
Logger logging.Logger
// Metrics is an optional instance of the metrics.Metrics interface
Metrics metrics.Metrics
}
EngineOptions contains options for initializing an Engine instance
type EvalOptions ¶
type EvalOptions struct {
// Inputs are the State instances that the engine should evaluate.
Inputs []models.State
// Workers sets how many policies are to be evaluated concurrently. When
// unset or set to a value less than 1, this defaults to the number of CPU
// cores - 1.
Workers int
// ResourceResolver is a function that returns a resource state for the given
// ResourceRequest.
// Multiple ResourcesResolvers can be composed with And() and Or().
ResourcesResolver policy.ResourcesResolver
// RuleIDs determines which rules are executed. When this option is empty or
// unspecified, all rules will be run.
RuleIDs []string
}
EvalOptions contains options for Engine.Eval
type MetadataResult ¶
type PolicyConsumer ¶
type PolicyConsumer struct {
Modules map[string]*ast.Module
Document map[string]interface{}
NumDocuments int
}
PolicyConsumer is an implementation of the data.Consumer interface that stores parsed modules, policies, and documents in-memory.
func NewPolicyConsumer ¶
func NewPolicyConsumer() *PolicyConsumer
func (*PolicyConsumer) DataDocument ¶
type PolicySource ¶ added in v0.17.0
type PolicySource string
const ( POLICY_SOURCE_DATA PolicySource = "data" POLICY_SOURCE_BUNDLE_ARCHIVE PolicySource = "bundle_archive" POLICY_SOURCE_BUNDLE_DIRECTORY PolicySource = "bundle_directory" )
type RuleBundleError ¶ added in v0.17.0
type RuleBundleError struct {
// contains filtered or unexported fields
}
func (*RuleBundleError) Error ¶ added in v0.17.0
func (p *RuleBundleError) Error() string
func (*RuleBundleError) ToModel ¶ added in v0.17.0
func (p *RuleBundleError) ToModel() models.RuleBundleInfo