sandbox

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 11 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 holds the container boundary kibble executes inside: the hardening flags every run carries, the metadata hostnames it closes, and the plumbing that names, reaches, and tears down containers. It is separate because it is the security surface, and a security surface buried among a thousand lines of result classification is one nobody reviews.

What it does not claim is as important as what it does. The session runs as root inside the container, because installing the packages a document depends on requires that, and the network stays open, because verifying an install is fetching it. The honest description is a reduced-capability root process on an open network behind the Docker boundary. docs/SECURITY.md owns the full statement.

Index

Constants

View Source
const MinFreeBytes int64 = 2 << 30

MinFreeBytes is the free space kibble needs inside Docker before a run. A daemon out of space fails installs with errors that read like the document's fault, so the run refuses to start instead.

Variables

View Source
var ErrDF = errors.New("df output not understood")

ErrDF reports df output kibble cannot read a free-space figure from.

Functions

func ArchWarning added in v1.4.0

func ArchWarning(ctx context.Context, image string) string

ArchWarning returns a warning when image is local, built for another architecture than the daemon's, and no platform was requested. It returns empty for an image already checked in this process.

func Args

func Args() []string

hardenedArgs are the docker flags every kibble container runs under. A documented command is text from a repository, which makes it untrusted input, so the container gets no capability the session does not need and bounded memory and process counts. The capabilities kept are the minimal set apt needs, since sessions install Debian packages the docs depend on. Network stays on because verifying an install is fetching it; that is a conscious tradeoff the README's security section owns.

func Available

func Available(ctx context.Context) error

DockerAvailable reports an error when the docker CLI cannot reach a running daemon, so kibble can fail fast with a clear message instead of reporting every install as a container error.

func Bin

func Bin() string

dockerBin returns the container client binary to invoke. Podman and other drop-in replacements speak docker's command line, so KIBBLE_DOCKER names the binary and docker stays the default.

func FreeBytes added in v0.26.0

func FreeBytes(ctx context.Context, image string) (int64, error)

FreeBytes returns the space available on the root filesystem of a container started from image. On Docker Desktop that is the VM's disk, which images, volumes, and build cache from every project share. kibble only measures: what to remove is the owner's decision.

func Name

func Name() string

containerName returns a container name unique to this process and step.

func RemoveFunc

func RemoveFunc(cmd *exec.Cmd, name string) func() error

removeContainerFunc returns the cancel hook for a docker run. Killing the docker client leaves the container running, since the daemon owns it, so the hook removes the container by name before killing the client. Without it an interrupted run leaves containers building in the background.

Types

type ArchCheck added in v1.4.0

type ArchCheck struct {
	// ImageArch returns the architecture of a local image, or an error when
	// the image is not local, in which case a run pulls the native one.
	ImageArch func(ctx context.Context, image string) (string, error)
	// ServerArch returns the architecture the daemon runs containers on.
	ServerArch func(ctx context.Context) (string, error)
	// contains filtered or unexported fields
}

ArchCheck finds images kibble is about to run that were built for another architecture than the daemon's. Docker runs such an image without asking when it is already local and no platform was requested, under emulation and several times slower. A source build that fits its budget natively then times out, and the timeout reads like the document's limit, not kibble's.

func (*ArchCheck) Platform added in v1.4.0

func (c *ArchCheck) Platform(ctx context.Context, image string) Platform

Platform returns the platform a container of image ran on: the platform DOCKER_DEFAULT_PLATFORM requested when set, else the local image's architecture, else the daemon's. It is asked after the run, when the image is local, and ignores ctx's cancellation, since a run that hit its deadline still needs its platform named. An empty image returns the daemon's own.

func (*ArchCheck) Warning added in v1.4.0

func (c *ArchCheck) Warning(ctx context.Context, image string) string

Warning returns the mismatch warning for image the first time image is checked, and empty after that or when there is nothing to warn about. A lookup that fails says nothing, since the run reports Docker's own error.

type Platform added in v1.4.0

type Platform struct {
	// Arch is the architecture the container ran, the image's own when it
	// could be read and the daemon's otherwise.
	Arch string
	// Host is the architecture the daemon runs containers on natively.
	Host string
}

Platform names the platform a container ran on. A verdict reached under emulation is a narrower claim than one reached natively, since the reader's own machine runs the native build.

func HostPlatform added in v1.4.0

func HostPlatform(ctx context.Context) Platform

HostPlatform returns the daemon's own platform, for a verdict no container was run for.

func ImagePlatform added in v1.4.0

func ImagePlatform(ctx context.Context, image string) Platform

ImagePlatform returns the platform a container of image ran on.

func (Platform) Emulated added in v1.4.0

func (p Platform) Emulated() bool

Emulated reports whether the container ran on another architecture than the daemon's own.

func (Platform) Name added in v1.4.0

func (p Platform) Name() string

Name returns the platform as an OS and architecture pair, or "linux" alone when the architecture is unknown.

func (Platform) String added in v1.4.0

func (p Platform) String() string

String returns the platform's name, followed by the daemon's architecture when the container ran emulated.

Jump to

Keyboard shortcuts

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