MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / validate_sandbox_state_dir

Function validate_sandbox_state_dir

crates/openshell-driver-vm/src/driver.rs:4213–4240  ·  view source on GitHub ↗
(root: &Path, state_dir: &Path)

Source from the content-addressed store, hash-verified

4211
4212#[allow(clippy::result_large_err)]
4213fn validate_sandbox_state_dir(root: &Path, state_dir: &Path) -> Result<(), Status> {
4214 let sandboxes_root = sandboxes_root_dir(root);
4215 let relative = state_dir.strip_prefix(&sandboxes_root).map_err(|_| {
4216 Status::internal(format!(
4217 "refusing to use sandbox state path outside vm state root: {}",
4218 state_dir.display()
4219 ))
4220 })?;
4221
4222 let mut components = relative.components();
4223 match components.next() {
4224 Some(Component::Normal(_)) => {}
4225 _ => {
4226 return Err(Status::internal(format!(
4227 "refusing to use malformed sandbox state path: {}",
4228 state_dir.display()
4229 )));
4230 }
4231 }
4232 if components.next().is_some() {
4233 return Err(Status::internal(format!(
4234 "refusing to use nested sandbox state path: {}",
4235 state_dir.display()
4236 )));
4237 }
4238
4239 Ok(())
4240}
4241
4242async fn remove_sandbox_state_dir(root: &Path, state_dir: &Path) -> Result<(), Status> {
4243 validate_sandbox_state_dir(root, state_dir)?;

Callers 2

remove_sandbox_state_dirFunction · 0.85

Calls 2

sandboxes_root_dirFunction · 0.85
nextMethod · 0.45

Tested by

no test coverage detected