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

Function unique_provider_rule_key

crates/openshell-policy/src/compose.rs:77–90  ·  view source on GitHub ↗
(policy: &SandboxPolicy, preferred: &str)

Source from the content-addressed store, hash-verified

75}
76
77fn unique_provider_rule_key(policy: &SandboxPolicy, preferred: &str) -> String {
78 if !policy.network_policies.contains_key(preferred) {
79 return preferred.to_string();
80 }
81
82 for suffix in 2_u32.. {
83 let candidate = format!("{preferred}_{suffix}");
84 if !policy.network_policies.contains_key(&candidate) {
85 return candidate;
86 }
87 }
88
89 unreachable!("unbounded suffix search must find an unused provider policy key")
90}
91
92#[cfg(test)]
93mod tests {

Callers 1

compose_effective_policyFunction · 0.85

Calls 1

contains_keyMethod · 0.80

Tested by

no test coverage detected