Home / Function/ test_path_traversal_with_absolute_path() — langchain Function Reference

test_path_traversal_with_absolute_path() — langchain Function Reference

Architecture documentation for the test_path_traversal_with_absolute_path() function in test_file_search.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  5b45f149_2d67_f3db_7590_f7ee9f0d2a83["test_path_traversal_with_absolute_path()"]
  e5a178bd_bdb1_3bca_cf3b_735c1d713414["TestPathTraversalSecurity"]
  5b45f149_2d67_f3db_7590_f7ee9f0d2a83 -->|defined in| e5a178bd_bdb1_3bca_cf3b_735c1d713414
  style 5b45f149_2d67_f3db_7590_f7ee9f0d2a83 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_file_search.py lines 236–250

    def test_path_traversal_with_absolute_path(self, tmp_path: Path) -> None:
        """Test that absolute paths outside root are blocked."""
        (tmp_path / "allowed").mkdir()

        # Create file outside root
        (tmp_path / "secret.txt").write_text("secret", encoding="utf-8")

        middleware = FilesystemFileSearchMiddleware(root_path=str(tmp_path / "allowed"))

        # Try to access with absolute path
        assert isinstance(middleware.glob_search, StructuredTool)
        assert middleware.glob_search.func is not None
        result = middleware.glob_search.func(pattern="*.txt", path=str(tmp_path))

        assert result == "No files found"

Domain

Subdomains

Frequently Asked Questions

What does test_path_traversal_with_absolute_path() do?
test_path_traversal_with_absolute_path() 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_absolute_path() defined?
test_path_traversal_with_absolute_path() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_file_search.py at line 236.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free