hostsensormanager

package
v0.3.19 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// API group and version for host data CRDs
	HostDataGroup   = "hostdata.kubescape.cloud"
	HostDataVersion = "v1beta1"
)

Variables

View Source
var (
	ProcNetTCPPaths  = []string{"/proc/net/tcp", "/proc/net/tcp6"}
	ProcNetUDPPaths  = []string{"/proc/net/udp", "/proc/net/udp6", "/proc/net/udplite", "/proc/net/udplite6"}
	ProcNetICMPPaths = []string{"/proc/net/icmp", "/proc/net/icmp6"}
)

Functions

This section is empty.

Types

type ApiServerInfo

type ApiServerInfo struct {
	EncryptionProviderConfigFile *FileInfo `json:"encryptionProviderConfigFile,omitempty"`
	AuditPolicyFile              *FileInfo `json:"auditPolicyFile,omitempty"`
	ProcessInfo                  `json:",inline"`
}

type CNIInfo

type CNIInfo struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   CNIInfoSpec `json:"spec,omitempty"`
	Status Status      `json:"status,omitempty"`
}

CNIInfo represents the CRD structure for CNI info data

type CNIInfoSensor

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

CNIInfoSensor implements the Sensor interface for CNI info data

func NewCNIInfoSensor

func NewCNIInfoSensor(nodeName string) *CNIInfoSensor

NewCNIInfoSensor creates a new CNI info sensor

func (*CNIInfoSensor) GetKind

func (s *CNIInfoSensor) GetKind() string

GetKind returns the CRD kind for this sensor

func (*CNIInfoSensor) GetPluralKind

func (s *CNIInfoSensor) GetPluralKind() string

GetPluralKind returns the plural and lowercase form of CRD kind for this sensor

func (*CNIInfoSensor) Sense

func (s *CNIInfoSensor) Sense() (interface{}, error)

Sense collects the CNI info data from the host

type CNIInfoSpec

type CNIInfoSpec struct {
	CNIConfigFiles []*FileInfo `json:"CNIConfigFiles,omitempty"`
	CNINames       []string    `json:"CNINames,omitempty"`
	NodeName       string      `json:"nodeName"`
}

type CRDClient

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

CRDClient handles Kubernetes CRD operations

func NewCRDClient

func NewCRDClient(nodeName string) (*CRDClient, error)

NewCRDClient creates a new CRD client

func (*CRDClient) CreateOrUpdateHostData

func (c *CRDClient) CreateOrUpdateHostData(ctx context.Context, resource string, kind string, spec interface{}) error

CreateOrUpdateHostData creates or updates a host data CRD

func (*CRDClient) UpdateStatus

func (c *CRDClient) UpdateStatus(ctx context.Context, resource string, errorMsg string) error

UpdateStatus updates the status of a host data CRD with an error

type CloudProviderInfo

type CloudProviderInfo struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   CloudProviderInfoSpec `json:"spec,omitempty"`
	Status Status                `json:"status,omitempty"`
}

CloudProviderInfo represents the CRD structure for cloud provider info data

type CloudProviderInfoSensor

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

CloudProviderInfoSensor implements the Sensor interface for cloud provider info data

func NewCloudProviderInfoSensor

func NewCloudProviderInfoSensor(nodeName string) *CloudProviderInfoSensor

NewCloudProviderInfoSensor creates a new cloud provider info sensor

func (*CloudProviderInfoSensor) GetKind

func (s *CloudProviderInfoSensor) GetKind() string

GetKind returns the CRD kind for this sensor

func (*CloudProviderInfoSensor) GetPluralKind

func (s *CloudProviderInfoSensor) GetPluralKind() string

GetPluralKind returns the plural and lowercase form of CRD kind for this sensor

func (*CloudProviderInfoSensor) Sense

func (s *CloudProviderInfoSensor) Sense() (interface{}, error)

Sense collects the cloud provider info data from the host

type CloudProviderInfoSpec

type CloudProviderInfoSpec struct {
	ProviderMetaDataAPIAccess bool   `json:"providerMetaDataAPIAccess"`
	NodeName                  string `json:"nodeName"`
}

type Config

type Config struct {
	Enabled  bool
	Interval time.Duration
	NodeName string
}

Config holds the configuration for the host sensor manager

type Connection

type Connection struct {
	Transport     string `json:"transport"`
	LocalAddress  string `json:"localAddress"`
	LocalPort     uint16 `json:"localPort"`
	RemoteAddress string `json:"remoteAddress"`
	RemotePort    uint16 `json:"remotePort"`
}

Connection represents a network connection (minimal version of procspy.Connection)

type ControlPlaneInfo

type ControlPlaneInfo struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   ControlPlaneInfoSpec `json:"spec,omitempty"`
	Status Status               `json:"status,omitempty"`
}

