agents

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentsManager

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

AgentsManager contains easy functions to interact with a connected agent

func NewAgentsManager

func NewAgentsManager(
	c *coordinator.Coordinator,
	src *sources.SourcesManager,
	ev chan coordinator.Event,
) (*AgentsManager, error)

NewAgentsManager creates a new AgentsManager

func (*AgentsManager) BreakCommand

func (am *AgentsManager) BreakCommand(agentID int32, commandID []byte) error

BreakCommand will instruct the agent to break the given command by sending it a os.Interrupt signal

func (*AgentsManager) ExecuteCommand

func (am *AgentsManager) ExecuteCommand(
	agentID int32,
	command string,
	params, env []string,
	environmentID []byte,
	dir string,
	timeout int,
	commandResults chan *common.ExecutedCommand,
	wait bool,
	profile bool,
	perf bool,
	perfSampleRate int,
	debug bool,
	recordNetwork bool,
) ([]byte, error)

ExecuteCommand will execute a command on the agent specified by the agentID. It will run the command specified in `command`, with the parameters and environment variables specified by the `params` and `env` arguments. It will execute the command in the environment specified by `environmentID`. The working directory will be set to the `dir` parameter, which is relative to the root of the enviroment's working directory. `timeout` indicates how long the command should be allowed to run (in seconds). `wait` indicates if the function call should block until the command is completed. `profile` determines if we gather system performance metrics while running the command. `perfProfile` determines if we run `perf` performance profiling on the process and `perfSampleRate` the samples per second that we have `perf` gather. `debug` determines if we run the command in gdb for debugging. `commandResults` is a channel where we are supposed to report the command's results once the agent has completed it.

func (*AgentsManager) PrepareAgentWithBinariesForCommit

func (am *AgentsManager) PrepareAgentWithBinariesForCommit(
	agentID int32,
	binariesInS3 string,
) ([]byte, error)

PrepareAgentWithBinariesForCommit is a convenience method that instructs the given agent to create a new environment, and then download the binaries specified by the binariesInS3 parameter into that environment and unpack it

func (*AgentsManager) QueryAgent

func (am *AgentsManager) QueryAgent(
	agentID int32,
	msg wire.Msg,
) (wire.Msg, error)

QueryAgent is a utility function to do a single request-response interaction with the given agent. It will wait for a response for up to 15 seconds, and return an error if the response was not received within that timeout.

func (*AgentsManager) QueryAgentWithTimeout

func (am *AgentsManager) QueryAgentWithTimeout(
	agentID int32,
	msg wire.Msg,
	timeout time.Duration,
) (wire.Msg, error)

QueryAgentWithTimeout is a utility function to do a single request-response interaction with the given agent. It will wait for a response for up to the specified timeout, and return an error if the response was not received within that timeout.

func (*AgentsManager) RunningCommandsForAgent

func (am *AgentsManager) RunningCommandsForAgent(
	agentID int32,
) []coordinator.AgentCommandRunningPayload

RunningCommandsForAgent returns a list of commands that are currently running on the agent specified by agentID

func (*AgentsManager) TerminateCommand

func (am *AgentsManager) TerminateCommand(
	agentID int32,
	commandID []byte,
) error

TerminateCommand will instruct the agent to terminate the given command by sending it a os.Kill signal

Jump to

Keyboard shortcuts

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