pub struct SandboxConfig { /* private fields */ }Expand description
Least-privilege limits for a delegated agent (P2-5 sandbox).
Path checks are prefix-based: a request is allowed when it is the allowed
directory itself or lives underneath it. Before the prefix test, a request
path containing .. is rejected outright, and both sides are resolved
against the filesystem so a symlink inside the root cannot smuggle a path
outside it. Network checks allow the host exactly, or any subdomain of an
allowed domain.
Implementations§
Source§impl SandboxConfig
impl SandboxConfig
Sourcepub fn allow_read(self, path: impl Into<PathBuf>) -> Self
pub fn allow_read(self, path: impl Into<PathBuf>) -> Self
Allow reading within path (builder style).
Sourcepub fn allow_write(self, path: impl Into<PathBuf>) -> Self
pub fn allow_write(self, path: impl Into<PathBuf>) -> Self
Allow writing within path (builder style).
Sourcepub fn allow_domain(self, domain: impl Into<String>) -> Self
pub fn allow_domain(self, domain: impl Into<String>) -> Self
Allow network access to domain and its subdomains (builder style).
Sourcepub fn with_max_payload(self, bytes: usize) -> Self
pub fn with_max_payload(self, bytes: usize) -> Self
Cap the payload size accepted from the agent (builder style).
Sourcepub fn accepts_payload(&self, size: usize) -> bool
pub fn accepts_payload(&self, size: usize) -> bool
Whether a payload of size bytes is within the configured limit.
Sourcepub fn check(&self, request: &AccessRequest) -> Result<(), SecurityError>
pub fn check(&self, request: &AccessRequest) -> Result<(), SecurityError>
Enforce the sandbox for a single access request.
Trait Implementations§
Source§impl Clone for SandboxConfig
impl Clone for SandboxConfig
Source§fn clone(&self) -> SandboxConfig
fn clone(&self) -> SandboxConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more