Repository navigation
ci: pin third-party actions to commit hashes and limit workflow permissions - #43
Merged
Merged
Conversation
…ssions Pin every third-party action to the commit its version tag points at, and keep the version as a trailing comment so Dependabot continues to update both. A moved or compromised tag can no longer change what runs in the release pipeline. Give tests.yml and security.yml a read-only token; they inherited the repository default, which is read and write. Stop actions/checkout from leaving the token in the checked-out files. Checked with actionlint and zizmor, which went from 51 findings (24 high) to none at default settings.
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.
Why
Every workflow referenced third-party actions by a movable tag or branch (for example
pypa/gh-action-pypi-publish@release/v1in the job that publishes to PyPI), and two workflows ran with the repository's default read-and-write token. A moved or compromised tag would have run unreviewed code in CI, and in the release pipeline.What changed
Only
.github/workflows/*.yml:# v7), and Dependabot's weeklygithub-actionsupdates understand this format and update both.tests.ymlandsecurity.ymlgetpermissions: contents: read. The other workflows already had explicit permissions.actions/checkoutsteps setpersist-credentials: false, so the token is not left in the checked-out files. No workflow pushes, tags or commits, and the only one that usesgh(the Discord announcement) does not check out code.Verification
actionlintis clean.zizmor(a GitHub Actions security linter) went from 51 findings (24 high) to none at default settings.Not in this PR
Switching the repository's default workflow token to read-only and turning on "require actions to be pinned to a full commit SHA" are repository settings. I'll make those after this merges, since turning the second one on first would fail every workflow.