ControlPlaneInfo represents the CRD structure for control plane info data

type ControlPlaneInfoSensor

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

ControlPlaneInfoSensor implements the Sensor interface for control plane info data

func NewControlPlaneInfoSensor

func NewControlPlaneInfoSensor(nodeName string) *ControlPlaneInfoSensor

NewControlPlaneInfoSensor creates a new control plane info sensor

func (*ControlPlaneInfoSensor) GetKind

func (s *ControlPlaneInfoSensor) GetKind() string

GetKind returns the CRD kind for this sensor

func (*ControlPlaneInfoSensor) GetPluralKind

func (s *ControlPlaneInfoSensor) GetPluralKind() string

GetPluralKind returns the plural and lowercase form of CRD kind for this sensor

func (*ControlPlaneInfoSensor) Sense

func (s *ControlPlaneInfoSensor) Sense() (interface{}, error)

Sense collects the control plane info data from the host

type ControlPlaneInfoSpec

type ControlPlaneInfoSpec struct {
	APIServerInfo         *ApiServerInfo `json:"APIServerInfo,omitempty"`
	ControllerManagerInfo *ProcessInfo   `json:"controllerManagerInfo,omitempty"`
	SchedulerInfo         *ProcessInfo   `json:"schedulerInfo,omitempty"`
	EtcdConfigFile        *FileInfo      `json:"etcdConfigFile,omitempty"`
	EtcdDataDir           *FileInfo      `json:"etcdDataDir,omitempty"`
	AdminConfigFile       *FileInfo      `json:"adminConfigFile,omitempty"`
	PKIDir                *FileInfo      `json:"PKIDir,omitempty"`
	PKIFiles              []*FileInfo    `json:"PKIFiles,omitempty"`
	NodeName              string         `json:"nodeName"`
}

type FileInfo

type FileInfo struct {
	Ownership   *FileOwnership `json:"ownership"`
	Path        string         `json:"path"`
	Content     []byte         `json:"content,omitempty"`
	Permissions int            `json:"permissions"`
}

FileInfo holds information about a file

func MakeChangedRootFileInfo

func MakeChangedRootFileInfo(rootDir string, filePath string, readContent bool) (*FileInfo, error)

MakeChangedRootFileInfo makes a file info object for the given path on the given root directory.

func MakeFileInfo

func MakeFileInfo(filePath string, readContent bool) (*FileInfo, error)

MakeFileInfo returns a FileInfo object for given path

type FileOwnership

type FileOwnership struct {
	Err       string `json:"err,omitempty"`
	UID       int64  `json:"uid"`
	GID       int64  `json:"gid"`
	Username  string `json:"username"`
	Groupname string `json:"groupname"`
}

FileOwnership holds the ownership of a file

type HostSensorManager

type HostSensorManager interface {
	// Start begins the sensing loop
	Start(ctx context.Context) error
	// Stop gracefully stops the manager
	Stop() error
}

HostSensorManager manages the lifecycle of host sensors

func NewHostSensorManager

func NewHostSensorManager(config Config) (HostSensorManager, error)

NewHostSensorManager creates a new host sensor manager

func NewNoopHostSensorManager

func NewNoopHostSensorManager() HostSensorManager

NewNoopHostSensorManager creates a new no-op host sensor manager

type KernelVariable

type KernelVariable struct {
	Key    string `json:"key"`
	Value  string `json:"value"`
	Source string `json:"source"`
}

KernelVariable represents a single kernel variable

type KernelVersion

type KernelVersion struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   KernelVersionSpec `json:"spec,omitempty"`
	Status Status            `json:"status,omitempty"`
}

KernelVersion represents the CRD structure for kernel version data

type KernelVersionSensor

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

KernelVersionSensor implements the Sensor interface for kernel version data

func NewKernelVersionSensor

func NewKernelVersionSensor(nodeName string) *KernelVersionSensor

NewKernelVersionSensor creates a new kernel version sensor

func (*KernelVersionSensor) GetKind

func (s *KernelVersionSensor) GetKind() string

GetKind returns the CRD kind for this sensor

func (*KernelVersionSensor) GetPluralKind

func (s *KernelVersionSensor) GetPluralKind() string

GetPluralKind returns the plural and lowercase form of CRD kind for this sensor

func (*KernelVersionSensor) Sense

func (s *KernelVersionSensor) Sense() (interface{}, error)

Sense collects the kernel version data from the host

type KernelVersionSpec

type KernelVersionSpec struct {
	Content  string `json:"content"`
	NodeName string `json:"nodeName"`
}

type KubeProxyInfo

type KubeProxyInfo struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   KubeProxyInfoSpec `json:"spec,omitempty"`
	Status Status            `json:"status,omitempty"`
}

