Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NewTrustedFilePathOptions ¶
NewTrustedFilePathOptions are options for creating a new trusted file path - used for disambiguating the args
type TrustedFilePath ¶
type TrustedFilePath struct {
State TrustedFilePathState
Error error
// contains filtered or unexported fields
}
TrustedFilePath contains the fields of a path to a file including "top", the top level directory containing the file, and "file", the relative path from top to the file. Top, if not provided will default to "."
func NewTrustedFilePath ¶
func NewTrustedFilePath(opts NewTrustedFilePathOptions) (*TrustedFilePath, error)
NewTrustedFilePath returns struct representation of the path to a file. If top is not provided (an empty string), it is defaulted to ".". The top is sanitized by evaluating all symlinks so that it can be properly sanitized by the builder when the time comes. This treats "top" as trusted (i.e. relative paths and symlinks can be evaluated safely).
func (*TrustedFilePath) File ¶
func (b *TrustedFilePath) File() string
File returns the file component of the trusted file path
func (*TrustedFilePath) FullPath ¶
func (b *TrustedFilePath) FullPath() string
FullPath returns the full path to the trusted file (i.e. top + "/" + file)
func (*TrustedFilePath) Sanitize ¶
func (trustedFilePath *TrustedFilePath) Sanitize()
Sanitize checks for disallowed entries in the provided file path and sets the State and Error values of the trustedFilePath
func (*TrustedFilePath) Top ¶
func (b *TrustedFilePath) Top() string
Top returns the top level directory containing the file. The path to the top level directory as provided by Top() is considered to be trusted.
type TrustedFilePathState ¶
type TrustedFilePathState int
TrustedFilePathState represents the state of a TrustedFilePath
const ( // Unchecked means the TrustedFilePath has not been checked for sanitization Unchecked TrustedFilePathState = iota // Errored means there was an error in creation Errored // OK means the path has been check and is sanitary OK // NotOK means the path has been check and is NOT sanitary NotOK )