compose

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package compose is the §5.6 allowlist validator — the ONE chokepoint every compose document passes before it can reach `docker compose` (plan §5.6). It resolves ${VAR}/.env interpolation FIRST (validating before interpolation is a known bypass), then rejects any unknown top-level/service key and the dangerous set, and confines every bind mount under the app's run_dir.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Interpolate

func Interpolate(raw string, env Env) string

Interpolate resolves docker-compose-style ${VAR} references in raw text BEFORE YAML parsing (plan §5.6 step 1). Supported forms: $VAR, ${VAR}, ${VAR:-def}, ${VAR-def}, ${VAR:?msg}, ${VAR?msg}; $$ is a literal $. An unset variable with no default resolves to "" (compose's default), which the validator then sees.

Types

type Env

type Env map[string]string

Env is a name→value map used for ${VAR} resolution. It is built from the app's .env file (and, later, the encrypted env store) — NEVER from Mooring's own process environment, so Mooring secrets can't leak into a compose render.

func ParseEnvFile

func ParseEnvFile(data []byte) Env

ParseEnvFile parses KEY=VALUE lines (a .env file). Blank lines and #comments are skipped; values are taken literally (no nested interpolation), matching docker compose's .env handling closely enough for validation.

type FileSecret

type FileSecret struct {
	Name string
	Path string
}

FileSecret is a compose top-level file-mounted secret (a TLS keypair, a credential file). Mooring shows these as present/missing by stat only and NEVER reads their contents (plan §7 file-secrets vs env).

func FileSecrets

func FileSecrets(raw []byte, env Env) []FileSecret

FileSecrets extracts top-level `secrets:` entries that have a `file:` path. It is read-only and best-effort: a malformed document yields no secrets rather than an error (the validator is the gate; this is just for the panel).

type Options

type Options struct {
	// ProtectedPaths are additional absolute host paths that must never be a bind
	// source (e.g. Mooring's data dir and config dir, holding the DB + master
	// key). Joined with the built-in sensitivePaths set (review #17).
	ProtectedPaths []string
}

ValidateBytes runs the full §5.6 validation on a compose document. env is used for ${VAR} resolution (built from the app's .env, never Mooring's env); runDir is the app's run directory that bind mounts must stay under. Options carry extra, deployment-specific inputs to the validator.

type Result

type Result struct {
	Violations []Violation
}

Result is the validation outcome.

func ValidateBytes

func ValidateBytes(raw []byte, env Env, runDir string, opts Options) Result

ValidateBytes runs the full §5.6 validation on a compose document. env is used for ${VAR} resolution (built from the app's .env, never Mooring's env); runDir is the app's run directory that bind mounts must stay under.

func (Result) Error

func (r Result) Error() string

Error renders all violations as one message.

func (Result) OK

func (r Result) OK() bool

OK reports whether the compose document is safe to hand to docker compose.

func (*Result) SortViolations

func (r *Result) SortViolations()

SortViolations orders violations by line for stable display.

type Violation

type Violation struct {
	Service string
	Key     string
	Message string
	Line    int
}

Violation is one rejected construct, line-anchored where possible.

func (Violation) String

func (v Violation) String() string

Jump to

Keyboard shortcuts

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