Documentation
¶
Index ¶
- Constants
- Variables
- func BuildPoliciesFromEvents(eventsToChoose []events.ID) *policy.Policies
- func DiscoverChildProcesses(pid int) ([]int, error)
- func ExecCmdBgWithSudoAndCtx(ctx context.Context, command string) (int, chan error, error)
- func ExecPinnedCmdWithTimeout(command string, timeout time.Duration) (int, error)
- func IsSudoCmdAvailableForThisUser() bool
- func NewPolicies(polsFilesID []PolicyFileWithID) *policy.Policies
- func ParseCmd(fullCmd string) (string, []string, error)
- func PinProccessToCPU(id ...int) error
- func SetTestLogger(t *testing.T, l logger.Level) (loggerOutput <-chan []byte, restoreLogger func())
- func SudoKillProcess(pid int, force bool) error
- func TestLogs(t *testing.T, logsToSearch []string, logsChan <-chan []byte, ...) <-chan bool
- type PolicyFileWithID
- type RunningTracker
- type TrackerStatus
Constants ¶
const ( SIGTERM = "-15" SIGKILL = "-9" )
const CPUForTests = 0 // CPU to pin test processes to
const (
TrackerDefaultStartupTimeout = 5 * time.Second
)
Variables ¶
var ( TrackerBinary = "../../dist/tracker" TrackerHostname = "localhost" TrackerPort = 3366 )
Functions ¶
func BuildPoliciesFromEvents ¶ added in v0.20.0
BuildPoliciesFromEvents create a Policies instance with a single policy, which chooses the given events without filters or scopes
func DiscoverChildProcesses ¶
DiscoverChildProcesses discovers all child processes of a given PID.
func ExecCmdBgWithSudoAndCtx ¶
ExecCmdBgWithSudoAndCtx executes a command with sudo in the background, and returns the PID of the process and a channel to wait for the command to exit (Check RunningTracker object about how to use this). The function will return an error if the command execution fails
func ExecPinnedCmdWithTimeout ¶
ExecPinnedCmdWithTimeout executes a cmd with a timeout and returns the PID of the process.
func IsSudoCmdAvailableForThisUser ¶
func IsSudoCmdAvailableForThisUser() bool
IsSudoCmdAvailableForThisUser checks if the sudo command is available for the current user.
func NewPolicies ¶ added in v0.20.0
func NewPolicies(polsFilesID []PolicyFileWithID) *policy.Policies
NewPolicies creates a new policies object with the given policies files with IDs.
func PinProccessToCPU ¶
PinProccessToCPU pins the current process to a specific CPU
func SetTestLogger ¶ added in v0.20.0
SetTestLogger create a logger which prints the logs to the returned channel. This function is meant to be used by tests to check logs, and by that test the flow of Tracker from outside.
func SudoKillProcess ¶
SudoKillProcess kills a process with sudo.
func TestLogs ¶ added in v0.20.0
func TestLogs( t *testing.T, logsToSearch []string, logsChan <-chan []byte, done <-chan struct{}, ) <-chan bool
TestLogs searches for the given logs and test when input channel closes if all logs were received. It also returns a channel with the result of the test - whether all logs were found.
Types ¶
type PolicyFileWithID ¶ added in v0.20.0
type PolicyFileWithID struct { PolicyFile v1beta1.PolicyFile Id int }
type RunningTracker ¶
type RunningTracker struct {
// contains filtered or unexported fields
}
RunningTracker is a wrapper for a running tracker process as a regular process.
func NewRunningTracker ¶
func NewRunningTracker(givenCtx context.Context, cmdLine string) *RunningTracker
NewRunningTracker creates a new RunningTracker instance.
func (*RunningTracker) IsReady ¶
func (r *RunningTracker) IsReady() bool
IsReady checks if the tracker process is ready.
func (*RunningTracker) Start ¶
func (r *RunningTracker) Start(timeout time.Duration) (<-chan TrackerStatus, error)
Start starts the tracker process.
func (*RunningTracker) Stop ¶
func (r *RunningTracker) Stop() []error
Stop stops the tracker process.
type TrackerStatus ¶
type TrackerStatus int
const ( TrackerStarted TrackerStatus = iota TrackerFailed TrackerTimedout TrackerAlreadyRunning )