MCPcopy Create free account
hub / github.com/enowdev/enowX-Coder / test_is_outside_sandbox

Function test_is_outside_sandbox

src-tauri/src/tools/executor.rs:745–766  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

743
744 #[tokio::test]
745 async fn test_is_outside_sandbox() {
746 let sandbox_path = with_sandbox("outside_sandbox");
747
748 tokio::fs::write(sandbox_path.join("file.txt"), "data")
749 .await
750 .expect("create file");
751
752 let executor = ToolExecutor::new(sandbox_path);
753
754 // Path inside sandbox
755 assert!(!executor.is_outside_sandbox("file.txt"));
756 assert!(!executor.is_outside_sandbox("subdir/file.txt"));
757
758 // Path attempting escape via ..
759 assert!(executor.is_outside_sandbox("../outside.txt"));
760 assert!(executor.is_outside_sandbox("../../etc/passwd"));
761
762 // Absolute path outside sandbox
763 assert!(executor.is_outside_sandbox("/etc/shadow"));
764
765 cleanup("outside_sandbox");
766 }
767
768 // ── Read / Write File ─────────────────────────────────────────────────────
769

Callers

nothing calls this directly

Calls 2

with_sandboxFunction · 0.85
cleanupFunction · 0.85

Tested by

no test coverage detected