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

Function provider_rule_name

crates/openshell-policy/src/compose.rs:22–41  ·  view source on GitHub ↗
(provider_name: &str)

Source from the content-addressed store, hash-verified

20
21#[must_use]
22pub fn provider_rule_name(provider_name: &str) -> String {
23 let sanitized = provider_name
24 .chars()
25 .map(|c| {
26 if c.is_ascii_alphanumeric() || c == '_' {
27 c.to_ascii_lowercase()
28 } else {
29 '_'
30 }
31 })
32 .collect::<String>()
33 .trim_matches('_')
34 .to_string();
35
36 if sanitized.is_empty() {
37 format!("{PROVIDER_RULE_NAME_PREFIX}unnamed")
38 } else {
39 format!("{PROVIDER_RULE_NAME_PREFIX}{sanitized}")
40 }
41}
42
43pub fn strip_provider_rule_names(policy: &mut SandboxPolicy) -> bool {
44 let original_len = policy.network_policies.len();

Callers 1

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected