rego

package
v0.94.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 29 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSchemaSetFromPolicies added in v0.82.8

func BuildSchemaSetFromPolicies(policies map[string]*ast.Module, paths []string, fsys fs.FS) (*ast.SchemaSet, bool, error)

func GetInputsContents added in v0.94.0

func GetInputsContents(inputs []Input) []any

func IsDotFile added in v0.94.0

func IsDotFile(name string) bool

func IsJSONFile added in v0.94.0

func IsJSONFile(name string) bool

func IsRegoFile added in v0.94.0

func IsRegoFile(name string) bool

func LoadEmbeddedLibraries added in v0.94.0

func LoadEmbeddedLibraries() (map[string]*ast.Module, error)

func LoadEmbeddedPolicies added in v0.94.0

func LoadEmbeddedPolicies() (map[string]*ast.Module, error)

func LoadPoliciesFromDirs added in v0.94.0

func LoadPoliciesFromDirs(target fs.FS, paths ...string) (map[string]*ast.Module, error)

func NewEngineMetadata added in v0.94.0

func NewEngineMetadata(schema string, meta map[string]interface{}) (*scan.EngineMetadata, error)

func RegisterRegoRules added in v0.82.6

func RegisterRegoRules(modules map[string]*ast.Module)

Types

type DynamicMetadata

type DynamicMetadata struct {
	Warning   bool
	Filepath  string
	Message   string
	StartLine int
	EndLine   int
}

type Input

type Input struct {
	Path     string      `json:"path"`
	FS       fs.FS       `json:"-"`
	Contents interface{} `json:"contents"`
}

type InputOptions

type InputOptions struct {
	Combined  bool
	Selectors []Selector
}

type MetadataRetriever

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

func NewMetadataRetriever

func NewMetadataRetriever(compiler *ast.Compiler) *MetadataRetriever

func (*MetadataRetriever) RetrieveMetadata

func (m *MetadataRetriever) RetrieveMetadata(ctx context.Context, module *ast.Module, contents ...any) (*StaticMetadata, error)

type Scanner

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

func NewScanner

func NewScanner(source types.Source, options ...options.ScannerOption) *Scanner

func (*Scanner) LoadPolicies

func (s *Scanner) LoadPolicies(enableEmbeddedLibraries, enableEmbeddedPolicies bool, srcFS fs.FS, paths []string, readers []io.Reader) error

func (*Scanner) ScanInput

func (s *Scanner) ScanInput(ctx context.Context, inputs ...Input) (scan.Results, error)

func (*Scanner) SetDataDirs added in v0.39.0

func (s *Scanner) SetDataDirs(dirs ...string)

func (*Scanner) SetDataFilesystem added in v0.82.10

func (s *Scanner) SetDataFilesystem(fs fs.FS)

func (*Scanner) SetDebugWriter added in v0.39.0

func (s *Scanner) SetDebugWriter(writer io.Writer)

func (*Scanner) SetFrameworks added in v0.69.0

func (s *Scanner) SetFrameworks(frameworks []framework.Framework)

func (*Scanner) SetParentDebugLogger added in v0.68.0

func (s *Scanner) SetParentDebugLogger(l debug.Logger)

func (*Scanner) SetPerResultTracingEnabled added in v0.39.0

func (s *Scanner) SetPerResultTracingEnabled(b bool)

func (*Scanner) SetPolicyDirs added in v0.39.0

func (s *Scanner) SetPolicyDirs(_ ...string)

func (*Scanner) SetPolicyFilesystem added in v0.46.0

func (s *Scanner) SetPolicyFilesystem(fs fs.FS)

func (*Scanner) SetPolicyNamespaces added in v0.39.0

func (s *Scanner) SetPolicyNamespaces(namespaces ...string)

func (*Scanner) SetPolicyReaders added in v0.39.0

func (s *Scanner) SetPolicyReaders(_ []io.Reader)

func (*Scanner) SetRegoErrorLimit added in v0.89.0

func (s *Scanner) SetRegoErrorLimit(limit int)

func (*Scanner) SetRegoOnly added in v0.80.1

func (s *Scanner) SetRegoOnly(bool)

func (*Scanner) SetSkipRequiredCheck added in v0.39.0

func (s *Scanner) SetSkipRequiredCheck(_ bool)

func (*Scanner) SetSpec added in v0.82.5

func (s *Scanner) SetSpec(spec string)

func (*Scanner) SetTraceWriter added in v0.39.0

func (s *Scanner) SetTraceWriter(writer io.Writer)

func (*Scanner) SetUseEmbeddedLibraries added in v0.87.0

func (s *Scanner) SetUseEmbeddedLibraries(b bool)

func (*Scanner) SetUseEmbeddedPolicies added in v0.54.0

func (s *Scanner) SetUseEmbeddedPolicies(b bool)

type Selector

type Selector struct {
	Type     string
	Subtypes []SubType
}

type StaticMetadata

type StaticMetadata struct {
	ID                 string
	AVDID              string
	Title              string
	ShortCode          string
	Aliases            []string
	Description        string
	Severity           string
	RecommendedActions string
	PrimaryURL         string
	References         []string
	InputOptions       InputOptions
	Package            string
	Frameworks         map[framework.Framework][]string
	Provider           string
	Service            string
	Library            bool
	CloudFormation     *scan.EngineMetadata
	Terraform          *scan.EngineMetadata
}

func NewStaticMetadata added in v0.94.0

func NewStaticMetadata(pkgPath string, inputOpt InputOptions) *StaticMetadata

func (*StaticMetadata) FromAnnotations added in v0.94.0

func (sm *StaticMetadata) FromAnnotations(annotations *ast.Annotations) error

func (StaticMetadata) ToRule

func (m StaticMetadata) ToRule() scan.Rule

func (*StaticMetadata) Update added in v0.94.0

func (sm *StaticMetadata) Update(meta map[string]any) error

type SubType added in v0.83.0

type SubType struct {
	Group     string
	Version   string
	Kind      string
	Namespace string
	Service   string // only for cloud
	Provider  string // only for cloud
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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