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

Function is_valid_sandbox_identity

crates/openshell-policy/src/lib.rs:946–953  ·  view source on GitHub ↗

Validate whether a process identity field value is acceptable. Accepts either the literal `"sandbox"` or a numeric UID/GID parsed as `u32` within the range `[MIN_SANDBOX_UID, MAX_SANDBOX_UID]`. Rejects: - The empty string (callers should use `ensure_sandbox_process_identity` to fill defaults before validation) - UID 0 or values below `MIN_SANDBOX_UID` - Values above `MAX_SANDBOX_UID` - Non-numer

(value: &str)

Source from the content-addressed store, hash-verified

944/// - Values above `MAX_SANDBOX_UID`
945/// - Non-numeric strings other than `"sandbox"` (e.g. `"root"`, `"nobody"`)
946pub fn is_valid_sandbox_identity(value: &str) -> bool {
947 if value == SANDBOX_NAME {
948 return true;
949 }
950 value
951 .parse::<u32>()
952 .is_ok_and(|uid| (MIN_SANDBOX_UID..=MAX_SANDBOX_UID).contains(&uid))
953}
954
955// ---------------------------------------------------------------------------
956// Public API

Callers 4

validate_sandbox_userFunction · 0.85
validate_sandbox_groupFunction · 0.85
validate_sandbox_policyFunction · 0.85
run_sandboxFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected