Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrEscapeAttempt = errors.New("path escape attempt: operation would access path outside jail")
)
Functions ¶
func EnsureInJail ¶
EnsureInJail returns a path that resides inside jail when possible.
If the path is already inside jail, the cleaned absolute form is returned. Otherwise a path under jail is returned by appending the base name of the path.
func EnsureInJailFor ¶
EnsureInJailFor is a test-friendly helper that mirrors EnsureInJail but accepts paths written with forward slashes.
It converts both jail and p using filepath.FromSlash before applying the EnsureInJail logic. Use this from tests when expected values are easier to express using POSIX-style literals.
func IsInJail ¶
IsInJail reports whether the provided path resides within the jail boundary.
If jail is empty, the function returns true (no boundary). Relative paths always are in the jail.
func RemoveJailPrefix ¶
RemoveJailPrefix removes the jail prefix from a path and returns an absolute path.