Skip to content
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

Expand github action pinning guidance to include update approach #868

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

huwd
Copy link
Member

@huwd huwd commented Feb 8, 2024

SHA pinning is a sensible approach to mitigate potential supply chain attacks. See some great blog posts here on the approach:

https://blog.rafaelgss.dev/why-you-should-pin-actions-by-commit-hash also
https://michaelheap.com/improve-your-github-actions-security/#using-pin-github-action

However one down side is that SHA's are not very human readable. It can be difficult to tell from the SHA if the version we've pinned has an update, or if that update is a security or important fix.

Best practice therefore is to place a comment after the pinned version listing the semantic version for a third party github action.

This gets you best of both worlds, maintainability plus certainty.

It might look at bit like this:

jobs:
  check-pull-request:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository code
	uses: actions/checkout@ee066bloop # pin @v2
      - name: Install Ruby uses:
	ruby/setup-ruby@22acsewblah # pin@v1

Consistency here also helps us manage this code in line with the GDS Way requirement to Update dependencies frequently when managing third party dependencies:
https://gds-way.digital.cabinet-office.gov.uk/standards/tracking-dependencies.html#update-dependencies-frequently

Since October 2022 DependaBot will now look for comments on SHA pinning and automatically suggest updates. Similar approaches may be possible for other dependency management tools.

Dependabot currently supports a range of different comment syntaxses which can be viewed here:
dependabot/dependabot-core#5951 (comment)

I've tried to keep the guidance general and open, leaving detail to this commit history, given the range of different tools on use across GDS.

The principles are:

  • Pin your actions using SHAs
  • Ensure human readability by commenting the semver on the line with the action
  • Explore if your usual dependency management process, especially automated ones like DependaBot can help flag and raise visibility on new versions.

Looks like

image
image

@huwd huwd requested a review from willp-bl February 8, 2024 13:01
Copy link
Contributor

@willp-bl willp-bl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good just needs a couple of minor changes.

source/standards/source-code/use-github.html.md.erb Outdated Show resolved Hide resolved
source/standards/source-code/use-github.html.md.erb Outdated Show resolved Hide resolved
@stephengrier
Copy link
Contributor

This seems like a good change to me and is inline with what we're already doing in some places. I'm happy to approve when the comments are resolved.

SHA pinning is a sensible approach to mitigate potential supply chain
attacks. See some great blog posts here on the approach:

https://blog.rafaelgss.dev/why-you-should-pin-actions-by-commit-hash
also
https://michaelheap.com/improve-your-github-actions-security/#using-pin-github-action

However one down side is that SHA's are not very human readable. It can
be difficult to tell from the SHA if the version we've pinned has an
update, or if that update is a security or important fix.

Best practice therefore is to place a comment after the pinned version
listing the semantic version for a third party github action.

This gets you best of both worlds, maintainability plus certainty.

It might look at bit like this:

```
jobs:
  check-pull-request:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository code
	uses: actions/checkout@ee066bloop # pin @v2
      - name: Install Ruby uses:
	ruby/setup-ruby@22acsewblah # pin@v1
```

Consistency here also helps us manage this code in line with the GDS Way
requirement to Update dependencies frequently when managing third party
dependencies:
https://gds-way.digital.cabinet-office.gov.uk/standards/tracking-dependencies.html#update-dependencies-frequently

Since October 2022 DependaBot will now look for comments on SHA pinning
and automatically suggest updates. Similar approaches may be possible
for other dependency management tools.

Dependabot currently supports a range of different comment syntaxses
which can be viewed here:
dependabot/dependabot-core#5951 (comment)

I've tried to keep the guidance general and open, leaving detail to this
commit history, given the range of different tools on use across GDS.

The principles are:

- Pin your actions using SHAs
- Ensure human readability by commenting the semver on the line with the
  action
- Explore if your usual dependency management process, especially
  automated ones like DependaBot can help flag and raise visibility on
  new versions.
@huwd
Copy link
Member Author

huwd commented Apr 23, 2024

Rightio folks,
Finally got this done, ready for a re-review if one of @andyloughran, @stephengrier, @willp-bl wouldn't mind another look?

@huwd huwd dismissed willp-bl’s stale review April 23, 2024 15:00

Request for a re-review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants