pub struct SandboxConfig {
pub allowed_read_paths: Vec<PathBuf>,
pub allowed_write_paths: Vec<PathBuf>,
pub allowed_commands: HashSet<String>,
pub allow_network: bool,
pub allow_env: bool,
pub timeout_ms: u64,
pub max_memory: usize,
pub max_read_size: usize,
pub permissions: HashSet<Permission>,
}Expand description
Configuration for plugin sandboxing.
Fields§
§allowed_read_paths: Vec<PathBuf>Paths the plugin is allowed to read from.
allowed_write_paths: Vec<PathBuf>Paths the plugin is allowed to write to.
allowed_commands: HashSet<String>Commands the plugin is allowed to execute.
allow_network: boolWhether network access is allowed.
allow_env: boolWhether environment access is allowed.
timeout_ms: u64Maximum execution time in milliseconds.
max_memory: usizeMaximum memory in bytes (0 = unlimited).
max_read_size: usizeMaximum file size that can be read.
permissions: HashSet<Permission>Granted permissions.
Implementations§
Source§impl SandboxConfig
impl SandboxConfig
Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
Create a permissive sandbox (for trusted plugins).
Sourcepub fn allow_read(self, path: impl Into<PathBuf>) -> Self
pub fn allow_read(self, path: impl Into<PathBuf>) -> Self
Add an allowed read path.
Sourcepub fn allow_write(self, path: impl Into<PathBuf>) -> Self
pub fn allow_write(self, path: impl Into<PathBuf>) -> Self
Add an allowed write path.
Sourcepub fn allow_command(self, cmd: impl Into<String>) -> Self
pub fn allow_command(self, cmd: impl Into<String>) -> Self
Allow a specific command.
Sourcepub fn allow_network(self) -> Self
pub fn allow_network(self) -> Self
Enable network access.
Sourcepub fn with_timeout(self, timeout_ms: u64) -> Self
pub fn with_timeout(self, timeout_ms: u64) -> Self
Set timeout.
Sourcepub fn with_memory_limit(self, bytes: usize) -> Self
pub fn with_memory_limit(self, bytes: usize) -> Self
Set memory limit.
Sourcepub fn grant(self, permission: Permission) -> Self
pub fn grant(self, permission: Permission) -> Self
Grant a permission.
Sourcepub fn has_permission(&self, permission: Permission) -> bool
pub fn has_permission(&self, permission: Permission) -> bool
Check if a permission is granted.
Sourcepub fn can_execute(&self, command: &str) -> bool
pub fn can_execute(&self, command: &str) -> bool
Check if executing a command is allowed.
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
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
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>
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