policy

package
v2.3.0-3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConfigFileNotFound = errors.New("policy file isn't found")

Functions

func ParseEnv

func ParseEnv(env string) []string

func Validate

func Validate(logE *logrus.Entry, finder ConfigFinder, validator Validator, param *config.Param) error

Types

type Checker

type Checker interface {
	ValidatePackage(param *ParamValidatePackage) error
}

type CheckerImpl

type CheckerImpl struct{}

func NewChecker

func NewChecker() *CheckerImpl

func (*CheckerImpl) ValidatePackage

func (pc *CheckerImpl) ValidatePackage(param *ParamValidatePackage) error

type Config

type Config struct {
	Path string
	YAML *ConfigYAML
}

func (*Config) Init

func (cfg *Config) Init() error

type ConfigFinder added in v2.3.0

type ConfigFinder interface {
	Find(policyFilePath, wd string) (string, error)
}

type ConfigFinderImpl added in v2.3.0

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

func NewConfigFinder added in v2.3.0

func NewConfigFinder(fs afero.Fs) *ConfigFinderImpl

func (*ConfigFinderImpl) Find added in v2.3.0

func (finder *ConfigFinderImpl) Find(policyFilePath, wd string) (string, error)

type ConfigReader

type ConfigReader interface {
	Read(policyConfigFiles []string, disablePolicy bool) ([]*Config, error)
}

type ConfigReaderImpl

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

func NewConfigReader

func NewConfigReader(fs afero.Fs) *ConfigReaderImpl

func (*ConfigReaderImpl) Read

func (reader *ConfigReaderImpl) Read(files []string, disablePolicy bool) ([]*Config, error)

type ConfigYAML

type ConfigYAML struct {
	Registries []*Registry `json:"registries"`
	Packages   []*Package  `json:"packages,omitempty"`
}

type MockChecker

type MockChecker struct {
	Err error
}

func (*MockChecker) ValidatePackage

func (pc *MockChecker) ValidatePackage(param *ParamValidatePackage) error

type MockConfigFinder added in v2.3.0

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

func (*MockConfigFinder) Find added in v2.3.0

func (finder *MockConfigFinder) Find(policyFilePath, wd string) (string, error)

type MockConfigReader

type MockConfigReader struct {
	Cfgs []*Config
	Err  error
}

func (*MockConfigReader) Read

func (reader *MockConfigReader) Read(files []string, disablePolicy bool) ([]*Config, error)

type MockValidator added in v2.3.0

type MockValidator struct {
	Err error
}

func (*MockValidator) Allow added in v2.3.0

func (validator *MockValidator) Allow(p string) error

func (*MockValidator) Deny added in v2.3.0

func (validator *MockValidator) Deny(p string) error

func (*MockValidator) Validate added in v2.3.0

func (validator *MockValidator) Validate(p string) error

func (*MockValidator) Warn added in v2.3.0

func (validator *MockValidator) Warn(logE *logrus.Entry, policyFilePath string) error

type Package

type Package struct {
	Name         string    `json:"name"`
	Version      string    `json:"version,omitempty"`
	RegistryName string    `yaml:"registry" json:"registry,omitempty"`
	Registry     *Registry `yaml:"-" json:"-"`
}

type ParamValidatePackage

type ParamValidatePackage struct {
	Pkg           *config.Package
	PolicyConfigs []*Config
}

type Registry

type Registry struct {
	Name      string `json:"name,omitempty"`
	Type      string `validate:"required" json:"type,omitempty" jsonschema:"enum=standard,enum=local,enum=github_content"`
	RepoOwner string `yaml:"repo_owner" json:"repo_owner,omitempty"`
	RepoName  string `yaml:"repo_name" json:"repo_name,omitempty"`
	Ref       string `json:"ref,omitempty"`
	Path      string `validate:"required" json:"path,omitempty"`
}

type Validator added in v2.3.0

type Validator interface {
	Validate(p string) error
	Allow(p string) error
	Deny(p string) error
	Warn(logE *logrus.Entry, policyFilePath string) error
}

type ValidatorImpl added in v2.3.0

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

func NewValidator added in v2.3.0

func NewValidator(param *config.Param, fs afero.Fs) *ValidatorImpl

func (*ValidatorImpl) Allow added in v2.3.0

func (validator *ValidatorImpl) Allow(p string) error

func (*ValidatorImpl) Deny added in v2.3.0

func (validator *ValidatorImpl) Deny(p string) error

func (*ValidatorImpl) Validate added in v2.3.0

func (validator *ValidatorImpl) Validate(p string) error

func (*ValidatorImpl) Warn added in v2.3.0

func (validator *ValidatorImpl) Warn(logE *logrus.Entry, policyFilePath string) error

Jump to

Keyboard shortcuts

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