Implement GitHub Actions pinning automation for improved security #25
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.
This PR implements an automated system to pin GitHub Actions to their full-length commit SHAs instead of using version tags, significantly improving the security posture of the repository by preventing supply chain attacks.
Problem
The existing CI/CD workflow was using unpinned GitHub Actions with version tags:
actions/checkout@v3(used 3 times across jobs)actions/setup-node@v3(used 3 times across jobs)This creates a security vulnerability where malicious actors could potentially move these tags to point to compromised commits, allowing them to inject malicious code into the CI/CD pipeline.
Solution
Created a comprehensive automation system that:
.github/workflows/to identify unpinned GitHub ActionsKey Features
./action) and already-pinned actions--dry-runflagUsage
Results
All 6 instances of unpinned actions have been successfully updated:
actions/checkout@v3→actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744actions/setup-node@v3→actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610The workflow file remains fully functional and passes YAML validation. Future runs of the automation will detect that all actions are already pinned and report "All GitHub Actions are already pinned to commit SHAs."
Files Added
scripts/pin-github-actions.js- Main automation script with GitHub API integrationscripts/pin-actions.sh- Bash wrapper with auto-commit functionalitytest/pin-github-actions.test.js- Comprehensive test suiteREADME.mdwith detailed documentation and usage examplespackage.jsonwith new npm scripts for easier usageThis implementation follows security best practices and provides a reusable solution for maintaining GitHub Actions security across the project lifecycle.
This pull request was created as a result of the following prompt from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.