Repository navigation
ci: align gosec pin across ci.yml, pre-commit.yml, and Makefile #1297
Description
Problem
Three sources currently pin gosec to inconsistent versions:
.github/workflows/ci.yml:321—securego/gosec@4a3bd8af174872c778439083ded7adbf3747e770 # v2.26.1(Docker Action, bumped in PR sec(ci): pin all GitHub Actions to commit SHAs #536).github/workflows/pre-commit.yml:97—go install ...@v2.22.4(with stale comment claiming it tracks ci.yml)Makefileinstall-dev-tools—GOSEC_VERSION?=v2.22.4(added by PR chore(make): drop broken recipes, pin dev tools, add ci to .PHONY #1245, aligned with pre-commit.yml)
PR #1245 deliberately aligned the Makefile with pre-commit.yml so install-dev-tools matches what pre-commit runs locally and in CI. The bigger problem is that pre-commit.yml's own pin (and its anchor comment, "Pinned to the same version ci.yml's securego/gosec Action uses") have been stale since PR #536 bumped ci.yml's Docker Action to v2.26.1.
Result: developers running the gosec scan locally via make install-dev-tools + make security-scan-go see a different gosec rule-set than the SARIF scan ci.yml uploads to GitHub Security. A new HIGH/CRITICAL rule shipped in v2.23.0+ would fail in CI while passing locally, or vice versa.
Proposed fix
Either:
- Track ci.yml (preferred) — bump
pre-commit.ymland the MakefileGOSEC_VERSIONtov2.26.1(or the next ci.yml bump), refresh the pre-commit.yml comment. - Track pre-commit.yml — pin ci.yml's Docker Action down to v2.22.x.
Whichever direction, fix all three sources in one PR so the Makefile comment ("keep in sync with the CI pins in .github/workflows/ci.yml, pre-commit.yml and database-migration.yml") becomes true.
References
- PR chore(make): drop broken recipes, pin dev tools, add ci to .PHONY #1245 introduced the Makefile pin and the anchor comment.
- PR sec(ci): pin all GitHub Actions to commit SHAs #536 (
sec(ci): pin all GitHub Actions to commit SHAs) bumped ci.yml's gosec Action to v2.26.1 without touching pre-commit.yml. - PR #3380eec96 (
fix(ci): pin actions to latest SHA of the in-use major, not a downgraded major) is the actual commit that landed the v2.26.1 bump.
Scope after the split
This repo (cloud-commitments-cli) is one of four repos affected, each with its own ci.yml, pre-commit.yml, Makefile and scripts/gosec-hook.sh; this issue now scopes to only this repo's own files. Siblings for the other three:
- ci: single-source the gosec pin across ci.yml, pre-commit.yml, Makefile and gosec-hook.sh [go part] cloud-commitments-go#117
- ci: single-source the gosec pin across ci.yml, pre-commit.yml, Makefile and gosec-hook.sh [mcp part] cloud-commitments-mcp#22
- ci: single-source the gosec pin across ci.yml, pre-commit.yml, Makefile and gosec-hook.sh [platform part] cloud-commitments-platform#347
Re-verified live on 2026-09-27, this repo's own state has moved on from what's described above (a comment on this issue from a maintainer, dated after the original filing, re-checked commit 3e9660d06): the original three-way version drift (v2.26.1 vs v2.22.4) is already fixed — ci.yml:328 no longer uses the securego/gosec Docker Action at all; all four current pin sites (ci.yml:328, pre-commit.yml:60/:67, Makefile:7, and a fourth site not in the original issue, scripts/gosec-hook.sh:35) now agree on v2.28.0. What's still open in this repo: the pre-commit.yml comment still wrongly claims to track a securego/gosec Action that no longer exists in ci.yml; the Makefile comment's claim to sync with database-migration.yml is still false (that workflow pins no gosec version); and the gosec install step + cache key in pre-commit.yml are dead code, since the gosec pre-commit hook is SKIPped in CI. Fix direction: single-source the version across all four sites and delete the dead pre-commit install step. This overlaps #1394 (pre-commit vs CI gosec rule-set divergence, a related but distinct problem); landing both as one "single source of truth for gosec" change avoids touching the same lines twice.
Activity
cristim commentedon Jul 28, 2026
Reviewed commit:
be11bdcb5. Note:origin/mainmoved to3e9660d06during the review; re-verify against currentmainbefore changing code, since a finding may have been fixed or moved.Still open on
3e9660d06, and the drift has grown since this issue was written. Adding the current state so the fix covers every site.Where (line numbers from
3e9660d06).github/workflows/ci.yml:328- v2.28.0 (thesecurego/gosecAction referenced in this issue is no longer used at all; see:325-328).github/workflows/pre-commit.yml:137- v2.22.4Makefile:16-GOSEC_VERSION?=v2.22.4scripts/gosec-hook.sh:35- v2.28.0 (a fourth declaration site, added after this issue was filed)Two stale comments that will mislead whoever does the fix
pre-commit.yml:134-136says:ci.ymlno longer uses that Action at all.Makefile:13-14claims sync with "ci.yml, pre-commit.yml and database-migration.yml".database-migration.ymlpins no gosec at any version; there is nothing to be in sync with.Dead weight to remove in the same change
The gosec install at
pre-commit.yml:132-137and its cache key at:130are never exercised: thegosechook isSKIPped in that job (pre-commit.yml:266). So one of the three or four sources of truth is not merely drifted, it does nothing at all.Failure scenario
The repo's own memory records that gosec rule sets differ materially between versions (v2.11.4 dropping G117). A developer runs
make install-dev-tools, gets v2.22.4, sees a cleanmake security-scan-go, pushes, and CI's v2.28.0 flags a rule that did not exist in v2.22.4 - reddening Security Scanning repo-wide and blocking every other PR until it is fixed. The inverse (v2.22.4 flagging locally what CI ignores) wastes the same cycle in the other direction.Fix direction
Single-source the version (a
GOSEC_VERSIONfile, or the Makefile variable) and haveci.yml,pre-commit.ymlandscripts/gosec-hook.shall read it. Delete theSKIPped gosec install and its cache key frompre-commit.ymlat the same time. This overlaps #1394, which covers the rule-set divergence between the same two gates; landing the two together as one "single source of truth for gosec" change avoids doing the same file twice.cristim commentedon Sep 27, 2026
Split after the monorepo split: each of the four repos has its own
ci.yml/pre-commit.yml/Makefile/gosec-hook.shgosec pins. This issue now covers onlycloud-commitments-cli's own files (updated issue body has the current, re-verified state: the original version drift is fixed, remaining work is single-sourcing + stale comments + dead pre-commit code). Siblings for the other three repos: