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

Function query_allowed_ips

crates/openshell-supervisor-network/src/proxy.rs:2730–2770  ·  view source on GitHub ↗

Query `allowed_ips` from the matched endpoint config for a CONNECT decision.

(
    engine: &OpaEngine,
    decision: &ConnectDecision,
    host: &str,
    port: u16,
)

Source from the content-addressed store, hash-verified

2728
2729/// Query `allowed_ips` from the matched endpoint config for a CONNECT decision.
2730fn query_allowed_ips(
2731 engine: &OpaEngine,
2732 decision: &ConnectDecision,
2733 host: &str,
2734 port: u16,
2735) -> Vec<String> {
2736 // Only query if action is Allow with a matched policy
2737 let has_policy = match &decision.action {
2738 NetworkAction::Allow { matched_policy } => matched_policy.is_some(),
2739 NetworkAction::Deny { .. } => false,
2740 };
2741 if !has_policy {
2742 return vec![];
2743 }
2744
2745 let input = crate::opa::NetworkInput {
2746 host: host.to_string(),
2747 port,
2748 binary_path: decision.binary.clone().unwrap_or_default(),
2749 binary_sha256: String::new(),
2750 ancestors: decision.ancestors.clone(),
2751 cmdline_paths: decision.cmdline_paths.clone(),
2752 };
2753
2754 match engine.query_allowed_ips(&input) {
2755 Ok(ips) => ips,
2756 Err(e) => {
2757 let event = NetworkActivityBuilder::new(openshell_ocsf::ctx::ctx())
2758 .activity(ActivityId::Fail)
2759 .severity(SeverityId::Low)
2760 .status(StatusId::Failure)
2761 .dst_endpoint(Endpoint::from_domain(host, port))
2762 .message(format!(
2763 "Failed to query allowed_ips from endpoint config: {e}"
2764 ))
2765 .build();
2766 ocsf_emit!(event);
2767 vec![]
2768 }
2769 }
2770}
2771
2772/// Query whether the matched endpoint was declared as this exact hostname.
2773fn query_exact_declared_endpoint_host(

Callers 2

handle_tcp_connectionFunction · 0.85
handle_forward_proxyFunction · 0.85

Calls 4

query_allowed_ipsMethod · 0.80
messageMethod · 0.80
ctxFunction · 0.50
buildMethod · 0.45

Tested by

no test coverage detected