1 unstable release
Uses new Rust 2024
| 0.1.0 | Oct 12, 2025 |
|---|
#384 in Cargo plugins
235KB
5.5K
SLoC
CLI Architecture Notes
Policy Loading Flow
commands::build::execandcommands::run::execforward shared CLI flags (--policy,--allow,--mode) topolicy::setup_isolation.setup_isolationlayers workspace policies (workspace.warden.toml), local overrides (warden.toml), and any CLI--policyfiles by callingPolicy::mergein order.- Manifest metadata and trust database entries extend the base policy before CLI overrides are applied. CLI
--allowpaths are added last to the exec allowlist so they always win. - Every assembled policy is validated and compiled via
warden_policy_compiler::compile, yielding theIsolationConfigused by the sandbox:mode, syscall deny list, compiled BPF map layout (MapsLayout), and the list of environment variables allowed to leak through.
Sandbox Wiring
sandbox::run_in_sandboxconstructs a newsandbox_runtime::Sandbox, launches the requested command, and always callsshutdown, propagating any run errors.Sandbox::runforwards the compiledMapsLayout, syscall deny list, and allowed environment variables to the runtime.RealSandbox::install_pre_execcallswrite_mode_flagandpopulate_mapswith theMapsLayoutproduced bywarden_policy_compiler::compile, then applies seccomp if enforcement and deny rules require it. The fake runtime records the same layout snapshots for integration assertions.- Cgroups are created through
sandbox_runtime::cgroup::Cgroup::createfor each invocation. Cleanup is triggered viaSandbox::shutdown, ensuring fake and real sandboxes remove their cgroup directories even when the workload fails.
Command Summaries
buildwrapscargo buildand exits with the child status (matchingEPERMfailures when enforcement blocks the build).runexecutes arbitrary commands after--, applying the same isolation stack; it validates arguments and mirrors the child exit code.statusreports layered policy sources (workspace, local, CLI overrides, and mode overrides) plus recent events fromwarden-events.jsonl, including observe-mode hints surfaced byEventRecord::to_string.reportreuses the recorded events and metrics snapshot to emit text, JSON, or SARIF outputs, bubbling up skipped malformed lines and missing metrics gracefully.
These notes capture how CLI options travel through policy compilation into sandbox map loading, complementing the integration tests under tests/sandbox.rs.
Dependencies
~16–32MB
~482K SLoC