ruler

package
v2.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateInTotoLink(reports []Report, fileBytes []byte) in_toto.Metablock

Types

type InvalidInputError

type InvalidInputError struct {
}

func (*InvalidInputError) Error

func (e *InvalidInputError) Error() string

type NotSupportedError

type NotSupportedError struct {
	Kind string
}

func (*NotSupportedError) Error

func (e *NotSupportedError) Error() string

type Report

type Report struct {
	Object   string      `json:"object"`
	Valid    bool        `json:"valid"`
	FileName string      `json:"fileName"`
	Rules    []RuleRef   `json:"-"`
	Message  string      `json:"message,omitempty"`
	Score    int         `json:"score"`
	Scoring  RuleScoring `json:"scoring,omitempty"`
}

type Reports added in v2.9.0

type Reports []Report

type Rule

type Rule struct {
	ID        string           `json:"id" yaml:"id"`
	Selector  string           `json:"selector" yaml:"selector"`
	Reason    string           `json:"reason" yaml:"reason"`
	Link      string           `json:"link,omitempty" yaml:"link,omitempty"`
	Kinds     []string         `json:"kinds" yaml:"kinds"`
	Points    int              `json:"points" yaml:"points"`
	Advise    int              `json:"advise" yaml:"advise"`
	Predicate func([]byte) int `json:"-" yaml:"-"`
}

func (*Rule) Eval

func (r *Rule) Eval(json []byte) (int, error)

Eval executes the predicate if the kind matches the rule

type RuleRef

type RuleRef struct {
	ID         string `json:"id"`
	Selector   string `json:"selector"`
	Reason     string `json:"reason"`
	Weight     int    `json:"weight,omitempty"`
	Link       string `json:"href,omitempty"`
	Containers int    `json:"-"`
	Points     int    `json:"points"`
}

type RuleRefCustomOrder

type RuleRefCustomOrder []RuleRef

func (RuleRefCustomOrder) Len

func (rr RuleRefCustomOrder) Len() int

func (RuleRefCustomOrder) Less

func (rr RuleRefCustomOrder) Less(i, j int) bool

func (RuleRefCustomOrder) Swap

func (rr RuleRefCustomOrder) Swap(i, j int)

type RuleScoring

type RuleScoring struct {
	Critical []RuleRef `json:"critical,omitempty"`
	Passed   []RuleRef `json:"passed,omitempty"`
	Advise   []RuleRef `json:"advise,omitempty"`
}

type Ruleset

type Ruleset struct {
	Rules []Rule
	// contains filtered or unexported fields
}

func NewRuleset

func NewRuleset(logger *zap.SugaredLogger) *Ruleset

func (*Ruleset) Run

func (rs *Ruleset) Run(fileName string, fileBytes []byte, schemaConfig SchemaConfig) ([]Report, error)

type SchemaConfig added in v2.13.0

type SchemaConfig struct {
	// DisableValidation disables the validation of the manifests against
	// Kubernetes JSON schema. Set to true when the source manifests
	// comes directly from the cluster (e.g: webhook, kubectl plugin).
	DisableValidation bool

	// Locations defines the locations of the schemas. This follows the
	// same logic as the -schema-location flag from kubeconform.
	Locations []string

	// ValidatorOpts are the options from kubeconform validator.
	ValidatorOpts validator.Opts
}

SchemaConfig hold the configuration of the schema validaton.

func NewDefaultSchemaConfig added in v2.13.0

func NewDefaultSchemaConfig() SchemaConfig

Jump to

Keyboard shortcuts

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