Skip to content

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

chore(sandbox): add read_write_mounts field to SandboxPolicy and fix formatting

Steven Enamakelf59555ffd217
diff --git a/crates/openhuman-core/src/config/mod.rs b/crates/openhuman-core/src/config/mod.rs
index 871337fac6..ab72f061a0 100644
--- a/crates/openhuman-core/src/config/mod.rs
+++ b/crates/openhuman-core/src/config/mod.rs
@@ -48,24 +48,24 @@ pub use schema::{
DictationActivationMode, DictationConfig, DiscordConfig, DockerRuntimeConfig, EmailConfig,
EmbeddingRouteConfig, GitbooksConfig, HttpHeader, HttpRequestConfig, IMessageConfig,
IntegrationToggle, IntegrationsConfig, LarkConfig, LearningConfig, LegacySearchInputs,
- LinqConfig, LlmBackend, LocalAiConfig, LocalJailConfig, MatrixConfig, McpAuthConfig, McpClientConfig,
- McpClientIdentityConfig, McpServerConfig, McpToolExposure, MemoryConfig, MemoryTreeConfig,
- ModelRouteConfig, MultimodalConfig, MultimodalFileConfig, ObservabilityConfig,
- OrchestratorModelConfig, PrivacyConfig, PrivacyMode, ProxyConfig, ProxyScope, ReflectionSource,
- ReliabilityConfig, ResourceLimitsConfig, RuntimeConfig, RuntimePoolConfig,
- RuntimePoolLangConfig, SandboxBackend, SandboxConfig, SchedulerConfig, SchedulerGateConfig,
- SchedulerGateMode, SearchConfig, SearchEngineCredentials, SearchPresentation,
- SearchProviderSettings, SearchRoute, SearxngConfig, SecretsConfig, SecurityConfig, ShellConfig,
- SlackConfig, StorageConfig, StorageProviderConfig, StorageProviderSection, StreamMode,
- SttEngine, TeamModelConfig, TelegramConfig, TokenjuiceConfig, UpdateConfig,
- UpdateRestartStrategy, VoiceActivationMode, VoiceServerConfig, WebSearchConfig, WebhookConfig,
- YuanbaoConfig, DEFAULT_CLOUD_LLM_MODEL, DEFAULT_MEMORY_SYNC_INTERVAL_SECS, DEFAULT_MODEL,
- LEGACY_TIER_MODELS, MANAGED_MULTIMODAL_MODELS, MANAGED_SEARCH_PROVIDERS,
- MEMORY_SYNC_INTERVAL_PRESETS_SECS, MODEL_IMAGE_GENERATION_AGENT, MODEL_MANAGED_DEFAULT,
- MODEL_MEDIA_UNDERSTANDING, MODEL_VIDEO_GENERATION_AGENT, SEARCH_ENGINE_BRAVE,
- SEARCH_ENGINE_DISABLED, SEARCH_ENGINE_EXA, SEARCH_ENGINE_MANAGED, SEARCH_ENGINE_PARALLEL,
- SEARCH_ENGINE_QUERIT, SEARCH_ENGINE_TAVILY, SEARCH_PROVIDERS, SEARCH_ROLES, SEARCH_ROLE_ANSWER,
- SEARCH_ROLE_CONTENTS, SEARCH_ROLE_SEARCH,
+ LinqConfig, LlmBackend, LocalAiConfig, LocalJailConfig, MatrixConfig, McpAuthConfig,
+ McpClientConfig, McpClientIdentityConfig, McpServerConfig, McpToolExposure, MemoryConfig,
+ MemoryTreeConfig, ModelRouteConfig, MultimodalConfig, MultimodalFileConfig,
+ ObservabilityConfig, OrchestratorModelConfig, PrivacyConfig, PrivacyMode, ProxyConfig,
+ ProxyScope, ReflectionSource, ReliabilityConfig, ResourceLimitsConfig, RuntimeConfig,
+ RuntimePoolConfig, RuntimePoolLangConfig, SandboxBackend, SandboxConfig, SchedulerConfig,
+ SchedulerGateConfig, SchedulerGateMode, SearchConfig, SearchEngineCredentials,
+ SearchPresentation, SearchProviderSettings, SearchRoute, SearxngConfig, SecretsConfig,
+ SecurityConfig, ShellConfig, SlackConfig, StorageConfig, StorageProviderConfig,
+ StorageProviderSection, StreamMode, SttEngine, TeamModelConfig, TelegramConfig,
+ TokenjuiceConfig, UpdateConfig, UpdateRestartStrategy, VoiceActivationMode, VoiceServerConfig,
+ WebSearchConfig, WebhookConfig, YuanbaoConfig, DEFAULT_CLOUD_LLM_MODEL,
+ DEFAULT_MEMORY_SYNC_INTERVAL_SECS, DEFAULT_MODEL, LEGACY_TIER_MODELS,
+ MANAGED_MULTIMODAL_MODELS, MANAGED_SEARCH_PROVIDERS, MEMORY_SYNC_INTERVAL_PRESETS_SECS,
+ MODEL_IMAGE_GENERATION_AGENT, MODEL_MANAGED_DEFAULT, MODEL_MEDIA_UNDERSTANDING,
+ MODEL_VIDEO_GENERATION_AGENT, SEARCH_ENGINE_BRAVE, SEARCH_ENGINE_DISABLED, SEARCH_ENGINE_EXA,
+ SEARCH_ENGINE_MANAGED, SEARCH_ENGINE_PARALLEL, SEARCH_ENGINE_QUERIT, SEARCH_ENGINE_TAVILY,
+ SEARCH_PROVIDERS, SEARCH_ROLES, SEARCH_ROLE_ANSWER, SEARCH_ROLE_CONTENTS, SEARCH_ROLE_SEARCH,
};
// Kept as a separate re-export (issue #4117) so the large alphabetized group
// above stays byte-identical and rustfmt-stable.
diff --git a/crates/openhuman-core/src/sandbox/docker_exec_tests.rs b/crates/openhuman-core/src/sandbox/docker_exec_tests.rs
index f330fe351c..96211ce1c5 100644
--- a/crates/openhuman-core/src/sandbox/docker_exec_tests.rs
+++ b/crates/openhuman-core/src/sandbox/docker_exec_tests.rs
@@ -67,6 +67,7 @@ fn policy(workspace: &Path) -> SandboxPolicy {
workspace_root: workspace.to_path_buf(),
state_dir: PathBuf::from("/tmp/state"),
read_only_mounts: vec![],
+ read_write_mounts: vec![],
allow_network: false,
env_passthrough: vec![],
docker_overrides: None,
diff --git a/crates/openhuman-core/src/sandbox/docker_tests.rs b/crates/openhuman-core/src/sandbox/docker_tests.rs
index f358f81775..e0f6fb34dd 100644
--- a/crates/openhuman-core/src/sandbox/docker_tests.rs
+++ b/crates/openhuman-core/src/sandbox/docker_tests.rs
@@ -8,6 +8,7 @@ fn test_policy() -> SandboxPolicy {
workspace_root: PathBuf::from("/tmp/test-workspace"),
state_dir: PathBuf::from("/tmp/state"),
read_only_mounts: vec![],
+ read_write_mounts: vec![],
allow_network: false,
env_passthrough: vec!["PATH".into(), "HOME".into()],
docker_overrides: None,
diff --git a/crates/openhuman-core/src/sandbox/grants.rs b/crates/openhuman-core/src/sandbox/grants.rs
index e87def5c08..092c6dd7d2 100644
--- a/crates/openhuman-core/src/sandbox/grants.rs
+++ b/crates/openhuman-core/src/sandbox/grants.rs
@@ -212,7 +212,9 @@ impl<'a> Builder<'a> {
depth: usize,
visited: &mut HashSet<PathBuf>,
) {
- let Ok(canonical) = file.canonicalize() else { return };
+ let Ok(canonical) = file.canonicalize() else {
+ return;
+ };
if !canonical.is_file() || !visited.insert(canonical.clone()) {
return;
}
@@ -220,7 +222,9 @@ impl<'a> Builder<'a> {
if depth >= GITCONFIG_MAX_DEPTH {
return;
}
- let Ok(text) = std::fs::read_to_string(&canonical) else { return };
+ let Ok(text) = std::fs::read_to_string(&canonical) else {
+ return;
+ };
// Relative includes resolve against the directory of the file *as
// named*, which for a symlinked config is the link's directory.
let base = file.parent().unwrap_or(home);
@@ -245,7 +249,8 @@ fn include_paths(config: &str) -> Vec<String> {
let line = line.trim();
if let Some(section) = line.strip_prefix('[') {
let name = section.split([']', ' ', '"']).next().unwrap_or("");
- in_include = name.eq_ignore_ascii_case("include") || name.eq_ignore_ascii_case("includeif");
+ in_include =
+ name.eq_ignore_ascii_case("include") || name.eq_ignore_ascii_case("includeif");
continue;
}
if !in_include {
diff --git a/crates/openhuman-core/src/sandbox/grants_tests.rs b/crates/openhuman-core/src/sandbox/grants_tests.rs
index be0df9d3c5..7693d492b1 100644
--- a/crates/openhuman-core/src/sandbox/grants_tests.rs
+++ b/crates/openhuman-core/src/sandbox/grants_tests.rs
@@ -4,7 +4,9 @@ use std::path::{Path, PathBuf};
fn fake_home() -> tempfile::TempDir {
let home = tempfile::tempdir().unwrap();
- for d in [".ssh", ".gnupg", ".aws", ".cargo", ".rustup", ".nvm", ".npm"] {
+ for d in [
+ ".ssh", ".gnupg", ".aws", ".cargo", ".rustup", ".nvm", ".npm",
+ ] {
fs::create_dir_all(home.path().join(d)).unwrap();
}
home
@@ -83,7 +85,10 @@ fn toolchain_homes_are_granted_when_they_exist() {
assert!(has(&g.read_write, &h.join(".cargo")));
for ro in [".rustup", ".nvm", ".npm"] {
assert!(has(&g.read_only, &h.join(ro)), "{ro} should be read-only");
- assert!(!has(&g.read_write, &h.join(ro)), "{ro} must not be writable");
+ assert!(
+ !has(&g.read_write, &h.join(ro)),
+ "{ro} must not be writable"
+ );
}
for sys in ["/usr/local", "/opt"] {
if Path::new(sys).exists() {
@@ -122,11 +127,18 @@ fn cargo_home_with_registry_credentials_is_granted_piecewise() {
for d in ["bin", "registry", "git"] {
fs::create_dir_all(cargo.join(d)).unwrap();
}
- fs::write(cargo.join("credentials.toml"), "[registry]\ntoken = \"x\"\n").unwrap();
+ fs::write(
+ cargo.join("credentials.toml"),
+ "[registry]\ntoken = \"x\"\n",
+ )
+ .unwrap();
fs::write(cargo.join("config.toml"), "").unwrap();
let g = resolve_local_jail_grants(Some(home.path()), &LocalJailConfig::default());
let c = canon(&cargo);
- assert!(!has(&g.read_write, &c), "whole ~/.cargo would expose credentials.toml");
+ assert!(
+ !has(&g.read_write, &c),
+ "whole ~/.cargo would expose credentials.toml"
+ );
assert!(!all(&g).iter().any(|p| p.ends_with("credentials.toml")));
assert!(has(&g.read_write, &c.join("registry")));
assert!(has(&g.read_write, &c.join("git")));
@@ -212,5 +224,8 @@ fn gitconfig_include_cycles_terminate() {
fn no_home_yields_only_system_toolchain_dirs() {
let g = resolve_local_jail_grants(None, &LocalJailConfig::default());
assert!(g.read_write.is_empty());
- assert!(g.read_only.iter().all(|p| p.starts_with("/usr/local") || p.starts_with("/opt")));
+ assert!(g
+ .read_only
+ .iter()
+ .all(|p| p.starts_with("/usr/local") || p.starts_with("/opt")));
}
diff --git a/crates/openhuman-core/src/sandbox/schemas_tests.rs b/crates/openhuman-core/src/sandbox/schemas_tests.rs
index 4e4234f04a..a9476afba8 100644
--- a/crates/openhuman-core/src/sandbox/schemas_tests.rs
+++ b/crates/openhuman-core/src/sandbox/schemas_tests.rs
@@ -168,6 +168,7 @@ async fn handle_validate_policy_valid() {
workspace_root: std::path::PathBuf::from("/tmp/safe"),
state_dir: std::path::PathBuf::from("/tmp/state"),
read_only_mounts: vec![],
+ read_write_mounts: vec![],
allow_network: false,
env_passthrough: vec![],
docker_overrides: None,
@@ -187,6 +188,7 @@ async fn handle_validate_policy_dangerous() {
workspace_root: std::path::PathBuf::from("/"),
state_dir: std::path::PathBuf::from("/tmp/state"),
read_only_mounts: vec![],
+ read_write_mounts: vec![],
allow_network: false,
env_passthrough: vec![],
docker_overrides: Some(super::super::types::DockerOverrides {
diff --git a/crates/openhuman-core/src/sandbox/types_tests.rs b/crates/openhuman-core/src/sandbox/types_tests.rs
index 8ffbe0ab2c..fcbe0f0042 100644
--- a/crates/openhuman-core/src/sandbox/types_tests.rs
+++ b/crates/openhuman-core/src/sandbox/types_tests.rs
@@ -39,6 +39,7 @@ fn sandbox_policy_serializes_roundtrip() {
workspace_root: PathBuf::from("/workspace"),
state_dir: PathBuf::from("/tmp/state"),
read_only_mounts: vec![PathBuf::from("/usr/lib")],
+ read_write_mounts: vec![],
allow_network: false,
env_passthrough: vec!["PATH".into()],
docker_overrides: Some(DockerOverrides {