Skip to content

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

test(sandbox): cover null redirection through jail facade

Steven Enamakelf9b58a975654
diff --git a/tests/cwd_jail_e2e.rs b/tests/cwd_jail_e2e.rs
index dc1c9354a6..7c8d7cbe91 100644
--- a/tests/cwd_jail_e2e.rs
+++ b/tests/cwd_jail_e2e.rs
@@ -216,6 +216,31 @@ fn macos_seatbelt_allows_write_inside_root() {
fs::remove_dir_all(&root).ok();
}
+#[cfg(target_os = "macos")]
+#[test]
+fn macos_seatbelt_allows_shell_redirection_to_dev_null() {
+ if !PathBuf::from("/usr/bin/sandbox-exec").exists() {
+ return;
+ }
+ let root = tempfile::tempdir().unwrap();
+ let jail = Jail::new(root.path(), "e2e.seatbelt.null");
+ let mut cmd = Command::new("/bin/sh");
+ cmd.arg("-c")
+ .arg(
+ "set -e; echo ignored >/dev/null; echo hidden 2>/dev/null >&2; echo completed > output",
+ )
+ .current_dir(root.path())
+ .stdout(Stdio::null())
+ .stderr(Stdio::null());
+
+ let mut child = spawn(&jail, cmd).expect("spawn under seatbelt");
+ assert!(child.wait().expect("wait").success());
+ assert_eq!(
+ fs::read_to_string(root.path().join("output")).unwrap(),
+ "completed\n"
+ );
+}
+
#[cfg(target_os = "macos")]
#[test]
fn macos_seatbelt_blocks_network_when_denied() {