Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SanitizeFilename ¶
SanitizeFilename makes a safe filename from an arbitrary string. It replaces any characters that are not ASCII letters, digits, dot, underscore or dash with an underscore. It also collapses repeated underscores and trims the result to a reasonable length. This is intended for use when embedding user-provided identifiers into file names.
func ValidateExportPath ¶
ValidateExportPath validates a file path for export operations. It ensures the path is within either the temp directory or current working directory.
func ValidateOutputPath ¶
ValidateOutputPath validates a file path for CLI output operations. It ensures the path is within the current working directory or temp directory, and doesn't attempt path traversal. This is intended for use with CLI tools that accept output file paths as arguments.
func ValidatePathWithinAllowedDirs ¶
ValidatePathWithinAllowedDirs checks if a file path is within any of the allowed directories. Returns nil if the path is valid, or an error describing why it was rejected.
func ValidatePathWithinDirectory ¶
ValidatePathWithinDirectory checks if a file path is within a safe directory. It prevents path traversal attacks by ensuring the resolved path doesn't escape the specified safe directory. This includes protection against symlink-based attacks.
Types ¶
This section is empty.