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

Function flush_activity_to_gateway

crates/openshell-sandbox/src/lib.rs:623–664  ·  view source on GitHub ↗

Flush an anonymous activity summary to the gateway via `SubmitPolicyAnalysis`.

(
    endpoint: &str,
    sandbox_name: &str,
    summary: activity_aggregator::FlushableActivitySummary,
)

Source from the content-addressed store, hash-verified

621
622/// Flush an anonymous activity summary to the gateway via `SubmitPolicyAnalysis`.
623async fn flush_activity_to_gateway(
624 endpoint: &str,
625 sandbox_name: &str,
626 summary: activity_aggregator::FlushableActivitySummary,
627) -> Result<()> {
628 use openshell_core::grpc_client::CachedOpenShellClient;
629 use openshell_core::proto::{DenialGroupCount, NetworkActivitySummary};
630
631 let client = CachedOpenShellClient::connect(endpoint).await?;
632
633 let proto_summary = NetworkActivitySummary {
634 network_activity_count: summary.network_activity_count,
635 denied_action_count: summary.denied_action_count,
636 denials_by_group: summary
637 .denials_by_group
638 .into_iter()
639 .map(|(group, count)| DenialGroupCount {
640 deny_group: group,
641 denied_count: count,
642 })
643 .collect(),
644 };
645
646 info!(
647 sandbox_name = %sandbox_name,
648 network_activity_count = proto_summary.network_activity_count,
649 denied_action_count = proto_summary.denied_action_count,
650 "Flushed activity summary to gateway"
651 );
652
653 client
654 .submit_policy_analysis(
655 sandbox_name,
656 Vec::new(),
657 Vec::new(),
658 vec![proto_summary],
659 "activity",
660 )
661 .await?;
662
663 Ok(())
664}
665
666// ============================================================================
667// Baseline filesystem path enrichment

Callers 1

run_sandboxFunction · 0.85

Calls 2

connectFunction · 0.85

Tested by

no test coverage detected