From 8912f71afb9697c8645209ec0e67f67098bb16a1 Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 15:15:53 +0000 Subject: config: the sandbox backend is an enum, not a string with a fallthrough MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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. --- src/pipeline/mod.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/pipeline') 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> { - 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", + ))), } } -- cgit v1.2.3