Skip to main content

Module path_utils

Module path_utils 

Source
Expand description

Path sanitization utilities.

Provides secure path handling to prevent path traversal attacks. All user-provided paths must be validated through this module.

Functionsยง

safe_copy
Validate both paths and copy file in one atomic step.
safe_open_file_async
Async variant: validate path and open a file in one atomic step.
safe_read_dir
Async variant: validate path and read directory in one atomic step.
safe_read_to_string
Validate path and read file contents in one atomic step. Prevents path traversal by combining validation with the read operation.
safe_read_to_string_async
Async variant: validate path and read file contents in one atomic step.
sanitize_existing_path
Sanitize and validate a user-provided path.
sanitize_new_path
Sanitize a path that may not exist yet (for creation).
validate_read_path
Validate a path is safe for reading (must exist, be under allowed base).
validate_write_path
Validate a path is safe for writing.