proctree

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

README

Security Engineering Commons Proctree

Bounded process-tree execution, cancellation and cleanup for Go

Proctree executes a trusted local command and returns after its owned process tree terminates or cleanup fails. Proctree is not a privilege boundary or hostile-code sandbox

API

Run(context.Context, Command) accepts an absolute executable, arguments, working directory, closed environment, optional input, output limits and execution deadlines

Result includes start state, exit code, bounded output and a typed outcome. Errors preserve sentinel and native causes

Unix executables using Run must call DispatchWatchdog(os.Args) before ordinary dispatch

The complete guarantees and bounds are in the contract

Platforms

CI runs the supported Windows, Linux, macOS, BSD, illumos and Solaris targets listed in Platforms

Verification

go test -count=1 ./...
go test -race -count=1 ./...

CI also covers Go compatibility, cross-builds, containers, fuzzing and CodeQL

Documentation

Index

Constants

View Source
const DefaultCleanupTimeout = time.Second
View Source
const MaxArgumentBytes = 64 << 10
View Source
const MaxArguments = 256
View Source
const MaxCleanupTimeout = 30 * time.Second
View Source
const MaxEnvironment = 128
View Source
const MaxEnvironmentBytes = 64 << 10
View Source
const MaxInputBytes = 1 << 20
View Source
const MaxOutputBytes = 16 << 20
View Source
const MaxPathBytes = 4 << 10
View Source
const MaxTimeout = 30 * time.Minute

Variables

View Source
var ErrCancelled = errors.New("process execution cancelled")
View Source
var ErrCleanup = errors.New("process cleanup failed")
View Source
var ErrDeadline = errors.New("process execution deadline exceeded")
View Source
var ErrExit = errors.New("process exited unsuccessfully")
View Source
var ErrInvalid = errors.New("invalid process command")
View Source
var ErrOutputLimit = errors.New("process output exceeds its bound")
View Source
var ErrOwnership = errors.New("process ownership failed")
View Source
var ErrStart = errors.New("process start failed")
View Source
var ErrUnsupported = errors.New("process-tree ownership is unsupported")

Functions

func DispatchWatchdog

func DispatchWatchdog([]string) (bool, int)

Types

type Command

type Command struct {
	Executable     string
	Arguments      []string
	Directory      string
	Environment    []string
	Input          []byte
	StdoutLimit    int
	StderrLimit    int
	Timeout        time.Duration
	CleanupTimeout time.Duration
}

type Outcome

type Outcome string
const OutcomeCancelled Outcome = "cancelled"
const OutcomeCleanupFailure Outcome = "cleanup_failure"
const OutcomeCompleted Outcome = "completed"
const OutcomeDeadline Outcome = "deadline"
const OutcomeExitFailure Outcome = "exit_failure"
const OutcomeInvalid Outcome = "invalid"
const OutcomeOutputLimit Outcome = "output_limit"
const OutcomeOwnershipFailure Outcome = "ownership_failure"
const OutcomeStartFailure Outcome = "start_failure"
const OutcomeUnsupported Outcome = "unsupported"

type Result

type Result struct {
	Started  bool
	ExitCode int
	Stdout   []byte
	Stderr   []byte
	Outcome  Outcome
}

func Run

func Run(ctx context.Context, command Command) (Result, error)

Jump to

Keyboard shortcuts

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