Documentation
¶
Index ¶
- func CheckFileContainsCommands(content []byte, comment string) bool
- func CheckFilesContent(shellPathFnPattern string, caseSensitive bool, c *checker.CheckRequest, ...) error
- func CheckFilesContentV6(shellPathFnPattern string, caseSensitive bool, repoClient clients.RepoClient, ...) error
- func CheckIfFileExists(c *checker.CheckRequest, onFile FileCb, data FileCbData) error
- func CheckIfFileExistsV6(repoClient clients.RepoClient, onFile FileCbV6, data FileCbData) error
- func FileGetCbDataAsBoolPointer(data FileCbData) *bool
- func FormatActionlintError(errs []*actionlint.Error) error
- func GetJobName(job *actionlint.Job) string
- func GetLineNumber(pos *actionlint.Pos) uint
- func GetOSesForJob(job *actionlint.Job) ([]string, error)
- func GetShellForStep(step *actionlint.Step, job *actionlint.Job) (string, error)
- func GetStepName(step *actionlint.Step) string
- func GetUses(step *actionlint.Step) *actionlint.String
- func IsGitHubOwnedAction(actionName string) bool
- func IsGithubWorkflowFileCb(pathfn string) (bool, error)
- func IsStepExecKind(step *actionlint.Step, kind actionlint.ExecKind) bool
- func IsStepWindows(step *actionlint.Step) (bool, error)
- func IsTemplateFile(pathfn string) bool
- func IsWorkflowFile(pathfn string) bool
- func JobAlwaysRunsOnWindows(job *actionlint.Job) (bool, error)
- type FileCb
- type FileCbData
- type FileCbV6
- type FileContentCb
- type FileContentCbV6
- type JobMatcher
- type JobMatcherStep
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckFileContainsCommands ¶
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(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 CheckIfFileExistsV6 ¶
func CheckIfFileExistsV6(repoClient clients.RepoClient, onFile FileCbV6, data FileCbData) error
CheckIfFileExistsV6 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 GetLineNumber ¶
func GetLineNumber(pos *actionlint.Pos) uint
GetLineNumber returns the line number for this position.
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 GetUses ¶
func GetUses(step *actionlint.Step) *actionlint.String
GetUses returns the 'uses' statement in this step or nil if this step does not have one.
func IsGitHubOwnedAction ¶
IsGitHubOwnedAction checks if this is a github specific action.
func IsGithubWorkflowFileCb ¶ added in v4.1.0
IsGithubWorkflowFileCb determines if a file is a workflow as a callback to use for repo client's ListFiles() API.
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 IsTemplateFile ¶
IsTemplateFile returns true if the file name contains a string commonly used in template files.
func IsWorkflowFile ¶
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 FileCbV6 ¶
type FileCbV6 func(path string, data FileCbData) (bool, error)
FileCbV6 is the callback. The bool returned indicates whether the FileCbData should continue iterating over files or not.
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.
type JobMatcher ¶
type JobMatcher struct {
// The text to be logged when a job match is found.
LogText string
// Each step in this field has a matching step in the job.
Steps []*JobMatcherStep
}
JobMatcher is rule for matching a job.
func (*JobMatcher) Matches ¶
func (m *JobMatcher) Matches(job *actionlint.Job) bool
Matches returns true if the job matches the job matcher.
type JobMatcherStep ¶
type JobMatcherStep struct {
// If set, the step's 'Uses' must match this field. Checks that the action name is the same.
Uses string
// If set, the step's 'With' have the keys and values that are in this field.
With map[string]string
// If set, the step's 'Run' must match this field. Does a regex match using this field.
Run string
}
JobMatcherStep is a single step that needs to be matched.