Expand description
Utility functions and helpers.
This module provides security-focused utilities with input validation and safe path handling to prevent common vulnerabilities.
Functionsยง
- file_
exists - Checks if a file exists and is readable with path validation. Returns false for invalid or potentially dangerous paths.
- get_
base_ directory - Extracts the base directory from a file path.
- get_
file_ extension - Gets the file extension from a path.
- has_
path_ traversal - Checks if a path contains potential traversal sequences.
- is_
image_ file - Validates that a path points to an image file.
- is_
markdown_ file - Validates that a path points to a markdown file.
- is_
safe_ path - Validates that a path is safe to access (prevents path traversal and dangerous files).
- resolve_
path - Resolves relative paths against a base directory with security validation. Prevents path traversal attacks by validating the resolved path.
- sanitize_
filename - Sanitizes a filename by removing or replacing dangerous characters.
- validate_
app_ credentials - Validates WeChat app credentials format.
- validate_
file_ size - Validates file size limits to prevent DoS attacks.