You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
go-format: _go_before snapshot temp file leaks on the syntax-error and tool-break arms #3405
plugins/go-format/hooks/go-format.sh snapshots the file before running goimports (_go_before=$(mktemp ...) plus cp at lines 230-232) so it can disclose a rewrite. The snapshot is released only on the clean arm: rm -f "$_go_before" at line 254, inside the RC -eq 0 branch. The other two arms both exit 0 without releasing it:
the syntax-error arm (RC -eq 2 with stderr, lines ~262-282)
the tool-break catch-all (lines ~284-296)
Every hook run that reaches either arm leaks one file in the OS temp tree. grep -n '_go_before' go-format.sh confirms references end at line 254; no trap or later cleanup exists.
This is the same defect class #3401 (a7f9537) just fixed in powershell-format, and the sibling of #3366 (_ps_before leak on the trust-gate and tool-break arms). The error arms also skip the cmp/disclosure check entirely, so if goimports ever rewrites before failing, that rewrite would be undisclosed; #3401 handled the analogous disclosure on powershell's tool-break arm.
Verified against the code on 2026-08-27 (branch claude/architecture-improve-5cle8j scan; the leak is in main history, not introduced by any pending change).
Extend go-format.test.sh with an isolated-TMPDIR assertion that the scratch area is empty after a syntax-error run and after a tool-break run, with a during-run probe so the assertion is not vacuous.
Acceptance criteria
A run reaching the syntax-error arm leaves no snapshot file behind (asserted with an isolated TMPDIR).
A run reaching the tool-break arm leaves no snapshot file behind.
The clean-arm behavior (disclosure on rewrite, release, telemetry) is unchanged.
Activity