fix(codeql): check Close() on writable file handles#13
Merged
Conversation
CodeQL's go/unhandled-writable-file-close flagged three spots where a writable file handle's Close() return was ignored via `defer`. Two are instance-lock files (never written; close genuinely can't lose data but CodeQL's flow analysis traces the O_RDWR open and warns anyway). One is a real upload-target in internal/files/files.go — ignoring that Close() would mask flush or fsync errors, the only way a successful Copy → silent data loss can happen. - `internal/files/files.go:126` — real fix. Replace `defer out.Close()` with an explicit close-and-check on each exit path; surface close errors as a failed upload. - `cmd/shellboto/main.go:95` — lockfile Close() wrapped in a defer that logs on error (via zap Warn). - `cmd/shellboto/cmd_db.go:174` — same, logs to stderr. Closes 3 of the 7 open CodeQL alerts. The remaining 4 (go/incorrect-integer-conversion on uid/gid → int narrowing) are false positives on our 64-bit-only build targets; dismissed via the security tab separately.
amiwrpremium
added a commit
that referenced
this pull request
Apr 21, 2026
🤖 I have created a release *beep* *boop* --- ## [0.1.1](v0.1.0...v0.1.1) (2026-04-21) ### Bug fixes * **ci:** commit-msg regex accepts multiple parenthesised scopes ([#10](#10)) ([fa8a3ff](fa8a3ff)) * **codeql:** check Close() on writable file handles ([#13](#13)) ([43c0b80](43c0b80)) ### CI * **release-please:** authenticate via RELEASE_PLEASE_TOKEN PAT ([#14](#14)) ([7434055](7434055)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: AMiWR <83715695+amiwrpremium@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves 3 of 7 open CodeQL go/unhandled-writable-file-close alerts. Upload-target Close is a real fix; two lockfile Closes are flock-only but satisfy the linter.