Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(spaces): a Space placed in your cloud by auto or overflow keeps its network rules or is refused (#6070)
ddupontdec726eaa63a
diff --git a/libs/cua/crates/cua-spaces/src/cloud.rs b/libs/cua/crates/cua-spaces/src/cloud.rsindex 1874079620..8b5994ad8d 100644--- a/libs/cua/crates/cua-spaces/src/cloud.rs+++ b/libs/cua/crates/cua-spaces/src/cloud.rs@@ -96,6 +96,11 @@ impl Spaces {/// Creates a Space in your cloud `word`: a sandbox there, then its/// relay machine as the Space.pub(crate) async fn create_in_cloud(&self, word: &str, opts: SpaceCreate) -> Result<SpaceInfo> {+ // Every way here (an explicit `on`, `auto`, overflow onto a Spaces+ // supplier) must keep the Space's network rules or refuse it: the+ // sandbox below has no host-side point that could enforce them, so a+ // Space that asked for rules would otherwise run open.+ refuse_network_rules(word, &opts)?;self.relay()?;let image = opts.image@@ -171,3 +176,63 @@ impl Spaces {}}}++/// A Space in your cloud account runs on a machine with no host-side point+/// cua controls, so it cannot keep egress rules or `network=none`: refused,+/// never started without them.+fn refuse_network_rules(word: &str, opts: &SpaceCreate) -> Result<()> {+ if !opts.egress.is_empty() {+ return Err(crate::egress::refused(+ word,+ "a Space in your own cloud account runs on a machine with no host-side point cua \+ controls; create it on this machine or one of yours",+ ));+ }+ if opts.network == cua_sandbox_core::NetworkMode::None {+ return Err(Error::invalid(format!(+ "network=none applies to VMs on your machines, not Spaces in your cloud ({word})"+ )));+ }+ Ok(())+}++#[cfg(test)]+mod tests {+ use super::*;++ fn opts() -> SpaceCreate {+ SpaceCreate {+ image: Some("linux".into()),+ ..Default::default()+ }+ }++ /// Overflow and `auto` reach a Spaces supplier through `create_in_cloud`+ /// with the caller's options: rules or `network=none` must be refused+ /// there, before anything is made, not dropped.+ #[tokio::test]+ async fn a_supplier_refuses_network_rules_instead_of_dropping_them() {+ let dir = tempfile::tempdir().unwrap();+ let s = Spaces::builder().home(dir.path()).build();++ let mut o = opts();+ o.egress = crate::egress::EgressPolicy {+ allow: vec![],+ deny: vec!["all".into()],+ };+ let e = s.create_in_cloud("modal", o).await.unwrap_err();+ assert_eq!(e.tag(), "wrong_provider", "{e}");+ assert!(e.to_string().contains("egress policy"), "{e}");++ let mut o = opts();+ o.network = cua_sandbox_core::NetworkMode::None;+ let e = s.create_in_cloud("modal", o).await.unwrap_err();+ assert_eq!(e.tag(), "invalid_argument", "{e}");+ assert!(e.to_string().contains("network=none"), "{e}");+ }++ #[test]+ fn a_space_without_rules_may_go_to_a_supplier() {+ assert!(refuse_network_rules("modal", &opts()).is_ok());+ }+}