pathutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0, BSD-3-Clause, MIT Imports: 5 Imported by: 0

Documentation

Overview

Package pathutil provides path security middleware Per AI.md PART 5: HTTP Request Path Middleware (NON-NEGOTIABLE)

Package pathutil provides path security and normalization functions Per AI.md PART 5: Path Security Functions (NON-NEGOTIABLE)

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPathTraversal = errors.New("path traversal attempt detected")
	ErrInvalidPath   = errors.New("invalid path characters")
	ErrPathTooLong   = errors.New("path exceeds maximum length")
)

Functions

func PathSecurityMiddleware

func PathSecurityMiddleware(next http.Handler) http.Handler

PathSecurityMiddleware normalizes paths and blocks traversal attempts Per AI.md: This middleware MUST be first in the chain - before auth, before routing.

func SafeFilePath

func SafeFilePath(input string) (string, error)

SafeFilePath validates a file path with extension Allows dots in filename portion for extensions (e.g., "file.txt")

func SafeFilePathWithBase

func SafeFilePathWithBase(baseDir, userPath string) (string, error)

SafeFilePathWithBase ensures path stays within base directory Per AI.md PART 5: When constructing file paths from user input, ALWAYS validate

func SafePath

func SafePath(input string) (string, error)

SafePath normalizes and validates - returns error if invalid Per AI.md PART 5: Use SafePath for ALL user-provided paths

Types

This section is empty.

Jump to

Keyboard shortcuts

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