Enable gosec linter for golangci-lint

`gosec` linter is able to identify issues described in #6584

e.g.

$ git revert 54e95e6b88
[gosec dfc8ca1ec] Revert "fix Implicit memory aliasing in for loop"
 2 files changed, 2 deletions(-)

$ make check
+ proto-fmt
+ check
GOGC=75 golangci-lint run
containerstore.go:192:54: G601: Implicit memory aliasing in for loop. (gosec)
		containers = append(containers, containerFromProto(&container))
		                                                   ^
image_store.go:132:42: G601: Implicit memory aliasing in for loop. (gosec)
		images = append(images, imageFromProto(&image))
		                                       ^
make: *** [check] Error 1

I also disabled following two settings which prevent the linter to show a complete list of issues.

* max-issues-per-linter (default 50)
* max-same-issues (default 3)

Furthermore enabling gosec revealed many other issues. For now I blacklisted the ones except G601.

Will create separate tasks to address them one by one moving next.

Signed-off-by: Henry Wang <henwang@amazon.com>
This commit is contained in:
Henry Wang
2022-03-12 05:33:32 +00:00
parent d4641e1ce1
commit b8bf504e94
7 changed files with 22 additions and 0 deletions

View File

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