filesystem

package
v0.88.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermDir      = 0o755 // Directory permission
	PermOwner    = 0o600 // Owner permission
	PermGroup    = 0o640 // Group permission
	PermPublic   = 0o644 // Public permission
	PermReadOnly = 0o444 // Read-only permission
)

Variables

View Source
var (
	ErrInvalidFilePath = errors.New("invalid file path")
	ErrPathTraversal   = errors.New("path traversal detected")
)

Functions

func InBasePath added in v0.76.0

func InBasePath(basePath, path string) bool

InBasePath checks if the given path is within the base path, preventing path traversal attacks.

func IsDir added in v0.74.0

func IsDir(path string) bool

IsDir checks if the given path is a directory.

func IsFile added in v0.74.0

func IsFile(path string) bool

IsFile checks if the given path is a regular file without any mode bits set (like symlink, socket, named pipe, etc.).

func IsSocket added in v0.74.0

func IsSocket(path string) bool

IsSocket checks if the given path is a socket file.

func IsSymlink(path string) bool

IsSymlink checks if the given path is a symbolic link.

func VerifyAndSanitizePath

func VerifyAndSanitizePath(path, trustedRoot string) (string, error)

VerifyAndSanitizePath checks if a file path is valid and sanitizes it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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