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

Function sandbox_policy_update

crates/openshell-cli/src/run.rs:6766–6938  ·  view source on GitHub ↗
(
    server: &str,
    name: &str,
    add_endpoints: &[String],
    remove_endpoints: &[String],
    add_deny: &[String],
    add_allow: &[String],
    remove_rules: &[String],
    binaries: &[Strin

Source from the content-addressed store, hash-verified

6764
6765#[allow(clippy::too_many_arguments)]
6766pub async fn sandbox_policy_update(
6767 server: &str,
6768 name: &str,
6769 add_endpoints: &[String],
6770 remove_endpoints: &[String],
6771 add_deny: &[String],
6772 add_allow: &[String],
6773 remove_rules: &[String],
6774 binaries: &[String],
6775 rule_name: Option<&str>,
6776 dry_run: bool,
6777 wait: bool,
6778 timeout_secs: u64,
6779 tls: &TlsOptions,
6780) -> Result<()> {
6781 if dry_run && wait {
6782 return Err(miette!("--wait cannot be combined with --dry-run"));
6783 }
6784
6785 let plan = build_policy_update_plan(
6786 add_endpoints,
6787 remove_endpoints,
6788 add_deny,
6789 add_allow,
6790 remove_rules,
6791 binaries,
6792 rule_name,
6793 )?;
6794
6795 let mut client = grpc_client(server, tls).await?;
6796 let sandbox = client
6797 .get_sandbox(GetSandboxRequest {
6798 name: name.to_string(),
6799 })
6800 .await
6801 .into_diagnostic()?
6802 .into_inner()
6803 .sandbox
6804 .ok_or_else(|| miette!("sandbox not found"))?;
6805
6806 let sandbox_id = if sandbox.object_id().is_empty() {
6807 return Err(miette!("sandbox missing metadata"));
6808 } else {
6809 sandbox.object_id().to_string()
6810 };
6811
6812 let current = client
6813 .get_sandbox_config(GetSandboxConfigRequest { sandbox_id })
6814 .await
6815 .into_diagnostic()?
6816 .into_inner();
6817
6818 if current.policy_source == PolicySource::Global as i32 {
6819 return Err(miette!(
6820 "policy is managed globally; delete the global policy before using `openshell policy update`"
6821 ));
6822 }
6823

Callers 1

mainFunction · 0.85

Calls 11

build_policy_update_planFunction · 0.85
grpc_clientFunction · 0.85
merge_policyFunction · 0.85
print_sandbox_policyFunction · 0.85
object_idMethod · 0.80
get_sandboxMethod · 0.45
is_emptyMethod · 0.45
get_sandbox_configMethod · 0.45
update_configMethod · 0.45

Tested by

no test coverage detected