filepathutil

package
v3.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 3 Imported by: 0

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

func IsPathWithinAnyDirectory(path string, directories ...string) bool

IsPathWithinAnyDirectory returns true when path resolves inside any directory.

func IsPathWithinDirectory

func IsPathWithinDirectory(path string, directory string) bool

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.

Jump to

Keyboard shortcuts

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