(file_path: str)
| 180 | return app_name, rel_path |
| 181 | |
| 182 | def _parse_file_path(file_path: str) -> str: |
| 183 | file_path = _normalize_relative_path(file_path) |
| 184 | if not file_path: |
| 185 | raise ValueError("file_path is missing.") |
| 186 | if file_path.startswith("/"): |
| 187 | raise ValueError(f"Absolute file_path rejected: {file_path!r}") |
| 188 | if _has_parent_reference(file_path): |
| 189 | raise ValueError(f"Path traversal rejected: {file_path!r}") |
| 190 | ext = os.path.splitext(file_path)[1].lower() |
| 191 | if ext not in _ALLOWED_EXTENSIONS: |
| 192 | raise ValueError( |
| 193 | f"File type not allowed: {file_path!r}" |
| 194 | f" (allowed: {', '.join(sorted(_ALLOWED_EXTENSIONS))})" |
| 195 | ) |
| 196 | return file_path |
| 197 | |
| 198 | def _resolve_under_dir(root_dir: Path, rel_path: str) -> Path: |
| 199 | file_path = root_dir / rel_path |
no test coverage detected