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 (*Docker) Available ¶
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 ¶
func (d *Docker) Execute(ctx context.Context, req analyzer.RuntimeRequest) analyzer.RuntimeResult
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.