Skip to content

Commit

Permalink
Update to latest deps for sec vulns. (#38)
Browse files Browse the repository at this point in the history
* Update to latest deps for sec vulns.

* Test with latest version of go.

* Lint with latest linters.
  • Loading branch information
sb10 authored Jul 2, 2024
1 parent ae0bc60 commit 5b77863
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 119 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.20.4
go-version: 1.22.4
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.1
version: v1.59.1
only-new-issues: true
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '1.20.4'
go-version: '1.22.4'

- name: Run tests
run: make test
Expand Down
83 changes: 56 additions & 27 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ run:

linters-settings:
dupl:
threshold: 50
threshold: 100
errcheck:
check-type-assertions: true
check-blank: true
Expand All @@ -16,13 +16,14 @@ linters-settings:
lines: 30
statements: 20
gocognit:
min-complexity: 8
nestif:
min-complexity: 2
min-complexity: 9
gocyclo:
min-complexity: 5
min-complexity: 7
gomnd:
ignored-functions:
- 'strconv.Parse*'
govet:
check-shadowing: true
shadow: true
enable-all: true
disable-all: false
disable:
Expand All @@ -33,6 +34,8 @@ linters-settings:
locale: UK
nakedret:
max-func-lines: 20
nestif:
min-complexity: 2
prealloc:
simple: true
range-loops: true
Expand All @@ -54,56 +57,85 @@ issues:
linters:
- funlen
- maintidx
- path: clog.go
- contextcheck
- gocognit
- gocyclo
- cyclop
- revive
- path: cmd
linters:
- gochecknoinits
- gochecknoglobals
- contextcheck
- dupl
- forbidigo
- path: version\.go
linters:
- forbidigo
- path: groupuser\.go
linters:
- dupl
- path: usergroup\.go
linters:
- dupl
max-issues-per-linter: 0
max-same-issues: 0
new-from-rev: master

linters:
disable-all: true
enable:
# defaults
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
# extras
- containedctx
- contextcheck
#- copyloopvar
- cyclop
- dogsled
- dupl
- dupword
- durationcheck
- err113
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- fatcontext
- forbidigo
- forcetypeassert
- funlen
- gci
- gocheckcompilerdirectives
- gochecknoglobals
- gochecknoinits
- gochecksumtype
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
- goerr113
- goimports
- gomnd
- gosec
- gosmopolitan
- grouper
- importas
- inamedparam
- interfacebloat
#- intrange
- ireturn
- lll
- maintidx
- makezero
- mirror
- misspell
- mnd
- nakedret
- nestif
- nilerr
Expand All @@ -112,56 +144,53 @@ linters:
- noctx
- nolintlint
- nosprintfhostport
- perfsprint
- prealloc
- predeclared
- reassign
- revive
- sloglint
- stylecheck
- tagalign
- tenv
- thelper
- tparallel
- unconvert
- unparam
- usestdlibvars
#- wastedassign
- wastedassign
- whitespace
- wsl
# disable:

#disable:
# - asasalint
# - asciicheck
# - bidichk
# - bodyclose
# - canonicalheader
# - decorder
# - depguard
# - errchkjson
# - execinquery
# - exhaustivestruct
# - exhaustruct
# - ginkgolinter
# - gofmt
# - gofumpt
# - goheader
# - golint
# - gomoddirectives
# - gomodguard
# - goprintffuncname
# - grouper
# - ifshort
# - interfacer
# - ireturn
# - loggercheck
# - maligned
# - musttag
# - nonamedreturns
# - nosnakecase
# - paralleltest
# - promlinter
# - protogetter
# - rowserrcheck
# - scopeline
# - spancheck
# - sqlclosecheck
# - structcheck
# - tagliatelle
# - testableexamples
# - testifylint
# - testpackage
# - tparallel
# - varcheck
# - varnamelen
# - wrapcheck
# - zerologlint
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"source.organizeImports": "explicit"
},
},
"go.formatTool": "goimports",
"go.formatFlags": [
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ To run the benchmarks:

Before committing any code, you should make sure you haven't introduced any
linting errors. First install the linters:
`curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.39.0`
`curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.1`

Then:
`make lint`
8 changes: 4 additions & 4 deletions container/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"context"
"encoding/json"

"github.com/docker/docker/api/types"
cn "github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
"github.com/wtsi-ssg/wr/container"
"github.com/wtsi-ssg/wr/math/convert"
Expand All @@ -50,7 +50,7 @@ func NewInteractor(cl *client.Client) *Interactor {
// ContainerList implements the Interactor interface method, which returns the
// list of containers.
func (i *Interactor) ContainerList(ctx context.Context) ([]*container.Container, error) {
containerList, err := i.dockerClient.ContainerList(ctx, types.ContainerListOptions{})
containerList, err := i.dockerClient.ContainerList(ctx, cn.ListOptions{})
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -80,8 +80,8 @@ func (i *Interactor) ContainerStats(ctx context.Context,

// decodeDockerContainerStats takes type.ContainerStats and decodes it to return
// the current memory usage (RSS, in MB) and total CPU (in seconds).
func decodeDockerContainerStats(containerStats types.ContainerStats) (*container.Stats, error) {
var ds *types.Stats
func decodeDockerContainerStats(containerStats cn.StatsResponseReader) (*container.Stats, error) {
var ds *cn.Stats

err := json.NewDecoder(containerStats.Body).Decode(&ds)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions container/docker/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (

"github.com/docker/docker/api/types"
cn "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/image"
nw "github.com/docker/docker/api/types/network"
"github.com/docker/docker/client"
specs "github.com/opencontainers/image-spec/specs-go/v1"
Expand Down Expand Up @@ -116,7 +117,7 @@ func createContainers(ctx context.Context, cli *client.Client, containerNames []
}

func pullUbuntuImage(ctx context.Context, cli *client.Client) error {
rc, err := cli.ImagePull(ctx, "ubuntu", types.ImagePullOptions{})
rc, err := cli.ImagePull(ctx, "ubuntu", image.PullOptions{})
if err != nil {
return err
}
Expand Down Expand Up @@ -153,14 +154,14 @@ func createContainer(ctx context.Context, cli *client.Client, cname string) (str
}

func startContainer(ctx context.Context, cli *client.Client, containerID string) error {
return cli.ContainerStart(ctx, containerID, types.ContainerStartOptions{})
return cli.ContainerStart(ctx, containerID, cn.StartOptions{})
}

// removeContainers removes all the containers given a list of containers as a
// part of clean up step.
func removeContainers(ctx context.Context, cli *client.Client, containerIDs []string) error {
for _, cid := range containerIDs {
err := cli.ContainerRemove(ctx, cid, types.ContainerRemoveOptions{Force: true})
err := cli.ContainerRemove(ctx, cid, cn.RemoveOptions{Force: true})
if err != nil {
return err
}
Expand Down
38 changes: 23 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,46 +1,54 @@
module github.com/wtsi-ssg/wr

go 1.17
go 1.21

toolchain go1.22.0

require (
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
github.com/docker/docker v24.0.2+incompatible
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/docker v27.0.3+incompatible
github.com/docker/go-connections v0.5.0 // indirect
github.com/go-stack/stack v1.8.1
github.com/hpcloud/tail v1.0.0
github.com/inconshreveable/log15 v2.16.0+incompatible
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc3
github.com/opencontainers/image-spec v1.1.0
github.com/ricochet2200/go-disk-usage/du v0.0.0-20210707232629-ac9918953285
github.com/rs/xid v1.5.0
github.com/sb10/l15h v0.0.0-20170510122137-64c488bf8e22
github.com/smartystreets/goconvey v1.6.4
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sys v0.21.0 // indirect
)

require (
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/term v0.0.0-20200312100748-672ec06f55cd // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/term v0.8.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 // indirect
go.opentelemetry.io/otel v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
go.opentelemetry.io/otel/sdk v1.27.0 // indirect
go.opentelemetry.io/otel/trace v1.27.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/tools v0.9.1 // indirect
gopkg.in/fsnotify.v1 v1.4.7 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.0.3 // indirect
)
Loading

0 comments on commit 5b77863

Please sign in to comment.