KubeProxyInfo represents the CRD structure for kube-proxy info data

type KubeProxyInfoSensor

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

KubeProxyInfoSensor implements the Sensor interface for kube-proxy info data

func NewKubeProxyInfoSensor

func NewKubeProxyInfoSensor(nodeName string) *KubeProxyInfoSensor

NewKubeProxyInfoSensor creates a new kube-proxy info sensor

func (*KubeProxyInfoSensor) GetKind

func (s *KubeProxyInfoSensor) GetKind() string

GetKind returns the CRD kind for this sensor

func (*KubeProxyInfoSensor) GetPluralKind

func (s *KubeProxyInfoSensor) GetPluralKind() string

GetPluralKind returns the plural and lowercase form of CRD kind for this sensor

func (*KubeProxyInfoSensor) Sense

func (s *KubeProxyInfoSensor) Sense() (interface{}, error)

Sense collects the kube-proxy info data from the host

type KubeProxyInfoSpec

type KubeProxyInfoSpec struct {
	KubeConfigFile *FileInfo `json:"kubeConfigFile,omitempty"`
	CmdLine        string    `json:"cmdLine"`
	NodeName       string    `json:"nodeName"`
}

type KubeletInfo

type KubeletInfo struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   KubeletInfoSpec `json:"spec,omitempty"`
	Status Status          `json:"status,omitempty"`
}

KubeletInfo represents the CRD structure for kubelet info data

type KubeletInfoSensor

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

KubeletInfoSensor implements the Sensor interface for kubelet info data

func NewKubeletInfoSensor

func NewKubeletInfoSensor(nodeName string) *KubeletInfoSensor

NewKubeletInfoSensor creates a new kubelet info sensor

func (*KubeletInfoSensor) GetKind

func (s *KubeletInfoSensor) GetKind() string

GetKind returns the CRD kind for this sensor

func (*KubeletInfoSensor) GetPluralKind

func (s *KubeletInfoSensor) GetPluralKind() string

GetPluralKind returns the plural and lowercase form of CRD kind for this sensor

func (*KubeletInfoSensor) Sense

func (s *KubeletInfoSensor) Sense() (interface{}, error)

Sense collects the kubelet info data from the host

type KubeletInfoSpec

type KubeletInfoSpec struct {
	ServiceFiles   []FileInfo `json:"serviceFiles,omitempty"`
	ConfigFile     *FileInfo  `json:"configFile,omitempty"`
	KubeConfigFile *FileInfo  `json:"kubeConfigFile,omitempty"`
	ClientCAFile   *FileInfo  `json:"clientCAFile,omitempty"`
	CmdLine        string     `json:"cmdLine"`
	NodeName       string     `json:"nodeName"`
}

type LinuxKernelVariables

type LinuxKernelVariables struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   LinuxKernelVariablesSpec `json:"spec,omitempty"`
	Status Status                   `json:"status,omitempty"`
}

LinuxKernelVariables represents the CRD structure for kernel variables data

type LinuxKernelVariablesSensor

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

LinuxKernelVariablesSensor implements the Sensor interface for kernel variables data

func NewLinuxKernelVariablesSensor

func NewLinuxKernelVariablesSensor(nodeName string) *LinuxKernelVariablesSensor

NewLinuxKernelVariablesSensor creates a new kernel variables sensor

func (*LinuxKernelVariablesSensor) GetKind

func (s *LinuxKernelVariablesSensor) GetKind() string

GetKind returns the CRD kind for this sensor

func (*LinuxKernelVariablesSensor) GetPluralKind

func (s *LinuxKernelVariablesSensor) GetPluralKind() string

GetPluralKind returns the plural and lowercase form of CRD kind for this sensor

func (*LinuxKernelVariablesSensor) Sense

func (s *LinuxKernelVariablesSensor) Sense() (interface{}, error)

Sense collects the kernel variables data from the host

type LinuxKernelVariablesSpec

type LinuxKernelVariablesSpec struct {
	KernelVariables []KernelVariable `json:"kernelVariables"`
	NodeName        string           `json:"nodeName"`
}

type LinuxSecurityHardening

type LinuxSecurityHardening struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   LinuxSecurityHardeningSpec `json:"spec,omitempty"`
	Status Status                     `json:"status,omitempty"`
}

LinuxSecurityHardening represents the CRD structure for security hardening data

type LinuxSecurityHardeningSensor

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

LinuxSecurityHardeningSensor implements the Sensor interface for security hardening data

func NewLinuxSecurityHardeningSensor

func NewLinuxSecurityHardeningSensor(nodeName string) *LinuxSecurityHardeningSensor

NewLinuxSecurityHardeningSensor creates a new security hardening sensor

func (*LinuxSecurityHardeningSensor) GetKind

