utils

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateNewFileUnderCurrentDirectory added in v1.2.1

func CreateNewFileUnderCurrentDirectory(path string, flag int) (io.Writer, error)

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

func CreateNewFileUnderDirectory(path, dir string, flag int) (io.Writer, error)

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

func MarshalToBytes(args interface{}) ([]byte, error)

MarshalToBytes marshals to a byte array.

func MarshalToString added in v1.2.1

func MarshalToString(args interface{}) (string, error)

MarshalToString marshals to a string.

func PathIsUnderCurrentDirectory added in v1.2.1

func PathIsUnderCurrentDirectory(path string) error

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

func PathIsUnderDirectory(path, absoluteDir string) error

PathIsUnderDirectory checks to see if path is under the absolute directory specified.

func UnmarshalList added in v1.2.1

func UnmarshalList(arg string) ([]string, error)

UnmarshalList unmarshals a string into a list of strings.

func VerifyAttestationPath added in v1.2.1

func VerifyAttestationPath(path string) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL