pathguard

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pathguard creates private directory trees without traversing aliases. It validates every existing ancestor before the first filesystem mutation and anchors each subsequent single-component create to a pinned parent directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InspectDirectory

func InspectDirectory(path string) (os.FileInfo, string, error)

InspectDirectory rejects a symlink, junction, or other reparse point at path and returns the directory's identity and resolved path.

func ValidateDirectoryPath

func ValidateDirectoryPath(path string) (os.FileInfo, string, error)

ValidateDirectoryPath walks from the path's volume root through every component, rejecting aliases at any existing ancestor.

Types

type CreateHook

type CreateHook func() error

CreateHook runs after the pinned parent has been checked and immediately before it is checked again for a single-component create. It exists so platform race tests can deterministically exercise this boundary.

type Directory

type Directory interface {
	Path() string
	Validate() error
}

Directory is a validated, handle-anchored directory capability.

type OpenPin

type OpenPin func(canonicalPath, operationPath string, identity os.FileInfo) (Pin, error)

OpenPin opens and validates a directory handle. canonicalPath is the stable path used for full-chain validation; operationPath may be handle-relative.

type Pin

type Pin interface {
	Directory
	Close() error
}

Pin is an owned Directory capability.

func EnsureChild

func EnsureChild(parent Directory, canonicalParent, name string, create bool, perm os.FileMode, open OpenPin, hook CreateHook) (string, os.FileInfo, Pin, bool, error)

EnsureChild validates or creates exactly one child through parent. It never recursively creates paths and rejects final-component aliases and reparse points before returning an owned pin.

func EnsureDirectory

func EnsureDirectory(requested string, perm os.FileMode, open OpenPin, hook CreateHook) (string, os.FileInfo, Pin, error)

EnsureDirectory validates an absolute directory chain and creates missing components one at a time through successively pinned parents.

func NewPin

func NewPin(canonicalPath, operationPath string, identity os.FileInfo, labels PinLabels) (Pin, error)

type PinLabels

type PinLabels struct {
	Store, Access string
	Invalid       error
}

PinLabels preserves each store's error vocabulary and invalid-input identity.

Jump to

Keyboard shortcuts

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