Documentation
¶
Index ¶
- Variables
- type CgroupDir
- type Container
- type ContainerPathResolver
- func (cPathRes *ContainerPathResolver) GetHostAbsPath(mountNSAbsolutePath string, mountNS uint32) (string, error)
- func (cPathRes *ContainerPathResolver) GetProcMounts(mountNS uint32) (string, error)
- func (cPathRes *ContainerPathResolver) ResolveAllLinks(mountNSAbsolutePath string, mountNS uint32) (string, error)
- func (cPathRes *ContainerPathResolver) ResolveLink(mountNSAbsolutePath string, mountNS uint32) (string, error)
- type ContainersSymbolsLoader
- func (cLoader *ContainersSymbolsLoader) GetDynamicSymbols(soInfo sharedobjs.ObjInfo) (map[string]bool, error)
- func (cLoader *ContainersSymbolsLoader) GetExportedSymbols(soInfo sharedobjs.ObjInfo) (map[string]bool, error)
- func (cLoader *ContainersSymbolsLoader) GetImportedSymbols(soInfo sharedobjs.ObjInfo) (map[string]bool, error)
- func (cLoader *ContainersSymbolsLoader) GetLocalSymbols(soInfo sharedobjs.ObjInfo) (map[string]bool, error)
- type Manager
- func (c *Manager) AddContainer(cont Container) error
- func (c *Manager) CgroupExists(cgroupId uint64) bool
- func (c *Manager) CgroupMkdir(cgroupId uint64, subPath string, hierarchyID uint32) (CgroupDir, Container, error)
- func (c *Manager) CgroupRemove(cgroupId uint64, hierarchyID uint32)
- func (c *Manager) Close() error
- func (c *Manager) EnrichCgroupInfo(cgroupId uint64) (Container, error)
- func (c *Manager) FindContainerCgroupID32LSB(containerID string) ([]uint32, error)
- func (c *Manager) GetCgroupInfo(cgroupId uint64) (CgroupDir, Container)
- func (c *Manager) GetCgroupVersion() cgroup.CgroupVersion
- func (c *Manager) GetContainer(containerId string) (Container, error)
- func (c *Manager) GetDefaultCgroupHierarchyID() int
- func (c *Manager) GetLiveContainers() map[uint32]Container
- func (c *Manager) Populate() error
- func (c *Manager) PopulateBpfMap(bpfModule *libbpfgo.Module) error
- func (c *Manager) RemoveContainer(cont Container) error
- func (c *Manager) RemoveFromBPFMap(bpfModule *libbpfgo.Module, cgroupId uint64, hierarchyID uint32) error
- type Pod
- type SignaturesDataSource
- func (ctx SignaturesDataSource) Get(key interface{}) (map[string]interface{}, error)
- func (ctx SignaturesDataSource) ID() string
- func (ctx SignaturesDataSource) Keys() []string
- func (ctx SignaturesDataSource) Namespace() string
- func (ctx SignaturesDataSource) Schema() string
- func (ctx SignaturesDataSource) Version() uint
Constants ¶
This section is empty.
Variables ¶
var ( ErrContainerFSUnreachable = errors.New("container file system is unreachable in mount namespace because there are not living children") ErrNonAbsolutePath = errors.New("file path is not absolute in its container mount point") )
Functions ¶
This section is empty.
Types ¶
type CgroupDir ¶
type CgroupDir struct {
Path string
ContainerId string
ContainerRoot bool // is the cgroup directory the root of its container
Ctime time.Time
Dead bool // is the cgroup deleted
// contains filtered or unexported fields
}
CgroupDir represents a cgroup dir (which may be a container cgroup dir).
type ContainerPathResolver ¶
type ContainerPathResolver struct {
// contains filtered or unexported fields
}
ContainerPathResolver generates an accessible absolute path from the root mount namespace to a relative path in a container. **NOTE**: to resolve host mount namespace, tracee reads from /proc/1/ns, requiring CAP_SYS_PTRACE capability.
func InitContainerPathResolver ¶
func InitContainerPathResolver(mountNSPIDsCache *bucketcache.BucketCache) *ContainerPathResolver
InitContainerPathResolver creates a resolver for paths from within containers.
func (*ContainerPathResolver) GetHostAbsPath ¶
func (cPathRes *ContainerPathResolver) GetHostAbsPath(mountNSAbsolutePath string, mountNS uint32) ( string, error, )
GetHostAbsPath translates an absolute path, which might be inside a container, to the correspondent abs path in the host mount namespace.
func (*ContainerPathResolver) GetProcMounts ¶
func (cPathRes *ContainerPathResolver) GetProcMounts(mountNS uint32) (string, error)
GetProcMounts returns the path of a /proc/<pid>/mounts file for any process in the given mount namespace. It first tries to use cached PIDs for the namespace, and falls back to searching procfs.
Parameters:
- mountNS: mount namespace ID
Returns the path to a valid /proc/<pid>/mounts file for the namespace.
func (*ContainerPathResolver) ResolveAllLinks ¶
func (cPathRes *ContainerPathResolver) ResolveAllLinks(mountNSAbsolutePath string, mountNS uint32) ( string, error, )
ResolveAllLinks resolves all symlinks in a path component by component. This method processes each path component individually, resolving any symlinks encountered at each level. This provides comprehensive symlink resolution for the entire path.
Parameters:
- mountNSAbsolutePath: absolute path within the mount namespace
- mountNS: mount namespace ID
Returns the fully resolved path with all symlinks resolved.
func (*ContainerPathResolver) ResolveLink ¶
func (cPathRes *ContainerPathResolver) ResolveLink(mountNSAbsolutePath string, mountNS uint32) ( string, error, )
ResolveLink resolves a single symlink to its final destination within the specified mount namespace. It follows symlinks until it reaches a non-symlink target or detects a loop. The resolution is performed from the perspective of the mount namespace, ensuring security by validating that resolved paths don't escape the namespace boundary.
Parameters:
- mountNSAbsolutePath: absolute path within the mount namespace
- mountNS: mount namespace ID
Returns the resolved path within the mount namespace context.
type ContainersSymbolsLoader ¶
type ContainersSymbolsLoader struct {
// contains filtered or unexported fields
}
ContainersSymbolsLoader is a decorator for SO loaders that resolves containers-relative paths to absolute host paths. This object operation requires the CAP_DAC_OVERRIDE to access files across the system.
func InitContainersSymbolsLoader ¶
func InitContainersSymbolsLoader(pathResolver *ContainerPathResolver, cacheSize int) *ContainersSymbolsLoader
func (*ContainersSymbolsLoader) GetDynamicSymbols ¶
func (cLoader *ContainersSymbolsLoader) GetDynamicSymbols(soInfo sharedobjs.ObjInfo) (map[string]bool, error)
func (*ContainersSymbolsLoader) GetExportedSymbols ¶
func (cLoader *ContainersSymbolsLoader) GetExportedSymbols(soInfo sharedobjs.ObjInfo) (map[string]bool, error)
func (*ContainersSymbolsLoader) GetImportedSymbols ¶
func (cLoader *ContainersSymbolsLoader) GetImportedSymbols(soInfo sharedobjs.ObjInfo) (map[string]bool, error)
func (*ContainersSymbolsLoader) GetLocalSymbols ¶
func (cLoader *ContainersSymbolsLoader) GetLocalSymbols(soInfo sharedobjs.ObjInfo) (map[string]bool, error)
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager contains information about running containers in the host.
func New ¶
func New( noContainersEnrich bool, cgroups *cgroup.Cgroups, sockets runtime.Sockets, mapName string, ) ( *Manager, error, )
New initializes a Containers object and returns a pointer to it. User should further call "Populate" and iterate with Containers data.
func (*Manager) AddContainer ¶
func (*Manager) CgroupExists ¶
CgroupExists checks if there is a cgroupInfo data of a given cgroupId.
func (*Manager) CgroupMkdir ¶
func (c *Manager) CgroupMkdir(cgroupId uint64, subPath string, hierarchyID uint32) (CgroupDir, Container, error)
CgroupMkdir adds cgroupInfo of a created cgroup dir to Containers struct.
func (*Manager) CgroupRemove ¶
CgroupRemove removes cgroupInfo of deleted cgroup dir from Containers struct. There is an expiration logic of 30 seconds to avoid race conditions (if cgroup dir event arrives too fast and its cgroupInfo data is still needed).
func (*Manager) EnrichCgroupInfo ¶
EnrichCgroupInfo checks for a given cgroupId if it is relevant to some running container. It then calls the runtime info service to gather additional data from the container's runtime. Should not be called twice for the same cgroupId unless attempting a retry.
Returns the retrieved metadata and a relevant error. If the given cgroup does not belong to a container, no error will be returned, but the returned metadata's containerId will be empty. This should be checked separately.
func (*Manager) FindContainerCgroupID32LSB ¶
FindContainerCgroupID32LSB returns the 32 LSB of the Cgroup ID for a given container ID.
func (*Manager) GetCgroupInfo ¶
GetCgroupInfo returns the contents of the Containers struct cgroupInfo data of a given cgroupId.
func (*Manager) GetCgroupVersion ¶
func (c *Manager) GetCgroupVersion() cgroup.CgroupVersion
func (*Manager) GetContainer ¶
func (*Manager) GetDefaultCgroupHierarchyID ¶
func (*Manager) GetLiveContainers ¶
GetLiveContainers provides a list of all existing containers mapped by their cgroup id.
func (*Manager) Populate ¶
Populate populates Containers struct by reading mounted proc and cgroups fs.
func (*Manager) PopulateBpfMap ¶
PopulateBpfMap populates the map with all the existing containers so eBPF programs can orchestrate new ones with the correct state.
func (*Manager) RemoveContainer ¶
type SignaturesDataSource ¶
type SignaturesDataSource struct {
// contains filtered or unexported fields
}
func NewDataSource ¶
func NewDataSource(c *Manager) *SignaturesDataSource
func (SignaturesDataSource) Get ¶
func (ctx SignaturesDataSource) Get(key interface{}) (map[string]interface{}, error)
func (SignaturesDataSource) ID ¶
func (ctx SignaturesDataSource) ID() string
func (SignaturesDataSource) Keys ¶
func (ctx SignaturesDataSource) Keys() []string
func (SignaturesDataSource) Namespace ¶
func (ctx SignaturesDataSource) Namespace() string
func (SignaturesDataSource) Schema ¶
func (ctx SignaturesDataSource) Schema() string
func (SignaturesDataSource) Version ¶
func (ctx SignaturesDataSource) Version() uint