Documentation
¶
Index ¶
Constants ¶
const TextSampleSize = 8192
TextSampleSize is the number of bytes sampled from a file to determine whether it is text or binary.
Variables ¶
This section is empty.
Functions ¶
func CopyDir ¶
CopyDir recursively copies a directory from src to dst. Symlinks are skipped for security. A TOCTOU mitigation re-checks each file with Lstat before copying to detect symlinks created between walk and copy.
func IsTextContent ¶
IsTextContent checks if content appears to be text rather than binary. It inspects the first 8KB for null bytes, invalid UTF-8, and non-printable characters.
func SanitizeFileMode ¶
SanitizeFileMode strips setuid, setgid, and sticky bits from a file mode to prevent privilege escalation from untrusted template sources.
func ValidatePathContainment ¶
ValidatePathContainment checks that fullPath is contained within basePath. Both paths are resolved through filepath.EvalSymlinks (with fallback for non-existent targets) and made absolute before comparison. This prevents path traversal attacks including those using symlinks.
Types ¶
This section is empty.