fileparser

package
v3.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFileContainsCommands

func CheckFileContainsCommands(content []byte, comment string) bool

CheckFileContainsCommands checks if the file content contains commands or not. `comment` is the string or character that indicates a comment: for example for Dockerfiles, it would be `#`.

func CheckFilesContent

func CheckFilesContent(shellPathFnPattern string,
	caseSensitive bool,
	c *checker.CheckRequest,
	onFileContent FileContentCb,
	data FileCbData,
) error

CheckFilesContent downloads the tar of the repository and calls the onFileContent() function shellPathFnPattern is used for https://golang.org/pkg/path/#Match Warning: the pattern is used to match (1) the entire path AND (2) the filename alone. This means:

  • To scope the search to a directory, use "./dirname/*". Example, for the root directory, use "./*".
  • A pattern such as "*mypatern*" will match files containing mypattern in *any* directory.

func CheckFilesContentV6

func CheckFilesContentV6(shellPathFnPattern string,
	caseSensitive bool,
	repoClient clients.RepoClient,
	onFileContent FileContentCbV6,
	data FileCbData,
) error

CheckFilesContentV6 is the same as CheckFilesContent but for use with separated check/policy code.

func CheckIfFileExists

func CheckIfFileExists(checkName string, c *checker.CheckRequest, onFile FileCb, data FileCbData) error

CheckIfFileExists downloads the tar of the repository and calls the onFile() to check for the occurrence.

func FileGetCbDataAsBoolPointer

func FileGetCbDataAsBoolPointer(data FileCbData) *bool

FileGetCbDataAsBoolPointer returns callback data as bool.

func FormatActionlintError

func FormatActionlintError(errs []*actionlint.Error) error

FormatActionlintError combines the errors into a single one.

func GetJobName

func GetJobName(job *actionlint.Job) string

GetJobName returns Name.Value if non-nil, else returns "".

func GetOSesForJob

func GetOSesForJob(job *actionlint.Job) ([]string, error)

GetOSesForJob returns the OSes this job runs on.

func GetShellForStep

func GetShellForStep(step *actionlint.Step, job *actionlint.Job) (string, error)

GetShellForStep returns the shell that is used to run the given step.

func GetStepName

func GetStepName(step *actionlint.Step) string

GetStepName returns Name.Value if non-nil, else returns "".

func IsGitHubOwnedAction

func IsGitHubOwnedAction(actionName string) bool

IsGitHubOwnedAction checks if this is a github specific action.

func IsStepExecKind

func IsStepExecKind(step *actionlint.Step, kind actionlint.ExecKind) bool

IsStepExecKind compares input `step` ExecKind with `kind` and returns true on a match.

func IsStepWindows

func IsStepWindows(step *actionlint.Step) (bool, error)

IsStepWindows returns true if the step will be run on Windows.

func IsWorkflowFile

func IsWorkflowFile(pathfn string) bool

IsWorkflowFile returns true if this is a GitHub workflow file.

func JobAlwaysRunsOnWindows

func JobAlwaysRunsOnWindows(job *actionlint.Job) (bool, error)

JobAlwaysRunsOnWindows returns true if the only OS that this job runs on is Windows.

Types

type FileCb

type FileCb func(path string,
	dl checker.DetailLogger, data FileCbData) (bool, error)

FileCb represents a callback fn.

type FileCbData

type FileCbData interface{}

FileCbData is any data the caller can act upon to keep state.

type FileContentCb

type FileContentCb func(path string, content []byte,
	dl checker.DetailLogger, data FileCbData) (bool, error)

FileContentCb is the callback. The bool returned indicates whether the CheckFilesContent2 should continue iterating over files or not.

type FileContentCbV6

type FileContentCbV6 func(path string, content []byte, data FileCbData) (bool, error)

FileContentCbV6 is the callback. The bool returned indicates whether the CheckFilesContent2 should continue iterating over files or not.

Jump to

Keyboard shortcuts

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