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

Method intent

crates/openshell-prover/src/policy.rs:165–192  ·  view source on GitHub ↗

The inferred access intent.

(&self)

Source from the content-addressed store, hash-verified

163
164 /// The inferred access intent.
165 pub fn intent(&self) -> PolicyIntent {
166 if self.protocol.is_empty() {
167 return PolicyIntent::L4Only;
168 }
169 match self.access.as_str() {
170 "read-only" => PolicyIntent::ReadOnly,
171 "read-write" => PolicyIntent::ReadWrite,
172 "full" => PolicyIntent::Full,
173 _ => {
174 if self.rules.is_empty() {
175 return PolicyIntent::Custom;
176 }
177 let methods: HashSet<String> =
178 self.rules.iter().map(|r| r.method.to_uppercase()).collect();
179 let read_only: HashSet<String> = ["GET", "HEAD", "OPTIONS"]
180 .iter()
181 .map(|s| (*s).to_owned())
182 .collect();
183 if methods.is_subset(&read_only) {
184 PolicyIntent::ReadOnly
185 } else if !methods.contains("DELETE") {
186 PolicyIntent::ReadWrite
187 } else {
188 PolicyIntent::Full
189 }
190 }
191 }
192 }
193
194 /// The effective list of ports for this endpoint.
195 pub fn effective_ports(&self) -> Vec<u16> {

Callers

nothing calls this directly

Calls 2

is_emptyMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected