use deck_core::Sandbox;
use crate::profile::SandboxProfile;
#[derive(Debug, Default)]
pub struct LinuxSandbox {
_placeholder: (),
}
impl LinuxSandbox {
#[must_use]
pub fn plan(&self, profile: &SandboxProfile) -> SandboxPlan {
SandboxPlan {
read_paths: profile.allow_read.len(),
write_paths: profile.allow_write.len(),
allow_network: profile.allow_network,
}
}
}
impl Sandbox for LinuxSandbox {
fn availability(&self) -> &'static str {
"scaffolded (not enforcing in 0.1)"
}
fn enforces(&self) -> bool {
false
}
}
#[derive(Debug, Clone, Copy)]
pub struct SandboxPlan {
pub read_paths: usize,
pub write_paths: usize,
pub allow_network: bool,
}
#[cfg(test)]
mod tests {
use super::*;
use std::path::PathBuf;
#[test]
fn plan_counts_paths() {
let sb = LinuxSandbox::default();
let p = SandboxProfile {
allow_read: vec![PathBuf::from("/etc")],
allow_write: vec![PathBuf::from("/tmp")],
allow_network: false,
};
let plan = sb.plan(&p);
assert_eq!(plan.read_paths, 1);
assert_eq!(plan.write_paths, 1);
assert!(!plan.allow_network);
}
}