pub struct RuntimePolicy {
pub allowed_paths: Vec<PathBuf>,
pub read_only_paths: Vec<PathBuf>,
pub allowed_hosts: Vec<String>,
pub memory_limit: Option<usize>,
pub time_limit: Option<Duration>,
pub output_limit: Option<usize>,
}Expand description
Runtime-scoped policy governing what a Shape program may access.
Threaded through the VM execution context as Option<Arc<RuntimePolicy>>.
None means unrestricted (default for trusted programs).
Fields§
§allowed_paths: Vec<PathBuf>Filesystem paths the program may access (glob patterns supported).
Empty means all paths are allowed unless the program lacks FsRead/FsWrite.
read_only_paths: Vec<PathBuf>Paths that may only be read, never written.
allowed_hosts: Vec<String>Network hosts the program may connect to (supports *.example.com).
Empty means all hosts are allowed unless the program lacks NetConnect.
memory_limit: Option<usize>Maximum heap memory in bytes. None = unlimited.
time_limit: Option<Duration>Maximum wall-clock execution time. None = unlimited.
output_limit: Option<usize>Maximum output bytes (stdout + sink). None = unlimited.
Implementations§
Source§impl RuntimePolicy
impl RuntimePolicy
Sourcepub fn unrestricted() -> Self
pub fn unrestricted() -> Self
Unrestricted policy (equivalent to not having a policy at all).
Sourcepub fn is_path_readable(&self, path: &Path) -> bool
pub fn is_path_readable(&self, path: &Path) -> bool
Check whether path is allowed for reading.
Returns true when:
allowed_pathsis empty (no path restrictions), orpathmatches at least one entry inallowed_pathsorread_only_paths.
Sourcepub fn is_path_writable(&self, path: &Path) -> bool
pub fn is_path_writable(&self, path: &Path) -> bool
Check whether path is allowed for writing.
Returns true when:
allowed_pathsis empty andread_only_pathsis empty, orpathmatches at least one entry inallowed_pathsand does NOT match any entry inread_only_paths.
Sourcepub fn is_host_allowed(&self, host: &str) -> bool
pub fn is_host_allowed(&self, host: &str) -> bool
Check whether a network host is allowed.
Returns true when allowed_hosts is empty or host matches at
least one pattern.
Trait Implementations§
Source§impl Clone for RuntimePolicy
impl Clone for RuntimePolicy
Source§fn clone(&self) -> RuntimePolicy
fn clone(&self) -> RuntimePolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more