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

Function expand_access_preset

crates/openshell-policy/src/merge.rs:730–757  ·  view source on GitHub ↗
(protocol: &str, access: &str)

Source from the content-addressed store, hash-verified

728}
729
730fn expand_access_preset(protocol: &str, access: &str) -> Option<Vec<L7Rule>> {
731 let methods = match (protocol, access) {
732 (_, "full") => vec!["*"],
733 ("websocket", "read-only") => vec!["GET"],
734 ("websocket", "read-write") => vec!["GET", "WEBSOCKET_TEXT"],
735 (_, "read-only") => vec!["GET", "HEAD", "OPTIONS"],
736 (_, "read-write") => vec!["GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH"],
737 _ => return None,
738 };
739
740 Some(
741 methods
742 .into_iter()
743 .map(|method| L7Rule {
744 allow: Some(L7Allow {
745 method: method.to_string(),
746 path: "**".to_string(),
747 command: String::new(),
748 query: HashMap::default(),
749 operation_type: String::new(),
750 operation_name: String::new(),
751 fields: Vec::new(),
752 params: HashMap::default(),
753 }),
754 })
755 .collect(),
756 )
757}
758
759fn append_unique_binaries(existing: &mut Vec<NetworkBinary>, incoming: &[NetworkBinary]) {
760 let mut seen: HashSet<String> = existing.iter().map(|binary| binary.path.clone()).collect();

Callers 1

expand_existing_accessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected