engine

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckResult

type CheckResult struct {
	Allowed  bool
	Tool     string
	Args     []string
	Reason   string // empty if allowed
	ExitCode int    // suggested exit code when blocked (0 if allowed)
}

CheckResult holds the outcome of a policy check.

type Engine

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

func New

func New(gc *config.GlobalConfig, cfgs []config.ConfigTool) *Engine

New creates an Engine from an explicit config and tool list.

func NewDefault

func NewDefault() *Engine

func (*Engine) Audit

func (e *Engine) Audit() *audit.Logger

Audit returns the audit logger (may be nil if disabled).

func (*Engine) Check

func (e *Engine) Check(args []string) CheckResult

Check validates a command against the policy without executing it.

func (*Engine) CheckInnerFunc

func (e *Engine) CheckInnerFunc() func(name string, args []string) error

CheckInnerFunc returns a function that validates a command against the engine's policy. Used by --sh shell validation (no NonInteractiveArgs needed).

func (*Engine) CheckInnerShellFunc added in v0.15.0

func (e *Engine) CheckInnerShellFunc() func(expr string) error

CheckInnerShellFunc returns a function that validates a shell expression against the engine's registry and options. Injected into shell interpreter tools.

func (*Engine) Close

func (e *Engine) Close()

Close releases resources (audit log file, etc.).

func (*Engine) GlobalConfig

func (e *Engine) GlobalConfig() *config.GlobalConfig

GlobalConfig returns the loaded global configuration.

func (*Engine) ListTools

func (e *Engine) ListTools() []ToolEntry

ListTools returns all registered tools sorted by name.

func (*Engine) Registry

func (e *Engine) Registry() *spec.Registry

Registry returns the tool registry.

func (*Engine) Run

func (e *Engine) Run(args []string) (int, error)

func (*Engine) ShellEnv

func (e *Engine) ShellEnv(toolNames []string) []string

ShellEnv builds the environment for shell execution, merging non-interactive env from all tools referenced in the expression.

func (*Engine) ShellValidateOpts

func (e *Engine) ShellValidateOpts() shell.ValidateOpts

ShellValidateOpts returns the standard options for shell.Validate, including writable dirs and the inner-command check function.

type ToolEntry

type ToolEntry struct {
	Name   string
	Source string // "built-in" or "config"
}

ToolEntry represents a registered tool with its source.

Jump to

Keyboard shortcuts

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