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

Function endpoint_allowed_methods_in_rule

crates/openshell-prover/src/queries.rs:282–297  ·  view source on GitHub ↗

Allowed HTTP methods for the endpoint in `policy.network_policies[policy_name]` matching `(host, port)`. Returns empty when the rule or endpoint is not found (e.g. SAT path threaded through a stale model).

(
    policy: &crate::policy::PolicyModel,
    policy_name: &str,
    host: &str,
    port: u16,
)

Source from the content-addressed store, hash-verified

280/// matching `(host, port)`. Returns empty when the rule or endpoint is not
281/// found (e.g. SAT path threaded through a stale model).
282fn endpoint_allowed_methods_in_rule(
283 policy: &crate::policy::PolicyModel,
284 policy_name: &str,
285 host: &str,
286 port: u16,
287) -> HashSet<String> {
288 let Some(rule) = policy.network_policies.get(policy_name) else {
289 return HashSet::new();
290 };
291 for ep in &rule.endpoints {
292 if ep.host.eq_ignore_ascii_case(host) && ep.effective_ports().contains(&port) {
293 return ep.allowed_methods();
294 }
295 }
296 HashSet::new()
297}
298
299// ---------------------------------------------------------------------------
300// Tests

Callers 1

check_credential_safetyFunction · 0.85

Calls 3

effective_portsMethod · 0.80
allowed_methodsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected