Documentation ¶
Index ¶
- Variables
- func CreateNewFileUnderCurrentDirectory(path string, flag int) (io.Writer, error)
- func CreateNewFileUnderDirectory(path, dir string, flag int) (io.Writer, error)
- func IsPresubmitTests() bool
- func MarshalToBytes(args interface{}) ([]byte, error)
- func MarshalToString(args interface{}) (string, error)
- func PathIsUnderCurrentDirectory(path string) error
- func PathIsUnderDirectory(path, absoluteDir string) error
- func SafeReadFile(path string) ([]byte, error)
- func UnmarshalList(arg string) ([]string, error)
- func VerifyAttestationPath(path string) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInternal indicates an internal error. ErrInternal = errors.New("internal error") // ErrInvalidPath indicates an invalid path. ErrInvalidPath = errors.New("invalid path") )
Functions ¶
func CreateNewFileUnderCurrentDirectory ¶
CreateNewFileUnderCurrentDirectory create a new file under the current directory and fails if the file already exists. The file is always created with the pemisisons `0o600`.
func CreateNewFileUnderDirectory ¶
CreateNewFileUnderDirectory create a new file under the current directory and fails if the file already exists. The file is always created with the pemisisons `0o600`. Ensures that the path does not exit out of the given directory.
func IsPresubmitTests ¶
func IsPresubmitTests() bool
IsPresubmitTests returns true if running in pre-submit tests.
func MarshalToBytes ¶
MarshalToBytes marshals to a byte array.
func MarshalToString ¶
MarshalToString marshals to a string.
func PathIsUnderCurrentDirectory ¶
PathIsUnderCurrentDirectory checks whether the `path` is under the current working directory. Examples: ./file, ./some/path, ../<cwd>.file would return `nil`. `../etc/password` would return an error.
func PathIsUnderDirectory ¶
PathIsUnderDirectory checks to see if path is under the absolute directory specified.
func SafeReadFile ¶
SafeReadFile checks for directory traversal before reading the given file.
func UnmarshalList ¶
UnmarshalList unmarshals a string into a list of strings.
func VerifyAttestationPath ¶
VerifyAttestationPath verifies that the path of an attestation is valid. It checks that the path is under the current working directory and that the extension of the file is `intoto.jsonl`.
Types ¶
This section is empty.