Documentation
¶
Overview ¶
Package osroot provides traversal-resistant file I/O helpers built on os.Root (Go 1.24+). These helpers ensure that file operations cannot escape a scoped directory, preventing symlink attacks and TOCTOU races at the kernel level.
os.Root supports: Open, OpenFile, Create, Stat, Lstat, Mkdir, Remove, OpenRoot. os.Root does NOT support: MkdirAll, WriteFile, ReadFile, Rename, RemoveAll. For unsupported operations, callers should use standard os functions with lexical validation.
Errors from these functions are returned unwrapped so that callers can use os.IsNotExist() and errors.Is() directly without losing the original sentinel.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadFile ¶
ReadFile reads the named file relative to root using os.Root for traversal-resistant access. The kernel enforces that the read cannot escape the root directory, preventing symlink and TOCTOU attacks.
func Remove ¶
Remove removes the named file relative to root using os.Root for traversal-resistant access. Returns nil if the file doesn't exist.
Types ¶
This section is empty.