test_path_traversal_with_double_dots() — langchain Function Reference
Architecture documentation for the test_path_traversal_with_double_dots() function in test_file_search.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 65430092_8c79_eb6c_a3e4_dbde1d79021c["test_path_traversal_with_double_dots()"] e5a178bd_bdb1_3bca_cf3b_735c1d713414["TestPathTraversalSecurity"] 65430092_8c79_eb6c_a3e4_dbde1d79021c -->|defined in| e5a178bd_bdb1_3bca_cf3b_735c1d713414 style 65430092_8c79_eb6c_a3e4_dbde1d79021c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_file_search.py lines 217–234
def test_path_traversal_with_double_dots(self, tmp_path: Path) -> None:
"""Test that path traversal with .. is blocked."""
(tmp_path / "allowed").mkdir()
(tmp_path / "allowed" / "file.txt").write_text("content", encoding="utf-8")
# Create file outside root
parent = tmp_path.parent
(parent / "secret.txt").write_text("secret", encoding="utf-8")
middleware = FilesystemFileSearchMiddleware(root_path=str(tmp_path / "allowed"))
# Try to escape with ..
assert isinstance(middleware.glob_search, StructuredTool)
assert middleware.glob_search.func is not None
result = middleware.glob_search.func(pattern="*.txt", path="/../")
assert result == "No files found"
assert "secret" not in result
Domain
Subdomains
Source
Frequently Asked Questions
What does test_path_traversal_with_double_dots() do?
test_path_traversal_with_double_dots() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_file_search.py.
Where is test_path_traversal_with_double_dots() defined?
test_path_traversal_with_double_dots() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_file_search.py at line 217.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free