pub struct SandboxPolicy {
pub profile: SandboxProfile,
pub allow_read: Vec<PathBuf>,
pub allow_write: Vec<PathBuf>,
pub allow_network: bool,
pub allow_exec: Vec<PathBuf>,
pub env_inherit: Vec<String>,
pub denied_domains: Vec<String>,
}Expand description
Declarative sandbox policy evaluated at command launch.
Applied after blocklist, PolicyGate, and TrustGate have accepted the call.
The sandbox is the last hard boundary, not a replacement for application-level controls.
Fields§
§profile: SandboxProfileThe enforcement profile controlling which restrictions are active.
allow_read: Vec<PathBuf>Paths granted read (and execute) access. Normalized to absolute paths at construction.
Paths are resolved to their canonical (real) form by SandboxPolicy::canonicalized
before being applied. If a path is a symlink, the resolved target is used for the allow
rule. Deny rules for well-known secret paths are also generated for the canonical form,
so the allow override works correctly even when the denied path is a symlink.
allow_write: Vec<PathBuf>Paths granted read and write access. Normalized to absolute paths at construction.
allow_network: boolWhether unrestricted network egress is permitted.
allow_exec: Vec<PathBuf>Additional executables or directories granted execute permission.
env_inherit: Vec<String>Environment variable names or prefixes that are inherited by the sandboxed child.
denied_domains: Vec<String>Hostname patterns (exact or *.suffix) denied network egress.
Enforcement is per-backend:
- macOS Seatbelt:
(deny network* (remote host "<host>"))after(allow network*). - Linux bwrap:
/etc/hostsoverride resolving the name to0.0.0.0(best-effort). NoopSandbox: ignored (log WARN at construction if non-empty).
Implementations§
Source§impl SandboxPolicy
impl SandboxPolicy
Sourcepub fn canonicalized(self) -> Self
pub fn canonicalized(self) -> Self
Canonicalize all path fields so that symlinks and .. components cannot bypass
the policy. Paths that cannot be resolved (e.g., non-existent) are dropped and
logged at WARN level with the OS error — callers should ensure paths exist
before adding them to the policy.
Trait Implementations§
Source§impl Clone for SandboxPolicy
impl Clone for SandboxPolicy
Source§fn clone(&self) -> SandboxPolicy
fn clone(&self) -> SandboxPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SandboxPolicy
impl Debug for SandboxPolicy
Auto Trait Implementations§
impl Freeze for SandboxPolicy
impl RefUnwindSafe for SandboxPolicy
impl Send for SandboxPolicy
impl Sync for SandboxPolicy
impl Unpin for SandboxPolicy
impl UnsafeUnpin for SandboxPolicy
impl UnwindSafe for SandboxPolicy
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more