()
| 677 | |
| 678 | #[tokio::test] |
| 679 | async fn test_path_traversal_absolute_escape() { |
| 680 | let sandbox_path = with_sandbox("path_traversal_abs"); |
| 681 | |
| 682 | tokio::fs::write(sandbox_path.join("safe.txt"), "hello") |
| 683 | .await |
| 684 | .expect("create safe.txt"); |
| 685 | |
| 686 | let executor = ToolExecutor::new(sandbox_path); |
| 687 | |
| 688 | // Absolute path pointing outside sandbox |
| 689 | let call = ToolCall { |
| 690 | tool: ToolName::ReadFile, |
| 691 | input: serde_json::json!({ "path": "/etc/passwd" }), |
| 692 | }; |
| 693 | let result = executor.execute(call).await; |
| 694 | assert!( |
| 695 | result.is_error, |
| 696 | "Absolute path outside sandbox should be rejected, got: {}", |
| 697 | result.output |
| 698 | ); |
| 699 | |
| 700 | cleanup("path_traversal_abs"); |
| 701 | } |
| 702 | |
| 703 | #[tokio::test] |
| 704 | #[cfg(unix)] |
nothing calls this directly
no test coverage detected