script

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidScriptFile is returned when the script file is not a regular file.
	ErrInvalidScriptFile = errors.New("invalid script file")
	// ErrFileIsNotExecutable is returned when the script file is not executable.
	ErrFileIsNotExecutable = errors.New("file is not executable")
)

Functions

This section is empty.

Types

type Executor

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

Executor is an implementation of QueueExecutor interface in the eventqueue package. Script executor will execute configured scripts according to the event received from the event queue. Scripts should be in the following naming convention <ScriptDir>/<ScriptPrefix>-<RuleID>.sh . Scripts should be executable. CAUTION: Make sure to vet the script before allowing the sensor to run it, since the sensor does not do any kind of verification. Implemented as a Proof of Concept. Passing on the event to eventsrunner will be more scalable, easier to maintain and secure.

func New

func New(scriptDir, scriptPrefix string) (*Executor, error)

New creates a new instance of script based Executor. ScriptDir and ScriptPrefix are configs are required.

func (*Executor) Execute

func (se *Executor) Execute(event *eventqueue.Event) error

Execute executes the script for the given event. Execute function will construct the script path and execute it. The relevant event information will be passed to the script as an base64 encoded JSON string in the form of an environment variable with the name EVENT. Execute will return errors if the script is not an executable or if the script is invalid. OS STDOUT and STDERR will be used for the script. TODO: Add file STDOUT and STDERR for scripts

Jump to

Keyboard shortcuts

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