sandbox

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sandbox implements analyzer.RuntimeExecutor on top of the Docker CLI. Its container flags enforce a read-only root, non-root user, dropped capabilities, bounded resources, and no network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Docker

type Docker struct {
	// Image is the container base image. It defaults to a locally-built,
	// empty scratch-based image, so a run never needs to pull anything from
	// a registry. Only ever override this with a trusted, minimal image:
	// this executor bind-mounts the entrypoint into it and expects nothing
	// else from the image's own filesystem.
	Image string

	// BaseTempDir is where per-run scanner-owned temp directories are
	// created. Defaults to os.TempDir(). This is the only directory tree
	// ever bind-mounted into a container.
	BaseTempDir string

	Memory    string // docker --memory value, e.g. "256m"
	CPUs      string // docker --cpus value, e.g. "1.0"
	PIDsLimit int64
	TmpfsSize string // size= value for the tmpfs work directory

	DefaultTimeout time.Duration

	// Logger receives a warning when a docker cleanup command (removing a
	// container) fails or times out. Defaults to
	// slog.Default() so the failure is never silent even when nothing sets
	// this.
	Logger *slog.Logger
	// contains filtered or unexported fields
}

Docker runs targets inside a docker container. The zero value is usable; New fills in sane defaults.

func New

func New() *Docker

New builds a Docker executor with default resource limits

func (*Docker) Available

func (d *Docker) Available(ctx context.Context) error

Available reports whether the docker CLI is on PATH and its daemon is reachable. It always returns within a few seconds rather than hanging: a missing or unresponsive daemon must be a clear error, not a stall.

func (*Docker) Execute

Execute runs one target inside the sandbox. It never mounts anything outside the temp directory it creates for this call, and that directory is always removed before Execute returns.

Jump to

Keyboard shortcuts

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