util

package
v0.0.0-...-c4270dd Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package util contains helper functions needed by unit tests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnnotateNS

func AnnotateNS(name, key, value string) error

AnnotateNS function

func AnnotationsMatch

func AnnotationsMatch(pod corev1.Pod, ants []string) bool

func DeleteAllHsp

func DeleteAllHsp() error

DeleteAllHsp delete all the kubearmorhostpolicies

func DeleteAllKsp

func DeleteAllKsp() error

DeleteAllKsp delete all the kubearmorpolicies from all namespaces

func DeleteKAConfigMap

func DeleteKAConfigMap() error

DeleteKAConfigMap function

func GetK8sClient

func GetK8sClient() *kcli.Client

GetK8sClient function return instance of k8s client

func GetOperations

func GetOperations(logs []*pb.Log) []string

GetOperations Function

func IsOperationsExpected

func IsOperationsExpected(operations []string, expected []string) bool

IsOperationsExpected validates what KubeArmor Operation is expected based on visibility configuration

func K8sApply

func K8sApply(files []string) error

K8sApply execute

func K8sApplyFile

func K8sApplyFile(fileName string) error

K8sApplyFile can apply deployments, services, namespace, and kubearmorhostpolicy

func K8sCRIRuntime

func K8sCRIRuntime() string

K8sCRIRuntime extracts Container Runtime from the Kubernetes API

func K8sDaemonSetCheck

func K8sDaemonSetCheck(dsname string, ns string, timeout time.Duration) error

K8sDaemonSetCheck Check if the daemonset exists and is ready

func K8sDelete

func K8sDelete(files []string) error

K8sDelete Delete

func K8sDeploymentCheck

func K8sDeploymentCheck(depname string, ns string, timeout time.Duration) error

K8sDeploymentCheck Check if the deployment exists and is ready

func K8sExecInPod

func K8sExecInPod(pod string, ns string, cmd []string) (string, string, error)

K8sExecInPod Exec into the pod. Output: stdout, stderr, err

func K8sExecInPodWithContainer

func K8sExecInPodWithContainer(pod string, ns string, container string, cmd []string) (string, string, error)

K8sExecInPodWithContainer Exec into the pod. Output: stdout, stderr, err

func K8sGetPods

func K8sGetPods(podstr string, ns string, ants []string, timeout int) ([]string, error)

K8sGetPods Check if Pods exists and is/are Running

func K8sPortForward

func K8sPortForward(pf PortForwardOpt) (chan struct{}, error)

K8sPortForward enable port forwarding

func K8sRuntimeEnforcer

func K8sRuntimeEnforcer() string

K8sRuntimeEnforcer extracts Runtime Enforcer from the Node Labels

func KarmorGetLogs

func KarmorGetLogs(timeout time.Duration, maxEvents int) ([]*pb.Log, []*pb.Alert, error)

KarmorGetLogs waits for logs from kubearmor. KarmorQueueLog() has to be called before this so that the channel is established.

func KarmorLogStart

func KarmorLogStart(logFilter string, ns string, op string, pod string) error

KarmorLogStart start observing for kubearmor telemetry events

func KarmorLogStop

func KarmorLogStop()

KarmorLogStop stops the kubearmor-client observer

func KspDeleteAll

func KspDeleteAll()

KspDeleteAll Delete all the kubearmor security policies

func KubearmorPortForward

func KubearmorPortForward() error

KubearmorPortForward enable port forwarding for kubearmor

func KubearmorPortForwardStop

func KubearmorPortForwardStop()

KubearmorPortForwardStop stop kubearmor port forwarding

func Kubectl

func Kubectl(cmdstr string) (string, error)

Kubectl execute

func RandString

func RandString(n int) string

RandString Get Random string

Types

type ConditionFunc

type ConditionFunc func() (done bool, err error)

ConditionFunc functions that fulfills the condition handling

type ConfigMapData

type ConfigMapData struct {
	GRPC                       string
	Visibility                 string
	Cluster                    string
	DefaultFilePosture         string
	DefaultCapabilitiesPosture string
	DefaultNetworkPosture      string
}

ConfigMapData hosts the structure which is used to configure Config Map Data

func NewDefaultConfigMapData

func NewDefaultConfigMapData() *ConfigMapData

NewDefaultConfigMapData returns Config Map Data with KubeArmor defaults set

func (*ConfigMapData) CreateKAConfigMap

func (data *ConfigMapData) CreateKAConfigMap() error

CreateKAConfigMap function

type EventResult

type EventResult struct {
	Alerts []*pb.Alert
	Logs   []*pb.Log
	Found  bool
}

EventResult type

func KarmorGetTargetAlert

func KarmorGetTargetAlert(timeout time.Duration, target *pb.Alert) (EventResult, error)

KarmorGetTargetAlert looks for target alert in telemetry events

func KarmorGetTargetLogs

func KarmorGetTargetLogs(timeout time.Duration, target *pb.Log) (EventResult, error)

KarmorGetTargetLogs waits for logs from kubearmor. KarmorLogStart() has to be called before this so that the channel is established.

type PortForwardOpt

type PortForwardOpt struct {
	LocalPort   int
	RemotePort  int
	ServiceName string
	Namespace   string
}

PortForwardOpt port forwarding options

Jump to

Keyboard shortcuts

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