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

Set top level permission to remaining workflows #13385

Merged
merged 7 commits into from
May 22, 2023
Merged

Conversation

joycebrum
Copy link
Contributor

Motivation:

Setting minimum permissions on workflow's top level is good practice. Similar changes were previously discussed in #12462. Since some workflows were left out of the previous PR, this PR is a small update to restrict their permissions.

Modification:

Set top level read only permission to ci-deploy.yml, ci-pr.yml, ci-release.yml and ci-release5.yml

I wasn't able to test the workflows:

  • ci-release.yml and ci-release5.yml: although I wasn't able to test successfully, considering that they are basically using personalized secrets and not the standard GITHUB_TOKEN (github.token), I've considered that no write permission would be needed to it. To avoid errors I've opted for read-all instead of contents: read.

  • ci-deploy.yml also seems to not be working so I wasn't able to provide a success example either.

  • ci-pr.yml run example https://github.com/joycebrum/netty/actions/runs/4994205584. Not sure why it didn't run on my fork but the errors seems not to be related to any permission. Anyway, I've changed the permission to read-all which certainly will be enough since it runs on pull request (which will always be no more than read-all to external PRs).

Result:

Similar change discussed at #12462: since github workflow default behavior is to grant write all permission to any workflow it is both a recommendation from OpenSSF Scorecard and the Github to always use credentials that are minimally scoped.

Signed-off-by: Joyce <joycebrum@google.com>
Signed-off-by: Joyce <joycebrum@google.com>
Signed-off-by: Joyce <joycebrum@google.com>
Signed-off-by: Joyce <joycebrum@google.com>
Signed-off-by: Joyce <joycebrum@google.com>
@normanmaurer
Copy link
Member

@joycebrum thanks a lot! Can you please also sign our ICLA: https://netty.io/s/icla

@joycebrum
Copy link
Contributor Author

Done! Thanks for the reminder.

@normanmaurer normanmaurer added this to the 4.1.93.Final milestone May 19, 2023
@normanmaurer
Copy link
Member

@joycebrum I think ci-release* will need write access as these will create tags during the release process and also add commits. I am wrong ?

@joycebrum
Copy link
Contributor Author

joycebrum commented May 19, 2023

It seems that the write permission to create tags and releases is coming from SSH_PRIVATE_KEY_PEM and not GITHUB_TOKEN so GITHUB_TOKEN might not need it.

If it was an action used to create the release, for example, (such as softprops/action-gh-release), then it would need to grant permission to GITHUB_TOKEN.

@normanmaurer normanmaurer merged commit 439e907 into netty:4.1 May 22, 2023
14 checks passed
normanmaurer pushed a commit that referenced this pull request May 22, 2023
Motivation:

Setting minimum permissions on workflow's top level is good practice.
Similar changes were previously discussed in
#12462. Since some workflows were
left out of the previous PR, this PR is a small update to restrict their
permissions.

Modification:

Set top level read only permission to `ci-deploy.yml`, `ci-pr.yml`,
`ci-release.yml` and `ci-release5.yml`

I wasn't able to test the workflows:

- `ci-release.yml` and `ci-release5.yml`: although I wasn't able to test
successfully, considering that they are basically using personalized
secrets and not the standard GITHUB_TOKEN (github.token), I've
considered that no write permission would be needed to it. To avoid
errors I've opted for `read-all` instead of `contents: read`.

- `ci-deploy.yml` also seems to not be working so I wasn't able to
provide a success example either.

- `ci-pr.yml` run example
https://github.com/joycebrum/netty/actions/runs/4994205584. Not sure why
it didn't run on my fork but the errors seems not to be related to any
permission. Anyway, I've changed the permission to read-all which
certainly will be enough since it runs on pull request (which will
always be no more than read-all to external PRs).

Result:

Similar change discussed at #12462:
since github workflow default behavior is to grant write all permission
to any workflow it is both a recommendation from [OpenSSF
Scorecard](https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions)
and the
[Github](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions)
to always use credentials that are minimally scoped.

---------

Signed-off-by: Joyce <joycebrum@google.com>
@normanmaurer
Copy link
Member

@joycebrum thanks a lot!

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

2 participants