Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(security): add scratch dir enforcement tests

Steven Enamakelac03b9981b53
diff --git a/crates/openhuman-core/src/security/policy/enforcement_scratch_dir_tests_tests.rs b/crates/openhuman-core/src/security/policy/enforcement_scratch_dir_tests_tests.rs
index 719e50a1d2..faa0a7eb9d 100644
--- a/crates/openhuman-core/src/security/policy/enforcement_scratch_dir_tests_tests.rs
+++ b/crates/openhuman-core/src/security/policy/enforcement_scratch_dir_tests_tests.rs
@@ -18,3 +18,29 @@ fn ensure_scratch_dir_creates_and_returns_it() {
assert_eq!(ensured.as_deref(), Some(expected.as_path()));
assert!(expected.is_dir());
}
+
+fn roots(saas: bool) -> Vec<String> {
+ let tmp = tempfile::tempdir().unwrap();
+ let policy = crate::security::SecurityPolicy::from_config_with(
+ saas,
+ &crate::config::AutonomyConfig::default(),
+ &tmp.path().join("ws"),
+ &tmp.path().join("act"),
+ );
+ policy.trusted_roots.iter().map(|r| r.path.clone()).collect()
+}
+
+#[test]
+fn saas_policy_skips_the_shared_projects_and_scratch_grants() {
+ let projects = crate::config::default_projects_dir()
+ .to_string_lossy()
+ .to_string();
+ let scratch = openhuman_scratch_dir().to_string_lossy().to_string();
+ let saas = roots(true);
+ assert!(!saas.contains(&projects), "projects home must not be granted in SaaS");
+ assert!(!saas.contains(&scratch), "/tmp/openhuman must not be granted in SaaS");
+
+ let single = roots(false);
+ assert!(single.contains(&projects));
+ assert!(single.contains(&scratch));
+}