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)
| 620 | /// Delegates to [`openshell_policy::validate_sandbox_policy`] and converts |
| 621 | /// violations into a gRPC `INVALID_ARGUMENT` status. |
| 622 | pub(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. |
| 634 | pub(super) fn validate_no_reserved_provider_policy_keys( |