execwatch

package
v4.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package execwatch reads process starts from Tetragon and checks each new executable against the feeds' file-hash indicators.

Tetragon (Cilium) does the kernel side with eBPF and writes one JSON object per event to its export file (--export-filename, by default /var/run/cilium/tetragon/tetragon.log). Reading that file instead of its gRPC API keeps the sensor free of the gRPC stack, and works the same on a node where Tetragon runs as a DaemonSet or a systemd unit.

This is detection only. A match is reported; the process is not stopped, because stopping it cannot be undone and the sensor does not yet have a kernel hook that refuses the exec before it runs. The sensor reports the capability accordingly, and the console says so.

Index

Constants

View Source
const DefaultExport = "/var/run/cilium/tetragon/tetragon.log"

DefaultExport is Tetragon's default export file.

Variables

This section is empty.

Functions

func Follow

func Follow(ctx context.Context, path string, fn func(Exec)) error

Follow tails a Tetragon export file from its end, reopening it when it is rotated, and calls fn for every exec until ctx ends.

Types

type Exec

type Exec struct {
	PID             int
	Binary          string
	Arguments       string
	Cwd             string
	ParentBinary    string
	ParentArguments string
	Pod             string
	Namespace       string
	Time            time.Time
	// PreExec is an exec that has not happened yet (the seccomp guard asks
	// before it runs): /proc/<pid>/exe is still the caller, so the binary is
	// read from its path.
	PreExec bool
	// KernelRefused is an exec the Tetragon policy already refused. The
	// rules are run again to name the rule, and the event says blocked.
	KernelRefused bool
}

Exec is one process start.

func ParseLine

func ParseLine(line []byte) (Exec, bool)

ParseLine reads one Tetragon export line. ok is false for any event that is not a process_exec.

type Watcher

type Watcher struct {
	// Root is the filesystem binaries are read from: "/" on the host, or the
	// host root mounted into the sensor's container.
	Root     string
	Rules    func() *engine.Set
	Verdicts *decide.Engine
	Report   func(uplink.Event)
	// contains filtered or unexported fields
}

Watcher checks execs against the current rule set.

func (*Watcher) Check

func (w *Watcher) Check(e Exec)

Check runs the process rules over one exec: the feeds' Sigma rules against the start itself, and the file-hash indicators against the binary. Hashing prefers the process's own /proc/<pid>/exe, which is the file that ran even if the path was replaced since, and falls back to the path Tetragon reported.

func (*Watcher) Gate

func (w *Watcher) Gate(e Exec) (refuse bool)

Gate runs the same rules over an exec that has not happened yet and says whether to refuse it. Refusing an exec can be undone (the next one can be allowed), so the verdict engine may hold or block it, and the event says what was done.

Jump to

Keyboard shortcuts

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