(provider_name: &str)
| 20 | |
| 21 | #[must_use] |
| 22 | pub 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 | |
| 43 | pub fn strip_provider_rule_names(policy: &mut SandboxPolicy) -> bool { |
| 44 | let original_len = policy.network_policies.len(); |
no test coverage detected