✨ Check for correct action pinning #285
Merged
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 pull request includes implementing a new GitHub Action to check for untrusted GitHub Actions pinned to a version rather than a SHA hash.
As per GitHub's documentation on using third-party actions, we should use the commit hash of a release rather than the GitHub version.
i.e.
This 👇
uses: oxsecurity/megalinter/flavors/python@32c1b3827a334c80026c654f31ee1b4801ad8798
Over 👇
uses: oxsecurity/megalinter/flavors/python@v1
The action simply uses the sting value after the @ symbol. This is a simple way to check for commit hash and the following examples will not be captured:
We've chosen the following organisations as "trusted":
ministryofjustice
actions
It's been agreed that we can implicitly trust these authors' actions, and version pinning can take place without an SHA.
Why not just use ActionLint
We attempted to use actionlint, but we found it too opinionated and rigid. We only want to check if third-party actions are pinned by a SHA.
### What's next
Implementation of GitHub Action:
Dockerfile:
python:3.12-slim
and installing necessary dependencies fromrequirements.txt
. (check-version-pinning/Dockerfile
)Main Script:
check_version_pinning.py
to scan workflow files and check for untrusted GitHub Actions pinned to a version. (check-version-pinning/check_version_pinning.py
)Action Metadata:
action.yaml
to define the action's inputs, outputs, and how it runs using the Docker image. (check-version-pinning/action.yaml
)Documentation and Tests:
Documentation:
README.md
to provide an overview of the action, its inputs, outputs, and an example usage. (check-version-pinning/README.md
)Tests:
test_check_version_pinning.py
to verify the functionality of the main script. (check-version-pinning/test_check_version_pinning.py
)Requirements:
pyyaml
as a dependency inrequirements.txt
. (check-version-pinning/requirements.txt
)