From 30e087cd4500c4d1dbbadb5956bf71fd863c8d8d Mon Sep 17 00:00:00 2001 From: Nikolai Emil Damm Date: Sun, 8 Nov 2026 03:52:16 +0100 Subject: [PATCH] fix(identity): clear golangci-lint findings in the Dex binary check Every platform pull request updated to main now fails the whole-repository golangci-lint step on these eight findings. Co-Authored-By: Claude Opus 5.5 --- scripts/check-dex-binary/main.go | 14 +++++++------- scripts/check-dex-binary/main_test.go | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/check-dex-binary/main.go b/scripts/check-dex-binary/main.go index 8b3571174f..d4da63ac79 100644 --- a/scripts/check-dex-binary/main.go +++ b/scripts/check-dex-binary/main.go @@ -93,8 +93,8 @@ func run(binary, scanner, advisory, web string) error { if err != nil { return err } - defer f.Close() - defer os.Remove(f.Name()) + defer func() { _ = f.Close() }() + defer func() { _ = os.Remove(f.Name()) }() ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() cmd := exec.CommandContext(ctx, scanner, "-mode", "binary", "-format", "json", binary) @@ -137,7 +137,7 @@ func binaryDigest(path string) ([32]byte, error) { if err != nil { return [32]byte{}, err } - defer f.Close() + defer func() { _ = f.Close() }() h := sha256.New() if _, err := io.Copy(h, f); err != nil { return [32]byte{}, err @@ -250,7 +250,7 @@ func nativeTLSFloor(binary, web, floor string) (resultErr error) { return err } defer func() { - if resultErr != nil && resultErr.Error() != "Dex discarded its configured TLS floor" { + if resultErr != nil && resultErr.Error() != "dex discarded its configured TLS floor" { // This process only receives the fictional configuration below. Keep // bounded failure diagnostics useful without retaining its private key. if body, err := os.ReadFile(filepath.Join(fixture, "dex.log")); err == nil { @@ -335,7 +335,7 @@ frontend: if err != nil { return err } - defer log.Close() + defer func() { _ = log.Close() }() ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() cmd := exec.CommandContext(ctx, binary, "serve", configPath) @@ -377,7 +377,7 @@ frontend: Issuer string `json:"issuer"` } err = json.NewDecoder(io.LimitReader(resp.Body, 65536)).Decode(&document) - resp.Body.Close() + _ = resp.Body.Close() if err == nil && resp.StatusCode == 200 && document.Issuer == issuer { ready = true break @@ -489,7 +489,7 @@ func exerciseTLS(address string, good *tls.Config) error { low := good.Clone() low.MinVersion, low.MaxVersion = tls.VersionTLS12, tls.VersionTLS12 if err := dial(low); err == nil || !strings.Contains(err.Error(), "protocol version not supported") { - return errors.New("Dex discarded its configured TLS floor") + return errors.New("dex discarded its configured TLS floor") } wrongCA := good.Clone() wrongCA.RootCAs = x509.NewCertPool() diff --git a/scripts/check-dex-binary/main_test.go b/scripts/check-dex-binary/main_test.go index f63266363f..ce1fb184e1 100644 --- a/scripts/check-dex-binary/main_test.go +++ b/scripts/check-dex-binary/main_test.go @@ -14,7 +14,7 @@ func TestNativeEndpointsStayReservedUntilHandoff(t *testing.T) { } defer func() { for _, listener := range listeners { - listener.Close() + _ = listener.Close() } }() if len(listeners) != 2 || listeners[0].Addr().String() == listeners[1].Addr().String() { @@ -23,7 +23,7 @@ func TestNativeEndpointsStayReservedUntilHandoff(t *testing.T) { for _, listener := range listeners { other, err := net.Listen("tcp", listener.Addr().String()) if err == nil { - other.Close() + _ = other.Close() t.Fatal("endpoint released before native process handoff") } } @@ -34,7 +34,7 @@ func TestNativeTLSFloorControls(t *testing.T) { if binary == "" || web == "" { t.Skip("native release fixture runs in the Dex image workflow") } - if err := nativeTLSFloor(binary, web, "1.2"); err == nil || err.Error() != "Dex discarded its configured TLS floor" { + if err := nativeTLSFloor(binary, web, "1.2"); err == nil || err.Error() != "dex discarded its configured TLS floor" { t.Fatalf("weak-floor control must reach the actual protocol check, got %v", err) } if err := nativeTLSFloor(binary, web, "1.3"); err != nil {