Skip to content

Commit 8a6e283

Browse files
committed
Fix Go staticcheck findings
1 parent efa98de commit 8a6e283

3 files changed

Lines changed: 56 additions & 12 deletions

File tree

.agents/sow/done/SOW-0010-20260602-static-analysis-finding-cleanup.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
Status: completed
66

7-
Sub-state: Local rule cleanup validated, Codacy Cloud import accepted, and
8-
GitHub workflow changes ready for commit.
7+
Sub-state: Reopened after GitHub Static Analysis exposed staticcheck
8+
annotations from the previous commit; fixed and locally validated.
99

1010
## Requirements
1111

@@ -357,8 +357,10 @@ Completed.
357357
reconfigured, and repository reanalysis requested.
358358
- GitHub Code Scanning producers were tuned so current result-bearing rules are
359359
removed from active upload paths instead of hidden in GitHub only.
360-
- No SDK runtime code, protocol behavior, public docs, or public integration
361-
skills changed.
360+
- Go staticcheck annotations from the previous commit were fixed by preserving
361+
overflow checks in lookup offset calculations and removing an unused POSIX
362+
UDS helper.
363+
- No protocol behavior, public docs, or public integration skills changed.
362364

363365
## Lessons Extracted
364366

@@ -374,4 +376,41 @@ None yet.
374376

375377
## Regression Log
376378

377-
None yet.
379+
## Regression - 2026-06-02
380+
381+
What broke:
382+
383+
- GitHub Static Analysis for commit `efa98de` completed successfully, but the
384+
`src/go` staticcheck step still emitted annotations:
385+
`src/go/pkg/netipc/protocol/lookup.go:758`,
386+
`src/go/pkg/netipc/protocol/lookup.go:1274`,
387+
`src/go/pkg/netipc/protocol/lookup.go:1278`, and
388+
`src/go/pkg/netipc/transport/posix/uds.go:667`.
389+
390+
Why previous validation missed it:
391+
392+
- The scanner cleanup validation focused on Codacy, GitHub Code Scanning SARIF
393+
producers, gosec, Semgrep, workflow syntax, and actionlint. The existing
394+
Static Analysis workflow kept staticcheck as `continue-on-error`, so the
395+
workflow stayed green while annotations still existed.
396+
397+
Repair plan:
398+
399+
- Fix the three `SA4006` findings by checking overflow status immediately after
400+
intermediate offset calculations.
401+
- Remove the unused `maxU32` helper that triggered `U1000`.
402+
- Re-run local staticcheck and Go tests.
403+
404+
Validation:
405+
406+
- `cd src/go && "$(go env GOPATH)/bin/staticcheck" ./...` passed.
407+
- `cd src/go && go test ./...` passed.
408+
- `codacy-analysis analyze . --output-format sarif --output /tmp/plugin-ipc-codacy-sow0010-final.sarif --parallel-tools 2 --tool-timeout 900000`
409+
reported zero issues after the Go fix.
410+
411+
Artifact updates:
412+
413+
- Specs: no protocol/API behavior changed; the Go fix preserves the intended
414+
overflow behavior and makes it explicit.
415+
- Runtime project skills: no update needed.
416+
- End-user/operator docs and skills: no public workflow changed.

src/go/pkg/netipc/protocol/lookup.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,10 @@ func (b *CgroupsLookupBuilder) Add(status, orchestrator uint16, path, name []byt
757757
if ok {
758758
nameOff, ok = checkedAddInt(nameOff, 1)
759759
}
760+
if !ok {
761+
b.err = ErrOverflow
762+
return ErrOverflow
763+
}
760764
fixedEnd, ok := checkedAddInt(nameOff, len(name))
761765
if ok {
762766
fixedEnd, ok = checkedAddInt(fixedEnd, 1)
@@ -1273,10 +1277,18 @@ func (b *AppsLookupBuilder) Add(status, cgroupStatus, orchestrator uint16, pid,
12731277
if ok {
12741278
pathOff, ok = checkedAddInt(pathOff, 1)
12751279
}
1280+
if !ok {
1281+
b.err = ErrOverflow
1282+
return ErrOverflow
1283+
}
12761284
nameOff, ok := checkedAddInt(pathOff, len(cgroupPath))
12771285
if ok {
12781286
nameOff, ok = checkedAddInt(nameOff, 1)
12791287
}
1288+
if !ok {
1289+
b.err = ErrOverflow
1290+
return ErrOverflow
1291+
}
12801292
fixedEnd, ok := checkedAddInt(nameOff, len(cgroupName))
12811293
if ok {
12821294
fixedEnd, ok = checkedAddInt(fixedEnd, 1)

src/go/pkg/netipc/transport/posix/uds.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -664,13 +664,6 @@ func minU32(a, b uint32) uint32 {
664664
return b
665665
}
666666

667-
func maxU32(a, b uint32) uint32 {
668-
if a > b {
669-
return a
670-
}
671-
return b
672-
}
673-
674667
// ---------------------------------------------------------------------------
675668
// Low-level I/O
676669
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)