mirror of
https://github.com/ossf/scorecard.git
synced 2024-11-04 03:52:31 +03:00
🌱 Add counting of shell parsing errors (#1026)
* Add counting of shell parsing errors * Use existing CheckErrors metric instead Co-authored-by: Azeem Shaikh <azeemshaikh38@gmail.com>
This commit is contained in:
parent
44dd10d465
commit
90332a9cb9
@ -24,7 +24,6 @@ var (
|
||||
errInternalInvalidYamlFile = errors.New("invalid yaml file")
|
||||
errInternalFilenameMatch = errors.New("filename match error")
|
||||
errInternalEmptyFile = errors.New("empty file")
|
||||
errInternalInvalidShellCode = errors.New("invalid shell code")
|
||||
errInternalCommitishNil = errors.New("commitish is nil")
|
||||
errInternalBranchNotFound = errors.New("branch not found")
|
||||
errInvalidGitHubWorkflow = errors.New("invalid GitHub workflow")
|
||||
|
@ -682,8 +682,7 @@ func validateShellFileAndRecord(pathfn string, content []byte, files map[string]
|
||||
// Note: this is caught by internal caller and only printed
|
||||
// to avoid failing on shell scripts that our parser does not understand.
|
||||
// Example: https://github.com/openssl/openssl/blob/master/util/shlib_wrap.sh.in
|
||||
//nolint
|
||||
return false, sce.CreateInternal(errInternalInvalidShellCode, err.Error())
|
||||
return false, sce.WithMessage(sce.ErrorShellParsing, err.Error())
|
||||
}
|
||||
|
||||
printer := syntax.NewPrinter()
|
||||
@ -826,7 +825,7 @@ func isMatchingShellScriptFile(pathfn string, content []byte, shellsToMatch []st
|
||||
func validateShellFile(pathfn string, content []byte, dl checker.DetailLogger) (bool, error) {
|
||||
files := make(map[string]bool)
|
||||
r, err := validateShellFileAndRecord(pathfn, content, files, dl)
|
||||
if err != nil && errors.Is(err, errInternalInvalidShellCode) {
|
||||
if err != nil && errors.Is(err, sce.ErrorShellParsing) {
|
||||
// Discard and print this particular error for now.
|
||||
dl.Debug(err.Error())
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ var (
|
||||
ErrorUnsupportedHost = errors.New("unsupported host")
|
||||
// ErrorInvalidURL indicates the repo's full URL was not passed.
|
||||
ErrorInvalidURL = errors.New("invalid repo flag")
|
||||
// ErrorShellParsing indicates there was an error when parsing shell code.
|
||||
ErrorShellParsing = errors.New("error parsing shell code")
|
||||
)
|
||||
|
||||
// WithMessage wraps any of the errors listed above.
|
||||
@ -47,6 +49,8 @@ func GetName(err error) string {
|
||||
return "ErrScorecardInternal"
|
||||
case errors.Is(err, ErrRepoUnreachable):
|
||||
return "ErrRepoUnreachable"
|
||||
case errors.Is(err, ErrorShellParsing):
|
||||
return "ErrorShellParsing"
|
||||
default:
|
||||
return "ErrUnknown"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user