(
endpoint: &mut NetworkEndpoint,
host: &str,
port: u32,
warnings: &mut Vec<PolicyMergeWarning>,
)
| 700 | } |
| 701 | |
| 702 | fn 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 | |
| 730 | fn expand_access_preset(protocol: &str, access: &str) -> Option<Vec<L7Rule>> { |
| 731 | let methods = match (protocol, access) { |
no test coverage detected