From 51be758eb605dab664501166b3b5f854bb26adb4 Mon Sep 17 00:00:00 2001 From: Moses Narrow <36607567+0pcom@users.noreply.github.com> Date: Fri, 21 Aug 2026 13:46:02 -0500 Subject: [PATCH] fix(lint): clear errcheck/gosec debt in status+interstitial code (make check green) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit golangci-lint 2.12.2 (errcheck check-blank:true, gosec G115/G705) flagged pre-existing issues in the merged status/interstitial code that CI's laxer lint let through, leaving `make check` RED on develop. No behavior change. - embedded_proxystatus.go: check ProcByName's returns instead of blanking. - routeviz_embed.go: handle the w.Write error (debug-log it). - proxystatus/render.go: keep the sent-share as uint64 and print it directly (no uint64->int narrowing) — clears gosec G115. - meshproxy.go: justify the status-page w.Write with //nolint:gosec (G705) — proxystatus.Render emits trusted server HTML that escapes all values. - stream_test.go / proxystatus_test.go: check the Write / ParseInt errors. --- pkg/proxyinterstitial/stream_test.go | 6 +++++- pkg/proxystatus/proxystatus_test.go | 5 ++++- pkg/proxystatus/render.go | 6 ++++-- pkg/visor/embedded_proxystatus.go | 3 ++- pkg/visor/meshproxy.go | 5 ++++- pkg/visor/routeviz_embed.go | 4 +++- 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/pkg/proxyinterstitial/stream_test.go b/pkg/proxyinterstitial/stream_test.go index b56a20d26a..b599ba0622 100644 --- a/pkg/proxyinterstitial/stream_test.go +++ b/pkg/proxyinterstitial/stream_test.go @@ -17,7 +17,11 @@ import ( // the fully de-chunked body. func readStreamBody(t *testing.T, c net.Conn, reqLine string) string { t.Helper() - go func() { _, _ = c.Write([]byte(reqLine)) }() + go func() { + if _, err := c.Write([]byte(reqLine)); err != nil { + return // reader finished + closed the pipe first — benign in this test + } + }() resp, err := http.ReadResponse(bufio.NewReader(c), nil) if err != nil { t.Fatalf("ReadResponse: %v", err) diff --git a/pkg/proxystatus/proxystatus_test.go b/pkg/proxystatus/proxystatus_test.go index 45d8890342..39da6aa6cd 100644 --- a/pkg/proxystatus/proxystatus_test.go +++ b/pkg/proxystatus/proxystatus_test.go @@ -108,7 +108,10 @@ func TestServeConn(t *testing.T) { func hexLum(h string) float64 { h = strings.TrimPrefix(h, "#") c := func(i int) float64 { - v, _ := strconv.ParseInt(h[i:i+2], 16, 0) + v, err := strconv.ParseInt(h[i:i+2], 16, 0) + if err != nil { + return 0 + } s := float64(v) / 255 if s <= 0.03928 { return s / 12.92 diff --git a/pkg/proxystatus/render.go b/pkg/proxystatus/render.go index aadf5dc465..6b01d8e5a9 100644 --- a/pkg/proxystatus/render.go +++ b/pkg/proxystatus/render.go @@ -93,11 +93,13 @@ func writeMuxSection(b *strings.Builder, snap Snapshot) { `