Documentation
¶
Overview ¶
Package filepathutil provides utilities for safe filepath operations, particularly for sandboxing file access in template environments.
It includes functions to check if a path is contained within a directory, with proper canonicalization to handle symlinks and platform-specific path differences (such as case sensitivity on Windows).
TODO(dwisiswant0): This package should be moved to the github.com/projectdiscovery/utils/filepath, but let see how it goes first.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsPathWithinAnyDirectory ¶ added in v3.9.0
IsPathWithinAnyDirectory returns true when path resolves inside any directory.
func IsPathWithinDirectory ¶
IsPathWithinDirectory returns true when path resolves inside directory. Both values are canonicalized to handle symlinks and platform-specific case rules.
As a fail-closed safety net, an empty path or empty directory ALWAYS returns false. filepath.Abs("") returns the process working directory, which would otherwise turn an unset/missing argument into a silent CWD-relative sandbox — a footgun that callers must not rely on. Callers that need to anchor on the working directory must pass it explicitly via os.Getwd().
Types ¶
This section is empty.