pub struct SandboxManager { /* private fields */ }Expand description
Userspace sandbox validator. See the module docs for the threat model.
Implementations§
Source§impl SandboxManager
impl SandboxManager
Sourcepub fn new(profile: SandboxProfile, workspace: PathBuf) -> Self
pub fn new(profile: SandboxProfile, workspace: PathBuf) -> Self
Create a new manager for the given profile rooted at workspace.
Sourcepub fn set_allow_network(&mut self, allow: bool)
pub fn set_allow_network(&mut self, allow: bool)
Allow or deny network tools checked via Self::validate_network.
Sourcepub fn from_config(config: SandboxConfig) -> Self
pub fn from_config(config: SandboxConfig) -> Self
Create a manager from a full SandboxConfig.
Sourcepub fn deactivate(&mut self)
pub fn deactivate(&mut self)
Deactivate the sandbox (e.g. for trusted local sessions).
Sourcepub fn workspace_root(&self) -> &Path
pub fn workspace_root(&self) -> &Path
The workspace root this sandbox is confined to.
Sourcepub fn validate_path(
&self,
path: &Path,
write: bool,
) -> Result<(), SandboxError>
pub fn validate_path( &self, path: &Path, write: bool, ) -> Result<(), SandboxError>
Validate that path may be accessed, with write indicating whether
the caller intends to mutate it.
Sourcepub fn validate_command(&self, cmd: &str) -> Result<(), SandboxError>
pub fn validate_command(&self, cmd: &str) -> Result<(), SandboxError>
Validate that cmd is not on the sandbox command blocklist.
Sourcepub fn validate_network(&self) -> Result<(), SandboxError>
pub fn validate_network(&self) -> Result<(), SandboxError>
Validate that network access is permitted by the sandbox.
Sourcepub fn validate_env(&self, vars: &[(String, String)]) -> Vec<(String, String)>
pub fn validate_env(&self, vars: &[(String, String)]) -> Vec<(String, String)>
Filter vars down to the set of env vars the sandbox permits.
Sourcepub fn log_violation(&self, violation: &SandboxViolation)
pub fn log_violation(&self, violation: &SandboxViolation)
Record a violation in the in-memory log.
Sourcepub fn violations(&self) -> Vec<SandboxViolation>
pub fn violations(&self) -> Vec<SandboxViolation>
Return a snapshot of all recorded violations.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SandboxManager
impl !RefUnwindSafe for SandboxManager
impl Send for SandboxManager
impl Sync for SandboxManager
impl Unpin for SandboxManager
impl UnsafeUnpin for SandboxManager
impl UnwindSafe for SandboxManager
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
Converts
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>
Converts
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