engine

package
v0.0.0-...-48c0a4e Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine scans a set of paths, identifies IaC files, and reports any found vulnerability.

func NewEngine

func NewEngine(ctx context.Context, options EngineOptions) *Engine

func (*Engine) Eval

func (e *Engine) Eval(ctx context.Context, options RunOptions, inputs []models.State) *Results

func (*Engine) InitializationErrors

func (e *Engine) InitializationErrors() []error

func (*Engine) LoadInput

func (e *Engine) LoadInput(options RunOptions) (input.Loader, []error, []error)

func (*Engine) Metadata

func (e *Engine) Metadata(ctx context.Context) ([]MetadataResult, error)

Metadata returns the metadata of all Policies that have been loaded into this Engine instance.

func (*Engine) PostProcess

func (e *Engine) PostProcess(results *Results, loader input.Loader, options RunOptions) *Results

func (*Engine) Run

func (e *Engine) Run(ctx context.Context, options RunOptions) (*Results, []error)

Run runs the engine according to its configuration, and returns the results of the scan. If one or more errors occurred during the execution of the engine, Run returns them. In an error condition is known, it is encapsulated by an Error; otherwise, Run returns a generic error.

type EngineOptions

type EngineOptions struct {
	SnykBundle        io.ReadCloser
	CustomRuleBundles []bundle.Reader
	Logger            *zerolog.Logger
}

type Error

type Error struct {
	Message string
	Code    ErrorCode
	Path    string
}

Error represents a known error condition that might occur when running the engine. It contains a message, for debugging purposes, and additional information (like a path) when possible.

func (Error) Error

func (e Error) Error() string

type ErrorCode

type ErrorCode int

ErrorCode represents one of the possible known error conditions that might occur when running the engine.

const (
	ErrorCodeNoLoadableInputs ErrorCode = iota
	ErrorCodeUnableToRecognizeInputType
	ErrorCodeUnsupportedInputType
	ErrorCodeUnableToResolveLocation
	ErrorCodeUnrecognizedFileExtension
	ErrorCodeFailedToParseInput
	ErrorCodeInvalidInput
	ErrorCodeUnableToReadFile
	ErrorCodeUnableToReadDir
	ErrorCodeUnableToReadStdin
	ErrorCodeFailedToLoadRegoAPI
	ErrorCodeFailedToLoadRules
	ErrorCodeFailedToCompile
	ErrorCodeUnableToReadPath
	ErrorCodeFailedToMakeResourcesResolvers
	ErrorCodeResourcesResolverError
	ErrorCodeSubmoduleLoadingError
	ErrorCodeMissingRemoteSubmodulesError
	ErrorCodeEvaluationError
	ErrorCodeMissingTermError
)

type EvaluationError

type EvaluationError struct {
	Message     string
	Code        ErrorCode
	Path        string
	Expressions []string
}

func (EvaluationError) Error

func (e EvaluationError) Error() string

type MetadataResult

type MetadataResult = engine.MetadataResult

type MissingRemoteSubmodulesError

type MissingRemoteSubmodulesError struct {
	Message        string
	Code           ErrorCode
	Path           string
	Dir            string
	MissingModules []string
}

func (MissingRemoteSubmodulesError) Error

type MissingTermError

type MissingTermError struct {
	Message string
	Code    ErrorCode
	Path    string
	Term    string
}

func (MissingTermError) Error

func (e MissingTermError) Error() string

type Results

type Results = models.Results

type RunOptions

type RunOptions struct {
	FS                afero.Fs
	Paths             []string
	RuleIDs           []string
	Scan              string
	VarFile           string
	DetectionDepth    int
	ResourcesResolver policy.ResourcesResolver
}

type SubmoduleLoadingError

type SubmoduleLoadingError struct {
	Message string
	Code    ErrorCode
	Path    string
	Module  string
}

func (SubmoduleLoadingError) Error

func (e SubmoduleLoadingError) Error() string

Jump to

Keyboard shortcuts

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