use std::{collections::HashMap, process::ExitStatus};
use crate::{error::CoreError, profile::SandboxProfile};
#[cfg(target_os = "macos")]
mod macos;
#[cfg(target_os = "macos")]
pub use macos::MacosSandbox as Sandbox;
#[cfg(target_os = "macos")]
pub use macos::sbpl;
#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "linux")]
pub use linux::LinuxSandbox as Sandbox;
#[cfg(target_os = "linux")]
pub use linux::policy;
pub trait SandboxBackend: Send + Sync {
fn name(&self) -> &'static str;
fn info(&self) -> &BackendInfo;
fn render_policy(&self, profile: &SandboxProfile, proxy_port: Option<u16>) -> String;
fn run(
&self,
profile: &SandboxProfile,
proxy_port: Option<u16>,
command: &[String],
extra_env: &HashMap<String, String>,
) -> impl std::future::Future<Output = Result<ExitStatus, CoreError>> + Send;
}
#[derive(Debug, Clone)]
pub struct BackendInfo {
pub name: &'static str,
pub kernel: String,
pub features: BackendFeatures,
}
#[derive(Debug, Clone, Copy, Default)]
pub struct BackendFeatures {
pub fs_write: bool,
pub fs_read: bool,
pub exec_allowlist: bool,
pub net_port_filter: bool,
pub audit_stream: bool,
}
#[derive(Debug, Clone, Copy, Default)]
pub struct BackendOptions {
pub allow_degraded: bool,
}