cautils

package
v1.0.95 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ComponentIdentifier = "Posture"
)
View Source
const ValueNotFound = -1

Variables

View Source
var (
	CustomerGUID          = ""
	ClusterName           = ""
	EventReceiverURL      = ""
	NotificationServerURL = ""
	DashboardBackendURL   = ""
	RestAPIPort           = "4001"
)

CA environment vars

View Source
var DescriptionDisplay = color.New(color.Faint, color.FgWhite).FprintfFunc()
View Source
var FailureDisplay = color.New(color.Bold, color.FgHiRed).FprintfFunc()
View Source
var FailureTextDisplay = color.New(color.Faint, color.FgHiRed).FprintfFunc()
View Source
var InfoDisplay = color.New(color.Bold, color.FgHiYellow).FprintfFunc()
View Source
var InfoTextDisplay = color.New(color.Bold, color.FgHiYellow).FprintfFunc()
View Source
var SimpleDisplay = color.New().FprintfFunc()
View Source
var Spinner *spinner.Spinner
View Source
var SuccessDisplay = color.New(color.Bold, color.FgHiGreen).FprintfFunc()
View Source
var WarningDisplay = color.New(color.Bold, color.FgCyan).FprintfFunc()

Functions

func ConfigFileFullPath added in v1.0.65

func ConfigFileFullPath() string

func ConvertLabelsToString

func ConvertLabelsToString(labels map[string]string) string

func ConvertStringToLabels

func ConvertStringToLabels(labelsStr string) map[string]string

ConvertStringToLabels convert a string "a=b;c=d" to map: {"a":"b", "c":"d"}

func DeleteConfig added in v1.0.65

func DeleteConfig(k8s *k8sinterface.KubernetesApi) error

func DeleteConfigFile added in v1.0.65

func DeleteConfigFile() error

func DeleteConfigMap added in v1.0.65

func DeleteConfigMap(k8s *k8sinterface.KubernetesApi) error

func ErrorDisplay

func ErrorDisplay(str string)

func GetValueFromConfigJson added in v1.0.47

func GetValueFromConfigJson(key string) (string, error)

func IsRegistered added in v1.0.65

func IsRegistered(clusterConfig *ClusterConfig) bool

Check if the customer is registered

func IsSilent

func IsSilent() bool

func IsSubmitted added in v1.0.65

func IsSubmitted(clusterConfig *ClusterConfig) bool

Check if the customer is submitted

func PrettyJson added in v1.0.37

func PrettyJson(data interface{}) ([]byte, error)

func ProgressTextDisplay

func ProgressTextDisplay(str string)

func ScanStartDisplay

func ScanStartDisplay()

func SetKeyValueInConfigJson added in v1.0.47

func SetKeyValueInConfigJson(key string, value string) error

func SetSilentMode

func SetSilentMode(s bool)

func StartSpinner

func StartSpinner()

func StopSpinner

func StopSpinner()

func StringInSlice

func StringInSlice(strSlice []string, str string) int

func SuccessTextDisplay

func SuccessTextDisplay(str string)

Types

type ClusterConfig added in v1.0.42

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

func NewClusterConfig added in v1.0.42

func NewClusterConfig(k8s *k8sinterface.KubernetesApi, backendAPI getter.IBackend) *ClusterConfig

func (*ClusterConfig) GenerateURL added in v1.0.42

func (c *ClusterConfig) GenerateURL()

func (*ClusterConfig) GetBackendAPI added in v1.0.65

func (c *ClusterConfig) GetBackendAPI() getter.IBackend

func (*ClusterConfig) GetClusterName added in v1.0.84

func (c *ClusterConfig) GetClusterName() string

func (*ClusterConfig) GetConfigObj added in v1.0.65

func (c *ClusterConfig) GetConfigObj() *ConfigObj

func (*ClusterConfig) GetCustomerGUID added in v1.0.42

func (c *ClusterConfig) GetCustomerGUID() string

func (*ClusterConfig) GetDefaultNS added in v1.0.65

func (c *ClusterConfig) GetDefaultNS() string

func (*ClusterConfig) GetK8sAPI added in v1.0.65

func (c *ClusterConfig) GetK8sAPI() *k8sinterface.KubernetesApi

func (*ClusterConfig) GetValueByKeyFromConfigMap added in v1.0.47

func (c *ClusterConfig) GetValueByKeyFromConfigMap(key string) (string, error)

func (*ClusterConfig) LoadConfig added in v1.0.65

func (c *ClusterConfig) LoadConfig()

func (*ClusterConfig) SetConfig added in v1.0.84

func (c *ClusterConfig) SetConfig(customerGUID string) error

func (*ClusterConfig) SetKeyValueInConfigmap added in v1.0.47

func (c *ClusterConfig) SetKeyValueInConfigmap(key string, value string) error

func (*ClusterConfig) ToMapString added in v1.0.42

func (c *ClusterConfig) ToMapString() map[string]interface{}

type ComponentConfig

