pub struct KernelSandbox {
policy: SandboxPolicy,
kernel_id: Option<KernelId>,
stats: RwLock<SandboxStats>,
violations: RwLock<Vec<SandboxViolation>>,
start_time: RwLock<Option<Instant>>,
message_count: AtomicU64,
last_rate_check: RwLock<Instant>,
}Expand description
Kernel sandbox for isolation and resource control.
Fields§
§policy: SandboxPolicyThe sandbox policy
kernel_id: Option<KernelId>Kernel this sandbox applies to
stats: RwLock<SandboxStats>Statistics
violations: RwLock<Vec<SandboxViolation>>Recorded violations
start_time: RwLock<Option<Instant>>Start time for execution tracking
message_count: AtomicU64Message count for rate limiting
last_rate_check: RwLock<Instant>Last rate check time
Implementations§
Source§impl KernelSandbox
impl KernelSandbox
Sourcepub fn new(policy: SandboxPolicy) -> Self
pub fn new(policy: SandboxPolicy) -> Self
Create a new kernel sandbox.
Sourcepub fn apply_to_kernel(&mut self, kernel_id: KernelId)
pub fn apply_to_kernel(&mut self, kernel_id: KernelId)
Apply sandbox to a kernel.
Sourcepub fn check_memory(&self, bytes: u64) -> Result<(), SandboxViolation>
pub fn check_memory(&self, bytes: u64) -> Result<(), SandboxViolation>
Check memory usage against limits.
Sourcepub fn check_execution_time(&self) -> Result<(), SandboxViolation>
pub fn check_execution_time(&self) -> Result<(), SandboxViolation>
Check execution time against limits.
Sourcepub fn check_k2k(&self, destination: &str) -> Result<(), SandboxViolation>
pub fn check_k2k(&self, destination: &str) -> Result<(), SandboxViolation>
Check K2K destination against policy.
Sourcepub fn check_checkpoint(&self) -> Result<(), SandboxViolation>
pub fn check_checkpoint(&self) -> Result<(), SandboxViolation>
Check if checkpointing is allowed.
Sourcepub fn check_migration(&self) -> Result<(), SandboxViolation>
pub fn check_migration(&self) -> Result<(), SandboxViolation>
Check if migration is allowed.
Sourcepub fn record_message(&self) -> Result<(), SandboxViolation>
pub fn record_message(&self) -> Result<(), SandboxViolation>
Record a message for rate limiting.
Sourcefn record_violation(&self, violation: SandboxViolation)
fn record_violation(&self, violation: SandboxViolation)
Record a violation.
Sourcepub fn violations(&self) -> Vec<SandboxViolation>
pub fn violations(&self) -> Vec<SandboxViolation>
Get all recorded violations.
Sourcepub fn stats(&self) -> SandboxStats
pub fn stats(&self) -> SandboxStats
Get sandbox statistics.
Sourcepub fn policy(&self) -> &SandboxPolicy
pub fn policy(&self) -> &SandboxPolicy
Get the policy.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for KernelSandbox
impl RefUnwindSafe for KernelSandbox
impl Send for KernelSandbox
impl Sync for KernelSandbox
impl Unpin for KernelSandbox
impl UnwindSafe for KernelSandbox
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.