safepath

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

@index safepath는 여러 핸들러가 공유하는 저수준 경로 안전 프리미티브를 단일화한다. 정책(prefix/Rel/walk 기반 containment)과 에러 문자열은 호출부에 남기고, 여기서는 공통 메커니즘(심링크 거부 walk, canonical 정규화, Rel 기반 containment)만 제공한다.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Canonical

func Canonical(path string, allowMissingLeaf bool) (string, error)

Canonical resolves path to an absolute, symlink-free, cleaned filesystem path. @intent normalize user-supplied paths before containment comparison to prevent symlink-based escapes. @param allowMissingLeaf when true, a non-existent leaf is tolerated by resolving the parent and appending the unresolved base; when false, a missing path is an error (strict existence).

func EnsureNoSymlinkInPath

func EnsureNoSymlinkInPath(root, relPath string, allowMissingLeaf bool) (string, error)

EnsureNoSymlinkInPath walks each path segment from root to relPath rejecting symlinks. @intent prevent symlink traversal from escaping a trusted root before any filesystem mutation. @param allowMissingLeaf when true, returns the joined path even when the leaf does not yet exist.

func IsWithinRoot

func IsWithinRoot(root, target string) (bool, error)

IsWithinRoot reports whether target is the same as root or a descendant of it. @intent detect path traversal by checking the relative path does not escape upward. @requires root and target should already be canonicalized (see Canonical) for symlink-safe comparison.

func ValidateNamespacePath

func ValidateNamespacePath(namespace, filePath string) error

ValidateNamespacePath rejects namespace and file inputs that could escape a namespace root. @intent keep lexical namespace traversal validation beside symlink and canonical containment safeguards. @domainRule namespace must be one safe segment; filePath must be relative and free of parent references.

Types

This section is empty.

Jump to

Keyboard shortcuts

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