safefile

package
v1.0.91 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package safefile provides portable path validation and root-scoped file access.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(root *os.Root, name string) error

Check rejects existing symlinks and special files; os.Root separately enforces containment at open/rename time, including if a symlink changes after this check.

func CheckRoot

func CheckRoot(path string) error

CheckRoot rejects symlinks in the configured root or its existing ancestors. The configured root is a trusted caller-selected boundary; OpenRoot pins it for subsequent operations. Missing components are allowed for output root creation.

func Read

func Read(root *os.Root, name string, maxBytes int64) ([]byte, error)

Read opens through a pinned root and bounds both the declared and actual size.

func Relative

func Relative(name string) (string, error)

Relative validates artifact paths consistently on Unix and Windows. It rejects traversal rather than normalizing it, so aliases cannot hide filename collisions.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL