Documentation
¶
Overview ¶
Package securefilepath offers operations on filesystem paths and files in a way which offers additional security properties beyond simple string manipulation.
The additional security comes primarily from the SecureFilePath.Child method which allows the construction of a new path which is a direct child of an existing path, even using untrusted input. Any input which would create a path which is not a child results in an error instead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SecureFilePath ¶
type SecureFilePath interface {
// Create a child path, given a segment (e.g. "child.txt"). Non-segments
// like "../child.txt" or "/path/child.txt" will result in an error.
Child(string) (SecureFilePath, error)
// Return the full path as a string.
Path() string
// Parent returns the path to the parent of this path or this path
// itself if it is the root.
Parent() SecureFilePath
// Base returns the basename (the last segment) of the path.
Base() string
// Return the children of the directory.
Children() ([]SecureFilePath, error)
// Exists determines whether a file exists at this path at the time of
// the call.
Exists() (bool, error)
}
SecureFilePath presents functionality related to paths and the files they refer to.
func New ¶
func New(path string) (SecureFilePath, error)
New creates a new SecureFilePath from an absolute, sanitized path.
Click to show internal directories.
Click to hide internal directories.