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

Function load_sandbox_policy

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

Load a sandbox policy from an explicit source. Resolution order: 1. `cli_path` argument (e.g. from a `--policy` flag) 2. `OPENSHELL_SANDBOX_POLICY` environment variable Returns `Ok(None)` when no policy source is configured, allowing the caller to omit the policy and let the server / sandbox apply its own default.

(cli_path: Option<&str>)

Source from the content-addressed store, hash-verified

1005/// caller to omit the policy and let the server / sandbox apply its own
1006/// default.
1007pub fn load_sandbox_policy(cli_path: Option<&str>) -> Result<Option<SandboxPolicy>> {
1008 let contents = if let Some(p) = cli_path {
1009 let path = Path::new(p);
1010 std::fs::read_to_string(path)
1011 .into_diagnostic()
1012 .wrap_err_with(|| format!("failed to read sandbox policy from {}", path.display()))?
1013 } else if let Ok(policy_path) = std::env::var("OPENSHELL_SANDBOX_POLICY") {
1014 let path = Path::new(&policy_path);
1015 std::fs::read_to_string(path)
1016 .into_diagnostic()
1017 .wrap_err_with(|| format!("failed to read sandbox policy from {}", path.display()))?
1018 } else {
1019 return Ok(None);
1020 };
1021 parse_sandbox_policy(&contents).map(Some)
1022}
1023
1024/// Well-known path where a sandbox container image can ship a policy YAML file.
1025///

Callers

nothing calls this directly

Calls 1

parse_sandbox_policyFunction · 0.85

Tested by

no test coverage detected