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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RuntimePolicy
impl RefUnwindSafe for RuntimePolicy
impl Send for RuntimePolicy
impl Sync for RuntimePolicy
impl Unpin for RuntimePolicy
impl UnsafeUnpin for RuntimePolicy
impl UnwindSafe for RuntimePolicy
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
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>
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>
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