Repository navigation
ci(security): save the gosec binary only when it exists - #1399
Merged
Merged
Conversation
run-gosec.sh exits 2 on setup failures, but an early mkdir or mktemp failure stops it with 1 before gosec is installed. The gosec step then marked binary_ready and "Save gosec binary" ran actions/cache/save on a missing path. Require the executable in the cache dir before marking it ready; findings and scan errors (exit 1, binary present) still save it. Follow-up to LeanerCloud#1398, from CodeRabbit's review there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
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.
Follow-up to #1398 (gosec result and binary caching), addressing the valid finding in CodeRabbit's review there.
What was wrong
scripts/run-gosec.shexits 2 on setup failures. But an earlymkdirormktempfailure can stop it with exit 1 before gosec is installed. The gosec step treated any exit other than 2 as "binary is in its cache dir", so it setbinary_ready=true, and "Save gosec binary" would then runactions/cache/saveon a path that doesn't exist.What changed
.github/workflows/ci.yml, "Run gosec Security Scanner" step:GOSEC_BIN_DIRfrom the cache-key step'sbin_diroutput.binary_ready=trueonly when the exit code isn't 2 AND$GOSEC_BIN_DIR/gosecis an executable file.No other behavior changes. The scan, the SARIF merge, the result cache and the job verdict are untouched.
Verification
actionlintonci.yml: clean.pre-commit run --files .github/workflows/ci.yml: all hooks pass (including the workflow lint and the zizmor injection audit) excepttrivy-config, which can't run because trivy isn't installed locally. I ran it instead withdocker run aquasec/trivy:0.69.3 config --severity HIGH,CRITICAL .github/workflows: clean, exit 0.scripts/test-git-secrets-allowlist.sh: 137 PASS, 0 FAIL. The secrets scan of the changed file is clean, and the planted key was flagged.🤖 Generated with Claude Code