Documentation
¶
Overview ¶
Package workdir provides generic, confinement-policy-free filesystem helpers for resolving user-supplied paths safely: canonicalizing directories, walking up to the nearest existing ancestor before resolving symlinks (so a symlinked parent can't be combined with a nonexistent leaf path to land somewhere unexpected), checking subpath containment, and rejecting symlinked leaf files. This package has no opinion on which root a caller should confine paths to — callers that need to enforce a specific confinement policy (an approved-root env var, for example) build it on top of these primitives.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalizeDir ¶
CanonicalizeDir resolves path to an absolute, symlink-resolved directory path. It returns an error if path does not exist or is not a directory.
func IsSubpath ¶
IsSubpath reports whether target is root itself or lies inside it. A name that merely starts with ".." (e.g. "..secrets") is not treated as parent traversal; only an actual ".." path segment counts as escaping root.
func RequireNonSymlinkLeaf ¶
RequireNonSymlinkLeaf rejects a leafPath that is itself a symlink, or whose resolved location escapes root. A leafPath that does not exist yet is allowed, since callers typically create it as a regular file on first use.
func ResolveViaExistingAncestor ¶
ResolveViaExistingAncestor finds the nearest existing ancestor of path, resolves symlinks there with EvalSymlinks, then rejoins any missing trailing path components. This blocks a symlinked/junction parent from being combined with a nonexistent leaf path to resolve somewhere other than where the symlink target actually points.
Types ¶
This section is empty.