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

Function test_path_traversal_absolute_escape

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

Source from the content-addressed store, hash-verified

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)]

Callers

nothing calls this directly

Calls 3

with_sandboxFunction · 0.85
cleanupFunction · 0.85
executeMethod · 0.80

Tested by

no test coverage detected