Documentation
¶
Index ¶
- 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
- type ErrInternal
- type ErrInvalidPath
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNewFileUnderCurrentDirectory ¶ added in v1.2.1
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 ¶ added in v1.5.0
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 ¶ added in v1.2.1
MarshalToBytes marshals to a byte array.
func MarshalToString ¶ added in v1.2.1
MarshalToString marshals to a string.
func PathIsUnderCurrentDirectory ¶ added in v1.2.1
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 ¶ added in v1.5.0
PathIsUnderDirectory checks to see if path is under the absolute directory specified.
func SafeReadFile ¶ added in v1.7.0
SafeReadFile checks for directory traversal before reading the given file.
func UnmarshalList ¶ added in v1.2.1
UnmarshalList unmarshals a string into a list of strings.
func VerifyAttestationPath ¶ added in v1.2.1
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 ¶
type ErrInternal ¶ added in v1.2.1
type ErrInternal struct {
errors.WrappableError
}
ErrInternal indicates an internal error.
type ErrInvalidPath ¶ added in v1.2.1
type ErrInvalidPath struct {
errors.WrappableError
}
ErrInvalidPath indicates an invalid path.