Documentation
¶
Overview ¶
Package safeoutput writes generated and scaffolded files through an os.Root-confined, atomic rename so that a symlink in the destination path cannot redirect a write to an unrelated victim file outside its intended directory.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteFileAtomic ¶
WriteFileAtomic writes data to path, creating missing parent directories with mode 0o700. It refuses a symlinked parent component that resolves outside the nearest real ancestor directory of path, and replaces rather than follows a symlink at the final component. The file is written to a temporary file in the destination directory and renamed into place.
func WriteFileWithin ¶
WriteFileWithin writes data to relPath beneath root, creating missing parent directories with mode 0o750. relPath must be relative and must not escape root. Parent components are resolved with root confinement: a symlinked parent that resolves outside root is refused, while a symlink that stays within root is followed. A symlink at the final component is replaced rather than followed. The file is written to a temporary file in the destination directory and renamed into place.
root must already exist and is treated as the containment anchor; callers that must also reject a symlinked root should check that beforehand.
Types ¶
This section is empty.