test_grep_path_traversal_protection() — langchain Function Reference
Architecture documentation for the test_grep_path_traversal_protection() function in test_file_search.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 24a999e5_7653_acd2_feb5_f68950cf3a3c["test_grep_path_traversal_protection()"] e5a178bd_bdb1_3bca_cf3b_735c1d713414["TestPathTraversalSecurity"] 24a999e5_7653_acd2_feb5_f68950cf3a3c -->|defined in| e5a178bd_bdb1_3bca_cf3b_735c1d713414 style 24a999e5_7653_acd2_feb5_f68950cf3a3c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_file_search.py lines 282–297
def test_grep_path_traversal_protection(self, tmp_path: Path) -> None:
"""Test that grep also protects against path traversal."""
(tmp_path / "allowed").mkdir()
(tmp_path / "secret.txt").write_text("secret content", encoding="utf-8")
middleware = FilesystemFileSearchMiddleware(
root_path=str(tmp_path / "allowed"), use_ripgrep=False
)
# Try to search outside root
assert isinstance(middleware.grep_search, StructuredTool)
assert middleware.grep_search.func is not None
result = middleware.grep_search.func(pattern="secret", path="/../")
assert result == "No matches found"
assert "secret" not in result
Domain
Subdomains
Source
Frequently Asked Questions
What does test_grep_path_traversal_protection() do?
test_grep_path_traversal_protection() 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_grep_path_traversal_protection() defined?
test_grep_path_traversal_protection() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_file_search.py at line 282.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free