summaryrefslogtreecommitdiffstats
path: root/src/pipeline
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-19 15:15:53 +0000
committeraur-build <aur-build@localhost>2026-11-19 15:15:53 +0000
commit8912f71afb9697c8645209ec0e67f67098bb16a1 (patch)
tree91476b46d1de87f3fb3d9565a41925e52620edff /src/pipeline
parent8096fde8d98cdde4e110865ebb15ad034b92ff27 (diff)
downloadaur-build-8912f71afb9697c8645209ec0e67f67098bb16a1.tar.gz
aur-build-8912f71afb9697c8645209ec0e67f67098bb16a1.zip
config: the sandbox backend is an enum, not a string with a fallthrough
`sandbox_backend` was a free-form string and `backend_for` matched it with `_ => loopback`. So `sandbox_backend = "kata"` — a real, intended backend, documented in the design — meant "run the untrusted PKGBUILD as the hub's own user", and nothing anywhere said so. There was also no validation of any kind in the crate: an empty `agent_token` with a remote backend, or a missing listen address, parsed fine and failed later as something else. The four flat fields become one tagged `sandbox` object with three kinds: `loopback` (needs nothing, still the default, so every config on disk keeps working), `remote` (listen + token), and `agent-sandbox` (api, namespace, bearer, image, listen, token). Required fields are required by the type, an unknown kind is a parse error naming the valid set, and `deny_unknown_fields` means a misspelled field is named rather than read as absent. `agent-sandbox` parses and is refused at backend construction until it is wired up — a valid kind that is not implemented is an error, never a substitution. Retired keys are refused when they carry intent: a config saying `sandbox_backend: "remote"` errors and names the replacement shape, because quietly reinterpreting it as loopback is the bug being removed. A config saying `"loopback"` with the empty strings `init` wrote is noise, not intent, and loads unchanged. The token and the cluster bearer are redacted in `Debug`, so a config that reaches a log line cannot leak them.
Diffstat (limited to 'src/pipeline')
-rw-r--r--src/pipeline/mod.rs21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/pipeline/mod.rs b/src/pipeline/mod.rs
index 1f57bed..9a53d80 100644
--- a/src/pipeline/mod.rs
+++ b/src/pipeline/mod.rs
@@ -180,13 +180,20 @@ impl Ctx {
/// point. `remote` binds the agent listener for the lifetime of this
/// run's context.
fn backend_for(cfg: &Config) -> Result<Arc<dyn SandboxBackend>> {
- match cfg.sandbox_backend.as_str() {
- "remote" => Ok(Arc::new(crate::sandbox::remote::RemoteBackend::bind(
- cfg,
- &cfg.agent_listen,
- &cfg.agent_token,
- )?)),
- _ => Ok(Arc::new(crate::sandbox::loopback::LoopbackBackend::new(cfg))),
+ match &cfg.sandbox {
+ crate::config::Sandbox::Loopback => {
+ Ok(Arc::new(crate::sandbox::loopback::LoopbackBackend::new(cfg)))
+ }
+ crate::config::Sandbox::Remote { listen, token, .. } => Ok(Arc::new(
+ crate::sandbox::remote::RemoteBackend::bind(cfg, listen, token)?,
+ )),
+ // A valid kind that is not wired up yet is an error, never a
+ // fallthrough: a build configured for a Kata VM that silently ran
+ // as the hub's own user is the failure this enum was added to stop.
+ crate::config::Sandbox::AgentSandbox { .. } => Err(Error::invalid(concat!(
+ "sandbox kind \"agent-sandbox\" is not wired up yet; refusing to run this build ",
+ "on a backend it was not configured for",
+ ))),
}
}