pub struct SandboxConfig {
pub fs_read: PathPolicy,
pub fs_write: PathPolicy,
pub net_outgoing: NetPolicy,
pub net_incoming: NetPolicy,
pub env_vars: Option<HashSet<String>>,
pub working_dir: Option<PathBuf>,
pub isolate_temp: bool,
}Expand description
Configuration for the sandbox environment.
Fields§
§fs_read: PathPolicyPolicy for filesystem read access.
fs_write: PathPolicyPolicy for filesystem write access.
net_outgoing: NetPolicyPolicy for outgoing network requests.
net_incoming: NetPolicyPolicy for incoming network connections.
env_vars: Option<HashSet<String>>Allowed environment variable names (None = all denied).
working_dir: Option<PathBuf>Working directory for the script.
isolate_temp: boolWhether to isolate temp directory.
Implementations§
Source§impl SandboxConfig
impl SandboxConfig
Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
Create a permissive sandbox configuration (use with caution).
Sourcepub fn with_read_paths<I, P>(self, paths: I) -> Self
pub fn with_read_paths<I, P>(self, paths: I) -> Self
Allow reading from specific paths.
Sourcepub fn with_write_paths<I, P>(self, paths: I) -> Self
pub fn with_write_paths<I, P>(self, paths: I) -> Self
Allow writing to specific paths.
Sourcepub fn with_allowed_hosts<I, S>(self, hosts: I) -> Self
pub fn with_allowed_hosts<I, S>(self, hosts: I) -> Self
Allow outgoing requests to specific hosts.
Sourcepub fn with_env_vars<I, S>(self, vars: I) -> Self
pub fn with_env_vars<I, S>(self, vars: I) -> Self
Allow access to specific environment variables.
Sourcepub fn with_working_dir<P: Into<PathBuf>>(self, path: P) -> Self
pub fn with_working_dir<P: Into<PathBuf>>(self, path: P) -> Self
Set the working directory.
Sourcepub fn with_temp_isolation(self) -> Self
pub fn with_temp_isolation(self) -> Self
Enable temp directory isolation.
Sourcepub fn can_connect(&self, host: &str) -> bool
pub fn can_connect(&self, host: &str) -> bool
Check if connecting to a host is allowed.
Sourcepub fn can_access_env(&self, name: &str) -> bool
pub fn can_access_env(&self, name: &str) -> bool
Check if an environment variable is accessible.
Trait Implementations§
Source§impl Clone for SandboxConfig
impl Clone for SandboxConfig
Source§fn clone(&self) -> SandboxConfig
fn clone(&self) -> SandboxConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SandboxConfig
impl Debug for SandboxConfig
Source§impl Default for SandboxConfig
impl Default for SandboxConfig
Source§fn default() -> SandboxConfig
fn default() -> SandboxConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SandboxConfig
impl RefUnwindSafe for SandboxConfig
impl Send for SandboxConfig
impl Sync for SandboxConfig
impl Unpin for SandboxConfig
impl UnwindSafe for SandboxConfig
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