Fix linter issues (#1472)

Co-authored-by: Azeem Shaikh <azeems@google.com>
This commit is contained in:
Azeem Shaikh 2022-01-12 12:34:16 -08:00 committed by GitHub
parent f2c57d2590
commit 696553be2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View File

@ -399,7 +399,7 @@ func validateDockerfileIsPinned(pathfn string, content []byte,
// (1): name = <>@sha245:hash
// (2): name = XXX where XXX was pinned
pinned := pinnedAsNames[name]
if pinned || regex.Match([]byte(name)) {
if pinned || regex.MatchString(name) {
// Record the asName.
pinnedAsNames[asName] = true
continue
@ -420,7 +420,7 @@ func validateDockerfileIsPinned(pathfn string, content []byte,
case len(valueList) == 1:
name := valueList[0]
pinned := pinnedAsNames[name]
if !pinned && !regex.Match([]byte(name)) {
if !pinned && !regex.MatchString(name) {
ret = false
dl.Warn3(&checker.LogMessage{
Path: pathfn,
@ -630,7 +630,7 @@ func validateGitHubActionWorkflow(pathfn string, content []byte,
// Ensure a hash at least as large as SHA1 is used (40 hex characters).
// Example: action-name@hash
match := hashRegex.Match([]byte(execAction.Uses.Value))
match := hashRegex.MatchString(execAction.Uses.Value)
if !match {
dl.Warn3(&checker.LogMessage{
Path: pathfn, Type: checker.FileTypeSource,

View File

@ -51,7 +51,7 @@ func BranchProtection(c clients.RepoClient) (checker.BranchProtectionsData, erro
}
// TODO: if this is a sha, get the associated branch. for now, ignore.
if commit.Match([]byte(release.TargetCommitish)) {
if commit.MatchString(release.TargetCommitish) {
continue
}

View File

@ -443,7 +443,7 @@ func isGoUnpinnedDownload(cmd []string) bool {
// Consider strings that are not URLs as local folders
// which are pinned.
regex := regexp.MustCompile(`\w+\.\w+/\w+`)
if !regex.Match([]byte(pkg)) {
if !regex.MatchString(pkg) {
return false
}
// Verify pkg = name@hash
@ -453,7 +453,7 @@ func isGoUnpinnedDownload(cmd []string) bool {
continue
}
hash := parts[1]
if hashRegex.Match([]byte(hash)) {
if hashRegex.MatchString(hash) {
return false
}
}

View File

@ -26,7 +26,7 @@ func (s CSVStrings) MarshalCSV() ([]byte, error) {
// UnmarshalCSV implements []byte -> []string de-serializtion.
func (s *CSVStrings) UnmarshalCSV(input []byte) error {
if len(input) == 0 || string(input) == "" {
if len(input) == 0 {
*s = nil
return nil
}