Skip to main content

IsolationPolicy

Struct IsolationPolicy 

Source
pub struct IsolationPolicy {
    pub ro_binds: Vec<(PathBuf, PathBuf)>,
    pub work_host: Option<PathBuf>,
    pub network: bool,
    pub env_allowlist: Vec<String>,
}
Expand description

What the sandbox does and doesn’t let a stage reach.

Derived from a stage’s EffectSet via IsolationPolicy::from_effects. Callers rarely construct this manually; it’s shaped so the stage executor can translate it into backend-specific flags (bwrap args in Phase 1, unshare+landlock+seccomp in Phase 2).

Fields§

§ro_binds: Vec<(PathBuf, PathBuf)>

Read-only bind mounts: (host_path, sandbox_path). Always includes /nix/store so Nix-pinned runtimes resolve inside the sandbox.

§work_host: Option<PathBuf>

Scratch directory strategy for /work inside the sandbox.

  • None (recommended, and the default from Self::from_effects) → bwrap creates /work as a sandbox-private tmpfs via --dir /work. No host-side path exists; cleanup happens automatically when the sandbox exits; a malicious host user can’t race to write predicatable filenames into the work dir before the stage runs.
  • Some(host)--bind <host> /work. Host dir must exist and be writable by the sandbox’s effective UID (65534 by default). Only for callers that need to inspect the work dir after execution — e.g., an integration test.
§network: bool

Inherit the host’s network namespace (true) or unshare into a fresh empty one (false). Only true when the stage has Effect::Network.

§env_allowlist: Vec<String>

Environment variables to pass through to the sandboxed process. Everything else in the parent environment is cleared.

Implementations§

Source§

impl IsolationPolicy

Source

pub fn from_effects(effects: &EffectSet) -> Self

Build the policy for a stage with the given effects.

Defaults to a sandbox-private /work (tmpfs, no host-side state). Callers that need a host-visible work dir can swap in Self::with_work_host.

Source

pub fn with_work_host(self, host: PathBuf) -> Self

Override the sandbox’s /work to bind a caller-provided host directory. The directory must already exist and be writable by the sandbox effective UID (65534). Consumers mostly leave the default (tmpfs).

Trait Implementations§

Source§

impl Clone for IsolationPolicy

Source§

fn clone(&self) -> IsolationPolicy

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IsolationPolicy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,