/
/
/
1"""Security utilities for input validation."""
2
3from __future__ import annotations
4
5import os
6
7
8def is_safe_path(path: str) -> bool:
9 """Check if path is free from path traversal components."""
10 norm_path = os.path.normpath(path)
11 return not (norm_path.startswith("..") or "/../" in norm_path or "\\..\\" in norm_path)
12
13
14def is_safe_name(name: str) -> bool:
15 """Check if name is safe for use (no path separators or traversal components)."""
16 return not ("/" in name or "\\" in name or ".." in name)
17