From fd9d9480bcdfd71f1572f3ea15df9cd51f2c3964 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:25:49 +0000 Subject: [PATCH 1/4] Bump securego/gosec from 2.21.2 to 2.21.3 Bumps [securego/gosec](https://github.com/securego/gosec) from 2.21.2 to 2.21.3. - [Release notes](https://github.com/securego/gosec/releases) - [Changelog](https://github.com/securego/gosec/blob/master/.goreleaser.yml) - [Commits](https://github.com/securego/gosec/compare/v2.21.2...v2.21.3) --- updated-dependencies: - dependency-name: securego/gosec dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/security.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index e7f9c2e..0efa021 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -22,7 +22,7 @@ jobs: - name: Checkout Source uses: actions/checkout@v4 - name: Run Gosec Security Scanner - uses: securego/gosec@v2.21.2 + uses: securego/gosec@v2.21.3 with: args: '-no-fail -fmt sarif -out results.sarif -tests ./...' - name: Upload SARIF file From 23eae8fa083280caec60ae4cebabd8f9f38b27ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 18 Sep 2024 22:55:03 +0200 Subject: [PATCH 2/4] Remove unused input govulncheck-action --- .github/workflows/security.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 0efa021..59809ab 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -42,7 +42,6 @@ jobs: - id: govulncheck uses: golang/govulncheck-action@v1.0.3 with: - govulncheck-action: go.mod output-format: sarif output-file: results.sarif - name: Fix SARIF format From 09c416dcebe6d555e04c975c734c3f40ca201abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 18 Sep 2024 23:28:21 +0200 Subject: [PATCH 3/4] Ensure portNumber is not to large Otherwise we could have a potential integer overflow when converting to int in the following statement. --- internal/container/container.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/container/container.go b/internal/container/container.go index e3a4375..8c75b5f 100644 --- a/internal/container/container.go +++ b/internal/container/container.go @@ -56,6 +56,13 @@ func (c Container) Services() map[string]uint16 { continue } + //nolint:gomnd + if portNumber > 65535 { + log.Logf(log.PriErr, "Port number %d is too large", portNumber) + + continue + } + service := netdb.GetServByPort(int(portNumber), proto) if service == nil || proto == nil { From 8a97b1f2452268876615d23ccfb7d60f84b193ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 18 Sep 2024 23:35:55 +0200 Subject: [PATCH 4/4] Fix issues reported by golangci-lint --- container.go | 4 ++-- internal/container/container.go | 2 +- internal/hostname/hostname_test.go | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/container.go b/container.go index 533a2e6..725e242 100644 --- a/container.go +++ b/container.go @@ -9,8 +9,8 @@ import ( "syscall" "time" - "github.com/docker/docker/api/types" typesContainer "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/client" "ldddns.arnested.dk/internal/container" @@ -126,7 +126,7 @@ func listen(ctx context.Context, config Config, docker *client.Client, egs *entr filter.Add("event", "start") filter.Add("event", "unpause") - msgs, errs := docker.Events(ctx, types.EventsOptions{ + msgs, errs := docker.Events(ctx, events.ListOptions{ Filters: filter, Since: strconv.FormatInt(started.Unix(), 10), Until: "", diff --git a/internal/container/container.go b/internal/container/container.go index 8c75b5f..01e44f0 100644 --- a/internal/container/container.go +++ b/internal/container/container.go @@ -56,7 +56,7 @@ func (c Container) Services() map[string]uint16 { continue } - //nolint:gomnd + //nolint:mnd,gomnd if portNumber > 65535 { log.Logf(log.PriErr, "Port number %d is too large", portNumber) diff --git a/internal/hostname/hostname_test.go b/internal/hostname/hostname_test.go index 0481f9a..776d6c2 100644 --- a/internal/hostname/hostname_test.go +++ b/internal/hostname/hostname_test.go @@ -108,10 +108,9 @@ func TestRewriteHostname(t *testing.T) { } for _, tt := range testdata { - tt := tt t.Run(tt.in, func(t *testing.T) { - t.Logf("%q %q\n", tt.in, tt.out) t.Parallel() + if s := hostname.RewriteHostname(tt.in); s != tt.out { t.Errorf("got %q from %q, want %q", s, tt.in, tt.out) } @@ -130,7 +129,7 @@ func FuzzRewriteHostname(f *testing.F) { f.Add("blåbærgrød") f.Add("xn--blbrgrd-fxak7p.local") - f.Fuzz(func(t *testing.T, a string) { + f.Fuzz(func(_ *testing.T, a string) { hostname.RewriteHostname(a) }) }