Spaces:
Paused
Paused
Download backend/tests/test_paths.py from 2Btainment/repospace: direct link, hf CLI and curl.
- Browser
- Download file 540 Bytes
-
https://huggingface.co/spaces/2Btainment/repospace/resolve/main/backend/tests/test_paths.py
- Command line
-
hf download hf://spaces/2Btainment/repospace/backend/tests/test_paths.py
-
curl -L -o test_paths.py https://huggingface.co/spaces/2Btainment/repospace/resolve/main/backend/tests/test_paths.py
540 Bytes
| from pathlib import Path | |
| import pytest | |
| from backend.app.security.paths import is_within_directory, safe_join | |
| def test_within(tmp_path: Path): | |
| base = tmp_path / "base" | |
| base.mkdir() | |
| child = base / "a" / "b" | |
| child.mkdir(parents=True) | |
| assert is_within_directory(base, child) | |
| assert not is_within_directory(base, tmp_path / "other") | |
| def test_safe_join_blocks_traversal(tmp_path: Path): | |
| base = tmp_path / "base" | |
| base.mkdir() | |
| with pytest.raises(ValueError): | |
| safe_join(base, "..", "etc", "passwd") | |