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

Function expand_existing_access

crates/openshell-policy/src/merge.rs:702–728  ·  view source on GitHub ↗
(
    endpoint: &mut NetworkEndpoint,
    host: &str,
    port: u32,
    warnings: &mut Vec<PolicyMergeWarning>,
)

Source from the content-addressed store, hash-verified

700}
701
702fn expand_existing_access(
703 endpoint: &mut NetworkEndpoint,
704 host: &str,
705 port: u32,
706 warnings: &mut Vec<PolicyMergeWarning>,
707) -> Result<(), PolicyMergeError> {
708 if endpoint.access.is_empty() {
709 return Ok(());
710 }
711
712 let access = endpoint.access.clone();
713 let expanded = expand_access_preset(&endpoint.protocol, &access).ok_or_else(|| {
714 PolicyMergeError::UnsupportedAccessPreset {
715 host: host.to_string(),
716 port,
717 access: access.clone(),
718 }
719 })?;
720 endpoint.access.clear();
721 append_unique_l7_rules(&mut endpoint.rules, &expanded);
722 warnings.push(PolicyMergeWarning::ExpandedAccessPreset {
723 host: host.to_string(),
724 port,
725 access,
726 });
727 Ok(())
728}
729
730fn expand_access_preset(protocol: &str, access: &str) -> Option<Vec<L7Rule>> {
731 let methods = match (protocol, access) {

Callers 2

apply_operationFunction · 0.85
merge_endpointFunction · 0.85

Calls 5

expand_access_presetFunction · 0.85
append_unique_l7_rulesFunction · 0.85
pushMethod · 0.80
is_emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected