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/view.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/view.rs') diff --git a/src/view.rs b/src/view.rs index bd4b8f5..b7ddc35 100644 --- a/src/view.rs +++ b/src/view.rs @@ -17,7 +17,7 @@ use crate::scratch::Scratch; /// would be, the others as they are. pub type Entries<'a> = BTreeMap<&'a str, &'a Content>; -/// Renders the view `name` from `entries` into scratch below `scratch`; nothing if a +/// Renders the view `name` from `entries` into scratch, by `runner`; nothing if a /// required slot it is made from is unfilled, or it is an entry's own and that entry /// isn't there. pub fn render( @@ -25,7 +25,7 @@ pub fn render( name: &str, view: &ViewSpec, entries: &Entries, - scratch: &Path, + runner: &program::Runner, ) -> Result> { let entry = |address: &Address| { entries @@ -45,7 +45,7 @@ pub fn render( let Some(bytes) = entry(address) else { return Ok(None); }; - let out = Scratch::new(scratch, "view-")?; + let out = Scratch::new(&runner.scratch, "view-")?; crate::content::write_file(&out.path().join(&address.slot), bytes, 0o600)?; Ok(Some(out)) } @@ -66,7 +66,7 @@ pub fn render( }) .collect(), }; - let outcome = program::run(renderer, Role::Renderer, name, &given, scratch)?; + let outcome = program::run(renderer, Role::Renderer, name, &given, runner)?; // What it can't render, it fails on; and it may write regular files and // directories only. program::files_below(outcome.out.path())?; -- cgit v1.3.1