Documentation
¶
Index ¶
- Constants
- func AllProcs(path string) ([]int, error)
- func CmdLine(pid int) ([]string, error)
- func Environ(pid int) ([]string, error)
- func Executable(pid int) (string, error)
- func IsKernelProcess(pid int) (bool, error)
- type Cgroup
- type Container
- type ContainerEnricher
- type DefaultObserver
- type Eventer
- type ExeFilter
- type ExeRegexFilter
- type Filter
- type Manager
- func (m *Manager) Await(ctx context.Context, pid int) (*Process, error)
- func (m *Manager) Get(pid int) *Process
- func (m *Manager) MaskEnvVars(envVars []string)
- func (m *Manager) Observe(observer Observer)
- func (m *Manager) RegisterProcess(ctx context.Context, p *Process) error
- func (m *Manager) SetConfig(cfg *config.Config)
- func (m *Manager) SnapshotProcesses(fn func(pid int, p *Process) bool)
- func (m *Manager) Start() error
- func (m *Manager) Stop() error
- func (m *Manager) UnregisterProcess(ctx context.Context, pid, exitCode int) error
- type Observer
- type PIDFilter
- type Pod
- type Process
- func (p *Process) CacheKey() string
- func (p *Process) Close() error
- func (p *Process) ClosedAt() *time.Time
- func (p *Process) ControlValues() map[string]any
- func (p *Process) CreatedAt() time.Time
- func (p *Process) Discover(ctx context.Context, mountPoint string, envMask *synq.Map[string, bool]) error
- func (p *Process) Exited() bool
- func (p *Process) Filter() uint8
- func (p *Process) FullCmd() []string
- func (p *Process) Hostname() (string, error)
- func (p *Process) IsFiltered(flag ...config.FilterLevel) bool
- func (p *Process) Lock()
- func (p *Process) RootFS() string
- func (p *Process) SetDetectedTLSProbeTypes(types []string)
- func (p *Process) SetHostname(hostname string)
- func (p *Process) SetNotifier(n func() error)
- func (p *Process) SetTlsOk(tlsOk bool) error
- func (p *Process) SetUser(uid uint, user string)
- func (p *Process) Tags() tags.List
- func (p *Process) TlsOk() bool
- func (p *Process) Unlock()
- type ProcessUser
- type QpointStrategy
- type Receiver
- type TlsProbeError
Constants ¶
const ( QpointStrategyEnvVar = "QPOINT_STRATEGY" QpointTagsEnvVar = "QPOINT_TAGS" )
Variables ¶
This section is empty.
Functions ¶
func Executable ¶
Executable returns the absolute path to the executable of the process.
func IsKernelProcess ¶
IsKernelProcess returns true if the process is a kernel process.
Types ¶
type Cgroup ¶
type Cgroup struct {
// HierarchyID that can be matched to a named hierarchy using /proc/cgroups. Cgroups V2 only has one
// hierarchy, so HierarchyID is always 0. For cgroups v1 this is a unique ID number
HierarchyID int
// Controllers using this hierarchy of processes. Controllers are also known as subsystems. For
// Cgroups V2 this may be empty, as all active controllers use the same hierarchy
Controllers []string
// Path of this control group, relative to the mount point of the cgroupfs representing this specific
// hierarchy
Path string
}
Cgroup models one line from /proc/[pid]/cgroup. Each Cgroup struct describes the placement of a PID inside a specific control hierarchy. The kernel has two cgroup APIs, v1 and v2. v1 has one hierarchy per available resource controller, while v2 has one unified hierarchy shared by all controllers. Regardless of v1 or v2, all hierarchies contain all running processes, so the question answerable with a Cgroup struct is 'where is this process in this hierarchy' (where==what path on the specific cgroupfs). By prefixing this path with the mount point of *this specific* hierarchy, you can locate the relevant pseudo-files needed to read/set the data for this PID in this hierarchy
Also see http://man7.org/linux/man-pages/man7/cgroups.7.html
func Cgroups ¶
Cgroups reads from /proc/<pid>/cgroups and returns a []*Cgroup struct locating this PID in each process control hierarchy running on this system. On every system (v1 and v2), all hierarchies contain all processes, so the len of the returned struct is equal to the number of active hierarchies on this system.
type Container ¶
type Container struct {
ID string `json:"container_id,omitempty"`
Name string `json:"container_name,omitempty"`
Labels map[string]string `json:"container_labels,omitempty"`
Image string `json:"container_image,omitempty"`
ImageDigest string `json:"container_imageDigest,omitempty"`
RootFS string `json:"-"`
}
func (Container) ControlValues ¶
type ContainerEnricher ¶
type ContainerEnricher struct {
DefaultObserver
// contains filtered or unexported fields
}
func NewContainerEnricher ¶
func NewContainerEnricher(containerManager *container.Manager) *ContainerEnricher
func (*ContainerEnricher) ProcessStarted ¶
func (e *ContainerEnricher) ProcessStarted(ctx context.Context, p *Process) error
type DefaultObserver ¶
type DefaultObserver struct{}
func (*DefaultObserver) ProcessReplaced ¶
func (d *DefaultObserver) ProcessReplaced(ctx context.Context, proc *Process) error
func (*DefaultObserver) ProcessStarted ¶
func (d *DefaultObserver) ProcessStarted(ctx context.Context, proc *Process) error
func (*DefaultObserver) ProcessStopped ¶
func (d *DefaultObserver) ProcessStopped(ctx context.Context, proc *Process) error
type Eventer ¶
type Eventer interface {
Start(ctx context.Context) error
Stop() error
Register(Receiver)
SetMeta(p *Process) error
}
Eventer is the interface for the process eventer
type ExeRegexFilter ¶
type ExeRegexFilter struct {
// contains filtered or unexported fields
}
func (*ExeRegexFilter) Bitmask ¶
func (f *ExeRegexFilter) Bitmask() uint8
func (*ExeRegexFilter) String ¶
func (f *ExeRegexFilter) String() string
type Manager ¶
type Manager struct {
Logger *zap.Logger
// observers
Observers []Observer
// contains filtered or unexported fields
}
func (*Manager) Await ¶
Await gets a process by pid. If it exists, it is returned immediately. Otherwise, it will wait for it to be discovered and then return it. The context can be used to set a timeout.
func (*Manager) MaskEnvVars ¶
func (*Manager) RegisterProcess ¶
func (*Manager) SnapshotProcesses ¶
SnapshotProcesses takes a snapshot of all the current processes and calls the given function for each process. The function can return false to stop the iteration.
type Pod ¶
type Pod struct {
Name string `json:"pod_name,omitempty"`
Namespace string `json:"pod_namespace,omitempty"`
Labels map[string]string `json:"pod_labels,omitempty"`
Annotations map[string]string `json:"pod_annotations,omitempty"`
}
func (Pod) ControlValues ¶
type Process ¶
type Process struct {
Pid int
PidExe string // PidExe is the path to the /proc process symlink
PodID string // TODO: remove
Cgroup string
ContainerID string
RootID uint64
Binary string
// Exe is the absolute path to the executable of the process.
// If the process is running in a container, this path will be relative to the container's root filesystem.
Exe string
ExeFilename string // ExeFilename is the path to the file that was called by the syscall. It can be empty.
Args []string
Root string
Env map[string]string
Strategy QpointStrategy
PredatesQpoint bool
User resolvable.V[*ProcessUser]
UserShell resolvable.V[bool]
ExitCode int
// TLSProbeTypesDetected are the the probes that have scanned the process binary and found matching hooks.
TLSProbeTypesDetected []string
Container resolvable.V[*Container]
Pod resolvable.V[*Pod]
// contains filtered or unexported fields
}
func (*Process) ControlValues ¶
func (*Process) IsFiltered ¶
func (p *Process) IsFiltered(flag ...config.FilterLevel) bool
func (*Process) SetDetectedTLSProbeTypes ¶
func (*Process) SetHostname ¶
func (*Process) SetNotifier ¶
type ProcessUser ¶
ProcessUser contains information about the user running a process
func GetProcessUser ¶
func GetProcessUser(pid int) (*ProcessUser, error)
GetProcessUser retrieves user information for a given process ID using the /proc filesystem
type QpointStrategy ¶
type QpointStrategy uint32
QpointStrategy represents the different qpoint strategies that can be used.
const ( StrategyObserve QpointStrategy = iota StrategyIgnore StrategyAudit StrategyForward StrategyProxy )
func QpointStrategyFromString ¶
func QpointStrategyFromString(s string, p *Process) (QpointStrategy, error)
func (QpointStrategy) String ¶
func (s QpointStrategy) String() string
type Receiver ¶
type Receiver interface {
RegisterProcess(ctx context.Context, p *Process) error
UnregisterProcess(ctx context.Context, pid, exitCode int) error
}
Receiver is the interface for the process manager
type TlsProbeError ¶
func (*TlsProbeError) Error ¶
func (e *TlsProbeError) Error() string
func (*TlsProbeError) Unwrap ¶
func (e *TlsProbeError) Unwrap() error