securejoin

package module
v0.0.0-...-11879ef Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 5 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 securejoin joins an unsafe path to a root directory while keeping the result confined inside the root.

This is a yoke clean-room implementation written for S488.3d (remove the MPL-2.0 cyphar/filepath-securejoin dependency from the engine build). It was written from POSIX path semantics, the call sites and expectations of its permissive callers (podman pkg/util, pkg/lookup, containers/common etchosts, storage, buildah parse, cgroups — Apache-2.0, all using only SecureJoin and checking only err != nil), the one-line public signature from `go doc`, and black-box behavior observed by executing the replaced module (lexical escapes clamp inside, outside symlinks re-scope under the root, loops are an error). The replaced module's source — including vendor copies — was never opened. Only the caller-used API is provided: SecureJoin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SecureJoin

func SecureJoin(root, unsafePath string) (string, error)

SecureJoin joins unsafePath to root, keeping the result inside root:

  • Absolute unsafe paths are treated as relative to root, and ".." components that would ascend above root are clamped: they stay at root instead of escaping.
  • Symlinks met while walking are expanded (absolute targets restart the walk at root, relative targets splice in place, and nested links are expanded in turn by the same walk); targets that resolve outside root are re-scoped under root, so they never yield a usable outside path.
  • A symlink loop is an error.

The root itself is used as given (never symlink-resolved). A missing path component ends expansion for that branch and the remainder stays lexical, still confined under root.

Types

This section is empty.

Directories

Path Synopsis
Package pathrs is a clean-room replacement for github.com/cyphar/filepath-securejoin/pathrs-lite, implementing only the API the shipped Podman engine graph calls: podman libpod and play, containers/storage, opencontainers/selinux and runc internal/pathrs.
Package pathrs is a clean-room replacement for github.com/cyphar/filepath-securejoin/pathrs-lite, implementing only the API the shipped Podman engine graph calls: podman libpod and play, containers/storage, opencontainers/selinux and runc internal/pathrs.
procfs
Package procfs is a clean-room replacement for the procfs API of github.com/cyphar/filepath-securejoin/pathrs-lite, implementing only what the shipped Podman engine graph calls (opencontainers/selinux, runc internal/pathrs).
Package procfs is a clean-room replacement for the procfs API of github.com/cyphar/filepath-securejoin/pathrs-lite, implementing only what the shipped Podman engine graph calls (opencontainers/selinux, runc internal/pathrs).

Jump to

Keyboard shortcuts

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