-
Notifications
You must be signed in to change notification settings - Fork 588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CI: pin GitHub actions to SHAs and use Dependabot to update them #4774
CI: pin GitHub actions to SHAs and use Dependabot to update them #4774
Conversation
Is this really necessary for actions that come from Github? I personally would be more annoyed by regular merge requests from a bot that just bumps commit IDs. |
Maybe, but there might still be problems with forks and PRs. We already have also LGTM, which is 3rd party. I'd expect the CI setup to expand to further 3rd party systems (for example Coveralls could be interesting) and maybe one day there are Python dependencies (like Meson and Ninja). The small downside is that simple version IDs like
The frequency can be tuned to monthly but I haven't found weekly check to be too noisy. The PRs are rather trivial and it's also easy to be vigilant and check the SHAs. |
Did I miss understand something or where's the issue with semver dependencies if we are not using |
There are other problems mentioned in the page, like "pull_request_target still has the read/write repository token in memory that is potentially available to any running program". Maybe other problems will rise in the future. The actions could be also buggy and keeping them relatively recent could help with that, like with any software. Using unmaintained 'v1' forever is asking for problems. |
@topimiettinen commented on Dec 14:
Since AFAIK GitHub does not verify the GPG signature of a tag after cloning it,
The dependabot spam is also a concern of mine, though I suppose that it's |
.github/workflows/build-extra.yml
Outdated
@@ -30,15 +30,15 @@ jobs: | |||
build-clang: | |||
runs-on: ubuntu-20.04 | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- uses: actions/checkout@@ec3a7ce113134d7a93b817d10a8272cb61118579 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unclear which version a SHA represents.
How about putting each intended version in a comment?
- uses: actions/checkout@@ec3a7ce113134d7a93b817d10a8272cb61118579 | |
# v2 | |
- uses: actions/checkout@@ec3a7ce113134d7a93b817d10a8272cb61118579 |
Or maybe:
- uses: actions/checkout@@ec3a7ce113134d7a93b817d10a8272cb61118579 | |
# actions/checkout@v2 | |
- uses: actions/checkout@@ec3a7ce113134d7a93b817d10a8272cb61118579 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the comment be updated by Dependabot? Otherwise it will bitrot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the comment be updated by Dependabot? Otherwise it will bitrot.
With the current configuration, does Dependabot put something like "update
foo@v1 to foo@v2" in the commit message (I know that it can do that, but I'm
not sure if it's the default)? If the equivalent tags can be discovered
locally/without having to search for them on GitHub, I think that would be good
enough.
If not, instead of a comment on each item, to avoid bitrot and duplication I
think we could have a mapping on a separate file. It would only need updating
when adding a completely new "action@version" combination (i.e.: one that was
never part of any committed workflow file). Kind of like a "package.lock"
file. Example:
actions/checkout@v2: ec3a7ce113134d7a93b817d10a8272cb61118579
actions/checkout@v3: 1231231231231231231231231231231231231231
github/codeql-action/init@v1: e095058bfa09de8070f94e98f5dc059531bc6235
By the way, is Dependabot smart enough to update a SHA to a new SHA or would it
open a PR to bump actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
to actions/checkout@v3
in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the comment be updated by Dependabot? Otherwise it will bitrot.
With the current configuration, does Dependabot put something like "update foo@v1 to foo@v2" in the commit message (I know that it can do that, but I'm not sure if it's the default)? If the equivalent tags can be discovered locally/without having to search for them on GitHub, I think that would be good enough.
Yes, here's an example commit/PR with the same settings: topimiettinen/libaslrmalloc@0aeb663
If not, instead of a comment on each item, to avoid bitrot and duplication I think we could have a mapping on a separate file. It would only need updating when adding a completely new "action@version" combination (i.e.: one that was never part of any committed workflow file). Kind of like a "package.lock" file. Example:
actions/checkout@v2: ec3a7ce113134d7a93b817d10a8272cb61118579 actions/checkout@v3: 1231231231231231231231231231231231231231 github/codeql-action/init@v1: e095058bfa09de8070f94e98f5dc059531bc6235
For Python, there's requirements.txt
with similar syntax (https://github.com/topimiettinen/libaslrmalloc/blob/master/.github/workflows/requirements.txt) but I don't know if that would work for GH actions. Example of Dependabot updating it: topimiettinen/libaslrmalloc@248495b
By the way, is Dependabot smart enough to update a SHA to a new SHA or would it open a PR to bump
actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
toactions/checkout@v3
in this case?
Only SHA is updated. There's also a GH action to verify that PRs don't change SHAs to semvers: https://github.com/zgosalvez/github-actions-ensure-sha-pinned-actions but I don't know if there's an action to verify that it actually does what it says it does and so forth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good then; thanks for the examples.
A GPG signature is also a hash, signed with a key. Instead of pinning the SHA, only the public key used for signing would need to be pinned. But which key? It would also need updating when the keys expire, there's maybe also CRL, OCSP, master keys, CAs etc. Cryptographic signatures could be better but they're also more complex.
Yeah, I can only imagine the noise with JS or Python. This shouldn't be as bad. Continuing the comparison of the Actions to other software: an LTS version of the Action with only security updates could be nice but I guess such things don't exist. |
Pinning actions to SHAs instead of versions improves the supply chain security: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
44f77eb
to
7160135
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for having Dependabot check the dependencies.
As for the pinning, maybe using exact versions (such as @2.1.0
) would be a
secure enough alternative (not sure), but I don't feel strongly about it either
way. Might expand on this on a discussion later.
Great! What about @reinerh and @rusty-snake, are you now OK with this or do you have further questions?
The problem is that PRs and forks could still forge the same exact version numbers but with SHAs its very hard. |
I still don't understand why it is necessary (we don't use pull_request_target either), but don't take this as blocking a merge. |
See:
https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
and:
https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/keeping-your-actions-up-to-date-with-dependabot