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
- Variables
- func ArchWarning(ctx context.Context, image string) string
- func Args() []string
- func Available(ctx context.Context) error
- func Bin() string
- func FreeBytes(ctx context.Context, image string) (int64, error)
- func Name() string
- func RemoveFunc(cmd *exec.Cmd, name string) func() error
- type ArchCheck
- type Platform
Constants ¶
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 ¶
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
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 ¶
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
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 ¶
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
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.
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
HostPlatform returns the daemon's own platform, for a verdict no container was run for.
func ImagePlatform ¶ added in v1.4.0
ImagePlatform returns the platform a container of image ran on.
func (Platform) Emulated ¶ added in v1.4.0
Emulated reports whether the container ran on another architecture than the daemon's own.