()
| 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 |
nothing calls this directly
no test coverage detected