From 2af90fd35ea8a0aafb9156653f5b28cbac4e1677 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 1 Dec 2026 01:59:16 +0000 Subject: enstate: validators and renderers in a sandbox By bubblewrap: everything read-only but OUT (and IN bound again after a fresh /tmp), a new /dev and /proc, namespaces of their own (no network), no capabilities, a new session, gone with the receptor. The setting sandbox is bwrap (found in the receptor's PATH, as the programs' environment is empty), or none; the module sets its bubblewrap. The tests run their programs in it where bubblewrap can make one (not in Nix's build sandbox), and a test checks that a program can't write outside OUT, nor into IN, and has no network nor environment. --- src/store.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/store.rs') diff --git a/src/store.rs b/src/store.rs index 9de62d3..c6d4d6c 100644 --- a/src/store.rs +++ b/src/store.rs @@ -35,6 +35,8 @@ pub type Kept = std::collections::BTreeMap)>; pub struct Store { pub state: PathBuf, pub run: PathBuf, + /// bubblewrap, for running programs in a sandbox (`program::Runner`). + pub sandbox: Option, } #[derive(Debug, Clone)] @@ -71,6 +73,7 @@ impl Store { Self { state: absolute(state), run: absolute(run), + sandbox: None, } } @@ -98,6 +101,20 @@ impl Store { self.run.join("tmp") } + /// How programs run: their scratch directories, and the sandbox. + pub fn runner(&self) -> crate::program::Runner { + crate::program::Runner { + scratch: self.scratch(), + sandbox: self.sandbox.clone(), + } + } + + /// The store, its programs run in a sandbox by `bwrap` (bubblewrap), or not. + pub fn with_sandbox(mut self, bwrap: Option) -> Self { + self.sandbox = bwrap; + self + } + fn channel_dir(&self, channel: &str) -> PathBuf { self.state.join("channels").join(channel) } @@ -261,6 +278,7 @@ impl Store { Ok(Store { state: dir.to_owned(), run: self.run.clone(), + sandbox: self.sandbox.clone(), }) } -- cgit v1.3.1