pub struct ProcessBackend { /* private fields */ }Available on crate feature
sandbox only.Expand description
Subprocess-based sandbox backend.
Executes code by spawning child processes with tokio::process::Command.
Enforces timeout via tokio::time::timeout and environment isolation
via env_clear(). Optionally enforces filesystem and network isolation
when a SandboxEnforcer is configured via with_sandbox().
§Example
use adk_sandbox::{ProcessBackend, SandboxBackend};
let backend = ProcessBackend::default();
assert_eq!(backend.name(), "process");§With OS-level sandbox
ⓘ
use adk_sandbox::{ProcessBackend, ProcessConfig, SandboxPolicyBuilder, get_enforcer};
let enforcer = get_enforcer()?;
let policy = SandboxPolicyBuilder::new()
.allow_read("/usr/lib")
.allow_read_write("/tmp/work")
.build();
let backend = ProcessBackend::with_sandbox(
ProcessConfig::default(),
enforcer,
policy,
);
assert!(backend.capabilities().enforced_limits.filesystem_isolation);Implementations§
Source§impl ProcessBackend
impl ProcessBackend
Sourcepub fn new(config: ProcessConfig) -> ProcessBackend
Available on crate feature process only.
pub fn new(config: ProcessConfig) -> ProcessBackend
process only.Creates a new ProcessBackend with the given configuration.
Sourcepub fn with_sandbox(
config: ProcessConfig,
enforcer: Box<dyn SandboxEnforcer>,
policy: SandboxPolicy,
) -> ProcessBackend
Available on crate feature process only.
pub fn with_sandbox( config: ProcessConfig, enforcer: Box<dyn SandboxEnforcer>, policy: SandboxPolicy, ) -> ProcessBackend
process only.Creates a new ProcessBackend with OS-level sandbox enforcement.
All executions through this backend will be sandboxed with the given policy. The enforcer wraps commands with platform-specific restrictions (Seatbelt on macOS, bubblewrap on Linux, AppContainer on Windows).
If different tools need different policies, create multiple
ProcessBackend instances.
Trait Implementations§
Source§impl Debug for ProcessBackend
impl Debug for ProcessBackend
Source§impl Default for ProcessBackend
impl Default for ProcessBackend
Source§fn default() -> ProcessBackend
fn default() -> ProcessBackend
Returns the “default value” for a type. Read more
Source§impl SandboxBackend for ProcessBackend
impl SandboxBackend for ProcessBackend
Source§fn capabilities(&self) -> BackendCapabilities
fn capabilities(&self) -> BackendCapabilities
Returns the capabilities and enforced limits of this backend.
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
request: ExecRequest,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, SandboxError>> + Send + 'async_trait>>where
'life0: 'async_trait,
ProcessBackend: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
request: ExecRequest,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, SandboxError>> + Send + 'async_trait>>where
'life0: 'async_trait,
ProcessBackend: 'async_trait,
Executes code in isolation according to the request parameters. Read more
Auto Trait Implementations§
impl Freeze for ProcessBackend
impl !RefUnwindSafe for ProcessBackend
impl Send for ProcessBackend
impl Sync for ProcessBackend
impl Unpin for ProcessBackend
impl UnsafeUnpin for ProcessBackend
impl !UnwindSafe for ProcessBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more