type ComponentConfig struct {
	Exceptions Exception `json:"exceptions"`
}

type ConfigObj added in v1.0.42

type ConfigObj struct {
	CustomerGUID       string `json:"customerGUID"`
	Token              string `json:"invitationParam"`
	CustomerAdminEMail string `json:"adminMail"`
	ClusterName        string `json:"clusterName"`
}

func (*ConfigObj) Config added in v1.0.84

func (co *ConfigObj) Config() []byte

Config - convert ConfigObj to config file

func (*ConfigObj) Json added in v1.0.42

func (co *ConfigObj) Json() []byte

type DownloadInfo added in v1.0.35

type DownloadInfo struct {
	Path          string
	FrameworkName string
	ControlName   string
}

type EmptyConfig added in v1.0.44

type EmptyConfig struct {
}

====================================================================================== ============================= Mock Config ============================================ ======================================================================================

func NewEmptyConfig added in v1.0.44

func NewEmptyConfig() *EmptyConfig

func (*EmptyConfig) GenerateURL added in v1.0.44

func (c *EmptyConfig) GenerateURL()

func (*EmptyConfig) GetBackendAPI added in v1.0.65

func (c *EmptyConfig) GetBackendAPI() getter.IBackend

func (*EmptyConfig) GetClusterName added in v1.0.84

func (c *EmptyConfig) GetClusterName() string

func (*EmptyConfig) GetConfigObj added in v1.0.65

func (c *EmptyConfig) GetConfigObj() *ConfigObj

func (*EmptyConfig) GetCustomerGUID added in v1.0.44

func (c *EmptyConfig) GetCustomerGUID() string

func (*EmptyConfig) GetDefaultNS added in v1.0.65

func (c *EmptyConfig) GetDefaultNS() string

func (*EmptyConfig) GetK8sAPI added in v1.0.65

func (c *EmptyConfig) GetK8sAPI() *k8sinterface.KubernetesApi

func (*EmptyConfig) SetConfig added in v1.0.84

func (c *EmptyConfig) SetConfig(customerGUID string) error

type Exception

type Exception struct {
	Ignore        *bool                      `json:"ignore"`        // ignore test results
	MultipleScore *reporthandling.AlertScore `json:"multipleScore"` // MultipleScore number - float32
	Namespaces    []string                   `json:"namespaces"`
	Regex         string                     `json:"regex"` // not supported
}

type Getters added in v1.0.36

type Getters struct {
	ExceptionsGetter getter.IExceptionsGetter
	PolicyGetter     getter.IPolicyGetter
}

type IClusterConfig added in v1.0.42

type IClusterConfig interface {

	// set
	SetConfig(customerGUID string) error

	// getters
	GetClusterName() string
	GetCustomerGUID() string
	GetConfigObj() *ConfigObj
	GetK8sAPI() *k8sinterface.KubernetesApi
	GetBackendAPI() getter.IBackend
	GetDefaultNS() string
	GenerateURL()
}

====================================================================================== =============================== interface ============================================ ======================================================================================

func ClusterConfigSetup added in v1.0.65

func ClusterConfigSetup(scanInfo *ScanInfo, k8s *k8sinterface.KubernetesApi, beAPI getter.IBackend) IClusterConfig

ClusterConfigSetup - Setup the desired cluster behavior regarding submittion to the Armo BE

type K8SResources

type K8SResources map[string]interface{}

K8SResources map[<api group>/<api version>/<resource>]<resource object>

type OPASessionObj

type OPASessionObj struct {
	Frameworks    []reporthandling.Framework
	K8SResources  *K8SResources
	Exceptions    []armotypes.PostureExceptionPolicy
	PostureReport *reporthandling.PostureReport
}

func NewOPASessionObj

func NewOPASessionObj(frameworks []reporthandling.Framework, k8sResources *K8SResources) *OPASessionObj

func NewOPASessionObjMock

func NewOPASessionObjMock() *OPASessionObj

type ScanInfo added in v1.0.35

type ScanInfo struct {
	Getters
	PolicyIdentifier   []reporthandling.PolicyIdentifier
	UseExceptions      string   // Load exceptions configuration
	UseFrom            []string // Load framework from local file (instead of download). Use when running offline
	UseDefault         bool     // Load framework from cached file (instead of download). Use when running offline
	Format             string   // Format results (table, json, junit ...)
	Output             string   // Store results in an output file, Output file name
	ExcludedNamespaces string   // DEPRECATED?
	InputPatterns      []string // Yaml files input patterns
	Silent             bool     // Silent mode - Do not print progress logs
	FailThreshold      uint16   // Failure score threshold
	Submit             bool     // Submit results to Armo BE
	Local              bool     // Do not submit results
	Account            string   // account ID
	FrameworkScan      bool     // false if scanning control
}

func (*ScanInfo) Init added in v1.0.35

func (scanInfo *ScanInfo) Init()

func (*ScanInfo) ScanRunningCluster added in v1.0.35

func (scanInfo *ScanInfo) ScanRunningCluster() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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