diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index e7f9c2e..59809ab 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 @@ -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 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 e3a4375..01e44f0 100644 --- a/internal/container/container.go +++ b/internal/container/container.go @@ -56,6 +56,13 @@ func (c Container) Services() map[string]uint16 { continue } + //nolint:mnd,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 { 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) }) }