Expand description
Path sanitization and directory permission utilities
Defense-in-depth for filenames derived from API responses or untrusted input.
Functionsยง
- create_
dir_ restricted - Create directories with mode 0o700 (owner-only) on Unix.
- safe_
join - Sanitize
untrusted_namethen join it tobase_dirand validate the result. - sanitize_
filename - Strip path traversal components and return only the final filename.
- validate_
path_ within - Canonicalize both paths and confirm
targetis a descendant ofbase_dir.