Merge pull request #6669 from henry118/gosec

Enable gosec linter for golangci-lint
This commit is contained in:
Phil Estes 2022-03-14 21:23:27 -07:00 committed by GitHub
commit ed4cc4b482
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 0 deletions

View File

@ -11,12 +11,28 @@ linters:
- vet - vet
- unused - unused
- misspell - misspell
- gosec
disable: disable:
- errcheck - errcheck
issues: issues:
include: include:
- EXC0002 - EXC0002
max-issues-per-linter: 0
max-same-issues: 0
linters-settings:
gosec:
# The following issues surfaced when `gosec` linter
# was enabled. They are temporarily excluded to unblock
# the existing workflow, but still to be addressed by
# by future works.
excludes:
- G204
- G305
- G306
- G402
- G404
run: run:
timeout: 8m timeout: 8m

View File

@ -162,6 +162,7 @@ func WriteExtensions(bkt *bolt.Bucket, extensions map[string]types.Any) error {
} }
for name, ext := range extensions { for name, ext := range extensions {
ext := ext
p, err := proto.Marshal(&ext) p, err := proto.Marshal(&ext)
if err != nil { if err != nil {
return err return err

View File

@ -152,6 +152,7 @@ func TestContainersList(t *testing.T) {
} }
for _, result := range results { for _, result := range results {
result := result
checkContainersEqual(t, &result, testset[result.ID], "list results did not match") checkContainersEqual(t, &result, testset[result.ID], "list results did not match")
} }
}) })

View File

@ -129,6 +129,7 @@ func TestImagesList(t *testing.T) {
} }
for _, result := range results { for _, result := range results {
result := result
checkImagesEqual(t, &result, testset[result.Name], "list results did not match") checkImagesEqual(t, &result, testset[result.Name], "list results did not match")
} }
}) })

View File

@ -596,6 +596,7 @@ func TestDevShmSize(t *testing.T) {
expected := "1024k" expected := "1024k"
for _, s := range ss { for _, s := range ss {
s := s
if err := WithDevShmSize(1024)(nil, nil, nil, &s); err != nil { if err := WithDevShmSize(1024)(nil, nil, nil, &s); err != nil {
if err != ErrNoShmMount { if err != ErrNoShmMount {
t.Fatal(err) t.Fatal(err)

View File

@ -25,6 +25,7 @@ func containersToProto(containers []containers.Container) []api.Container {
var containerspb []api.Container var containerspb []api.Container
for _, image := range containers { for _, image := range containers {
image := image
containerspb = append(containerspb, containerToProto(&image)) containerspb = append(containerspb, containerToProto(&image))
} }

View File

@ -27,6 +27,7 @@ func imagesToProto(images []images.Image) []imagesapi.Image {
var imagespb []imagesapi.Image var imagespb []imagesapi.Image
for _, image := range images { for _, image := range images {
image := image
imagespb = append(imagespb, imageToProto(&image)) imagespb = append(imagespb, imageToProto(&image))
} }