Documentation
¶
Index ¶
- Variables
- func SafeCreate(sp *SecurePath) (*os.File, error)
- func SafeJoin(basePath, userPath string) (string, error)
- func SafeMkdirAll(sp *SecurePath, perm os.FileMode) error
- func SafeOpen(sp *SecurePath) (*os.File, error)
- func SafeRemove(sp *SecurePath) error
- func SafeRemoveIfExists(sp *SecurePath) error
- func SafeRename(oldpath, newpath *SecurePath) error
- func SafeStat(sp *SecurePath) (os.FileInfo, error)
- func SafeStatExists(sp *SecurePath) bool
- func ValidateAndCleanFilename(filename string) (string, error)
- func ValidateExistingFilePath(path string) error
- func ValidateFilePath(path string) error
- func ValidateFilePathInBase(path, baseDir string) error
- func ValidateStorageKey(key string) error
- func ValidateURL(rawURL string) error
- type SecurePath
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrPathTraversal = errors.New("path contains directory traversal sequences") ErrAbsolutePath = errors.New("absolute paths are not allowed") ErrEmptyPath = errors.New("path cannot be empty") ErrInvalidPath = errors.New("invalid path") ErrOutsideBaseDir = errors.New("path is outside allowed base directory") )
View Source
var ( ErrInvalidURL = errors.New("invalid URL format") ErrInvalidScheme = errors.New("URL scheme must be http or https") ErrPrivateIP = errors.New("URL points to private/local IP address") ErrBlockedDomain = errors.New("domain is in blocklist") ErrEmptyURL = errors.New("URL cannot be empty") ErrIPResolutionFailed = errors.New("failed to resolve domain") )
Functions ¶
func SafeCreate ¶
func SafeCreate(sp *SecurePath) (*os.File, error)
func SafeMkdirAll ¶
func SafeMkdirAll(sp *SecurePath, perm os.FileMode) error
func SafeRemove ¶
func SafeRemove(sp *SecurePath) error
func SafeRemoveIfExists ¶
func SafeRemoveIfExists(sp *SecurePath) error
func SafeRename ¶
func SafeRename(oldpath, newpath *SecurePath) error
func SafeStatExists ¶
func SafeStatExists(sp *SecurePath) bool
func ValidateFilePath ¶
func ValidateFilePathInBase ¶
func ValidateStorageKey ¶
func ValidateURL ¶
Types ¶
type SecurePath ¶
type SecurePath struct {
// contains filtered or unexported fields
}
func NewSecurePath ¶
func NewSecurePath(userPath string) (*SecurePath, error)
func NewSecurePathFromExisting ¶
func NewSecurePathFromExisting(existingPath string) (*SecurePath, error)
func NewSecurePathInBase ¶
func NewSecurePathInBase(userPath, baseDir string) (*SecurePath, error)
func NewSecureStorageKey ¶
func NewSecureStorageKey(key string) (*SecurePath, error)
func (*SecurePath) Dir ¶
func (sp *SecurePath) Dir() *SecurePath
func (*SecurePath) Join ¶
func (sp *SecurePath) Join(elem string) (*SecurePath, error)
func (*SecurePath) String ¶
func (sp *SecurePath) String() string
Click to show internal directories.
Click to hide internal directories.