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

Function validate_policy_safety

crates/openshell-server/src/grpc/validation.rs:622–631  ·  view source on GitHub ↗

Validate that a policy does not contain unsafe content. Delegates to [`openshell_policy::validate_sandbox_policy`] and converts violations into a gRPC `INVALID_ARGUMENT` status.

(policy: &ProtoSandboxPolicy)

Source from the content-addressed store, hash-verified

620/// Delegates to [`openshell_policy::validate_sandbox_policy`] and converts
621/// violations into a gRPC `INVALID_ARGUMENT` status.
622pub(super) fn validate_policy_safety(policy: &ProtoSandboxPolicy) -> Result<(), Status> {
623 if let Err(violations) = openshell_policy::validate_sandbox_policy(policy) {
624 let messages: Vec<String> = violations.iter().map(ToString::to_string).collect();
625 return Err(Status::invalid_argument(format!(
626 "policy contains unsafe content: {}",
627 messages.join("; ")
628 )));
629 }
630 Ok(())
631}
632
633/// Validate that user-authored policy does not use provider-derived rule keys.
634pub(super) fn validate_no_reserved_provider_policy_keys(

Calls 1

validate_sandbox_policyFunction · 0.85