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) {
`
leg | transport | peer | sent | bandwidth (sent share) | ` +
`recv | rtt | rtx | state | `)
for _, l := range snap.Legs {
- pct := int(l.SentBytes * 100 / maxSent)
+ // share is 0..100 (maxSent is the per-leg max, >=1) — kept as uint64 and
+ // printed directly so there's no uint64->int narrowing to overflow-check.
+ share := l.SentBytes * 100 / maxSent
state, scls := legState(l)
fmt.Fprintf(b, `| R%d | %s | %s | %s | `,
l.Index, html.EscapeString(orDash(l.TpType)), html.EscapeString(shortPK(l.RemotePK)), humanBytes(l.SentBytes))
- fmt.Fprintf(b, ` | `, scls, pct)
+ fmt.Fprintf(b, ` | `, scls, share)
fmt.Fprintf(b, `%s | %.0f ms | %d | %s |
`,
humanBytes(l.RecvBytes), l.LatencyMS, l.Retransmits, scls, state)
}
diff --git a/pkg/visor/embedded_proxystatus.go b/pkg/visor/embedded_proxystatus.go
index 9dca32b879..b31037f148 100644
--- a/pkg/visor/embedded_proxystatus.go
+++ b/pkg/visor/embedded_proxystatus.go
@@ -66,7 +66,8 @@ func (p *visorStatusProvider) StatusSnapshot(surface proxystatus.Surface) (proxy
snap := proxystatus.Snapshot{Surface: surface, App: app}
if p.v.procM != nil {
- _, snap.Running = p.v.procM.ProcByName(app)
+ proc, ok := p.v.procM.ProcByName(app)
+ snap.Running = ok && proc != nil
}
// Logs (best-effort): the store may not exist for an internal app that has
diff --git a/pkg/visor/meshproxy.go b/pkg/visor/meshproxy.go
index cd2bce0a78..ce20807dbb 100644
--- a/pkg/visor/meshproxy.go
+++ b/pkg/visor/meshproxy.go
@@ -746,7 +746,10 @@ func meshStatusHandler(suffix string, status proxystatus.Provider, next http.Han
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Header().Set("Cache-Control", "no-store")
- _, _ = w.Write(proxystatus.Render(snap)) //nolint:errcheck
+ // G705: proxystatus.Render emits trusted, server-generated HTML that
+ // HTML-escapes every interpolated value (see pkg/proxystatus/render.go);
+ // it is not tainted request input.
+ _, _ = w.Write(proxystatus.Render(snap)) //nolint:errcheck,gosec
return
}
}
diff --git a/pkg/visor/routeviz_embed.go b/pkg/visor/routeviz_embed.go
index 96e52e02d2..00b18b831d 100644
--- a/pkg/visor/routeviz_embed.go
+++ b/pkg/visor/routeviz_embed.go
@@ -20,6 +20,8 @@ func (hv *Hypervisor) getRouteViz() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Header().Set("Cache-Control", "no-cache")
- _, _ = w.Write(routeVizHTML)
+ if _, err := w.Write(routeVizHTML); err != nil {
+ hv.log(r).WithError(err).Debug("route-viz page write failed")
+ }
}
}