func (s *LinuxSecurityHardeningSensor) GetKind() string

GetKind returns the CRD kind for this sensor

func (*LinuxSecurityHardeningSensor) GetPluralKind

func (s *LinuxSecurityHardeningSensor) GetPluralKind() string

GetPluralKind returns the plural and lowercase form of CRD kind for this sensor

func (*LinuxSecurityHardeningSensor) Sense

func (s *LinuxSecurityHardeningSensor) Sense() (interface{}, error)

Sense collects the security hardening data from the host

type LinuxSecurityHardeningSpec

type LinuxSecurityHardeningSpec struct {
	AppArmor string `json:"appArmor"`
	SeLinux  string `json:"seLinux"`
	NodeName string `json:"nodeName"`
}

type OpenPorts

type OpenPorts struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   OpenPortsSpec `json:"spec,omitempty"`
	Status Status        `json:"status,omitempty"`
}

OpenPorts represents the CRD structure for open ports data

type OpenPortsSensor

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

OpenPortsSensor implements the Sensor interface for open ports data

func NewOpenPortsSensor

func NewOpenPortsSensor(nodeName string) *OpenPortsSensor

NewOpenPortsSensor creates a new open ports sensor

func (*OpenPortsSensor) GetKind

func (s *OpenPortsSensor) GetKind() string

GetKind returns the CRD kind for this sensor

func (*OpenPortsSensor) GetPluralKind

func (s *OpenPortsSensor) GetPluralKind() string

GetPluralKind returns the plural and lowercase form of CRD kind for this sensor

func (*OpenPortsSensor) Sense

func (s *OpenPortsSensor) Sense() (interface{}, error)

Sense collects the open ports data from the host

type OpenPortsSpec

type OpenPortsSpec struct {
	TcpPorts  []Connection `json:"tcpPorts"`
	UdpPorts  []Connection `json:"udpPorts"`
	ICMPPorts []Connection `json:"icmpPorts"`
	NodeName  string       `json:"nodeName"`
}

type OsReleaseFile

type OsReleaseFile struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   OsReleaseFileSpec `json:"spec,omitempty"`
	Status Status            `json:"status,omitempty"`
}

OsReleaseFile represents the CRD structure for OS release data

type OsReleaseFileSpec

type OsReleaseFileSpec struct {
	Content  string `json:"content"`
	NodeName string `json:"nodeName"`
}

OsReleaseFileSpec contains the actual OS release file content

type OsReleaseSensor

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

OsReleaseSensor implements the Sensor interface for OS release data

func NewOsReleaseSensor

func NewOsReleaseSensor(nodeName string) *OsReleaseSensor

NewOsReleaseSensor creates a new OS release sensor

func (*OsReleaseSensor) GetKind

func (s *OsReleaseSensor) GetKind() string

GetKind returns the CRD kind for this sensor

func (*OsReleaseSensor) GetPluralKind

func (s *OsReleaseSensor) GetPluralKind() string

GetPluralKind returns the plural and lowercase form of CRD kind for this sensor

func (*OsReleaseSensor) Sense

func (s *OsReleaseSensor) Sense() (interface{}, error)

Sense collects the OS release data from the host

type ProcessDetails

type ProcessDetails struct {
	CmdLine []string `json:"cmdline"`
	PID     int32    `json:"pid"`
}

func LocateProcessByExecSuffix

func LocateProcessByExecSuffix(processSuffix string) (*ProcessDetails, error)

LocateProcessByExecSuffix locates process with executable name ends with processSuffix.

func (ProcessDetails) GetArg

func (p ProcessDetails) GetArg(argName string) (string, bool)

func (ProcessDetails) RawCmd

func (p ProcessDetails) RawCmd() string

func (ProcessDetails) RootDir

func (p ProcessDetails) RootDir() string

type ProcessInfo

type ProcessInfo struct {
	SpecsFile      *FileInfo `json:"specsFile,omitempty"`
	ConfigFile     *FileInfo `json:"configFile,omitempty"`
	KubeConfigFile *FileInfo `json:"kubeConfigFile,omitempty"`
	ClientCAFile   *FileInfo `json:"clientCAFile,omitempty"`
	CmdLine        string    `json:"cmdLine"`
}

type Sensor

type Sensor interface {
	// Sense collects the data from the host
	Sense() (interface{}, error)
	// GetKind returns the CRD kind for this sensor
	GetKind() string
	// GetPluralKind returns the plural and lowercase form of CRD kind for this sensor
	GetPluralKind() string
}

Sensor represents a single host sensor that can collect data

type Status

type Status struct {
	LastSensed metav1.Time `json:"lastSensed,omitempty"`
	Error      string      `json:"error,omitempty"`
}

Status contains status information about the sensing (common for all host data CRDs)

Jump to

Keyboard shortcuts

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