config

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigEnvvarName = "TERRASCAN_CONFIG"

ConfigEnvvarName env variable

Variables

View Source
var (
	// ErrTomlLoadConfig indicates error: Failed to load toml config
	ErrTomlLoadConfig = fmt.Errorf("failed to load toml config")
	// ErrNotPresent indicates error: Config file not present
	ErrNotPresent = fmt.Errorf("config file not present")
)

Functions

func GetCategoryList

func GetCategoryList() []string

GetCategoryList returns the configured list of category of violations

func GetNotifications

func GetNotifications() map[string]Notifier

GetNotifications returns the configured notifier map

func GetPolicyAccessToken

func GetPolicyAccessToken() string

GetPolicyAccessToken returns the configured policy access token

func GetPolicyBasePath

func GetPolicyBasePath() string

GetPolicyBasePath returns the configured policy base path

func GetPolicyBranch

func GetPolicyBranch() string

GetPolicyBranch returns the configured policy repo url

func GetPolicyEnvironment

func GetPolicyEnvironment() string

GetPolicyEnvironment returns the configured policy environment url

func GetPolicyRepoPath

func GetPolicyRepoPath() string

GetPolicyRepoPath return the configured path to the policies repo locally downloaded

func GetPolicyRepoURL

func GetPolicyRepoURL() string

GetPolicyRepoURL returns the configured policy repo url

func GetScanRules

func GetScanRules() []string

GetScanRules returns the configured scan rules

func GetSeverityLevel

func GetSeverityLevel() string

GetSeverityLevel returns the configured severity level

func GetSkipRules

func GetSkipRules() []string

GetSkipRules returns the configured skips rules

func LoadGlobalConfig

func LoadGlobalConfig(configFile string) error

LoadGlobalConfig loads policy configuration from specified configFile into var Global.Policy. Members of Global.Policy that are not specified in configFile will get default values

Types

type Category

type Category struct {
	List []string `toml:"list" yaml:"list"`
}

Category defines the categories of violations that you want to be reported

type K8sAdmissionControl

type K8sAdmissionControl struct {
	Dashboard      bool     `toml:"dashboard,omitempty" yaml:"dashboard,omitempty"`
	DeniedSeverity string   `toml:"denied-severity,omitempty" yaml:"denied-severity,omitempty"`
	Categories     []string `toml:"denied-categories,omitempty" yaml:"denied-categories,omitempty"`
	SaveRequests   bool     `toml:"save-requests,omitempty" yaml:"save-requests,omitempty"`
}

K8sAdmissionControl deny rules in the terrascan config file

func GetK8sAdmissionControl

func GetK8sAdmissionControl() K8sAdmissionControl

GetK8sAdmissionControl returns kubernetes admission control configuration

type Notifier

type Notifier struct {
	NotifierType   string      `toml:"type" yaml:"type"`
	NotifierConfig interface{} `toml:"config" yaml:"config"`
}

Notifier represent a single notification in the terrascan config file

type Policy

type Policy struct {
	// policy repo local path
	BasePath string `toml:"path,omitempty" yaml:"path,omitempty"`
	// local filepath where repository containing policies is cached at
	RepoPath string `toml:"rego_subdir,omitempty" yaml:"rego_subdir,omitempty"`

	// policy git url and branch
	RepoURL string `toml:"repo_url,omitempty" yaml:"repo_url,omitempty"`
	Branch  string `toml:"branch,omitempty" yaml:"branch,omitempty"`

	// policy environment and access token
	Environment string `toml:"environment,omitempty" yaml:"environment,omitempty"`
	AccessToken string `toml:"access_token,omitempty" yaml:"access_token,omitempty"`
}

Policy struct defines policy specific configurations

type Rules

type Rules struct {
	ScanRules []string `toml:"scan-rules,omitempty" yaml:"scan-rules,omitempty"`
	SkipRules []string `toml:"skip-rules,omitempty" yaml:"skip-rules,omitempty"`
}

Rules represents scan and skip rules in the terrascan config file

type Severity

type Severity struct {
	Level string `toml:"level" yaml:"level"`
}

Severity defines the minimum level of severity of violations that you want to be reported

type TerrascanConfig

type TerrascanConfig struct {
	Policy              `toml:"policy,omitempty" yaml:"policy,omitempty"`
	Notifications       map[string]Notifier `toml:"notifications,omitempty" yaml:"notifications,omitempty"`
	Rules               `toml:"rules,omitempty" yaml:"rules,omitempty"`
	Category            `toml:"category,omitempty" yaml:"category,omitempty"`
	Severity            `toml:"severity,omitempty" yaml:"severity,omitempty"`
	K8sAdmissionControl `toml:"k8s-admission-control,omitempty" yaml:"k8s-admission-control,omitempty"`
}

TerrascanConfig struct defines global variables/configurations across terrascan

type TerrascanConfigReader

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

TerrascanConfigReader holds the terrascan config file name

func NewTerrascanConfigReader

func NewTerrascanConfigReader(fileName string) (*TerrascanConfigReader, error)

NewTerrascanConfigReader initialises and returns a config reader

func (TerrascanConfigReader) GetK8sAdmissionControl

func (r TerrascanConfigReader) GetK8sAdmissionControl() K8sAdmissionControl

GetK8sAdmissionControl will return the k8s deny rules specified in the terrascan config file

Jump to

Keyboard shortcuts

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