How to set GitHub Actions’s `permissions`?

GitHub introduce permissions fields on GitHub Actions for security reasons.

GitHub Actions: Control permissions for GITHUB_TOKEN | GitHub Changelog
Workflow syntax for GitHub Actions – GitHub Docs

The permissions field will help you to prevent soft…


This content originally appeared on DEV Community and was authored by azu

GitHub introduce permissions fields on GitHub Actions for security reasons.

The permissions field will help you to prevent software supply chain attack.

For example, codecov's bash script is hacked recently.

This supply chain attack affects to CI like Circle CI, GitHub Actions.

GitHub Actions can limit each actions's permissions.

For example, next permissios only allow the action to read repo's content.

permissions:
    contents: read

The default permissions is write-all.
Of course, you can change the default workflow permission of the repository.

So, you need to do following to improve security of GitHub Actions.

  • Change the default permissiont to "Read repository contents permission "
  • Write each actions's permissions to yaml files

However, permissions is optional and it is a little of hard to set. Because, almost actions does not provides permissions guide.

@pkgdeps/update-github-actions-permissions

I've created a tool that update GitHub Actions's permissions automatically.

This tools detect using Actions and add permissions field to your action yaml file.

Requirements: Node.js 14+

You can update your GitHub Actions via following command:

npx @pkgdeps/update-github-actions-permissions ".github/workflows/*.{yaml,yml}"

update-github-actions-permissions result

This tool supports 40+ actions.

If you found missing actions, please submit a pull request.

Related


This content originally appeared on DEV Community and was authored by azu


Print Share Comment Cite Upload Translate Updates
APA

azu | Sciencx (2021-07-21T00:45:45+00:00) How to set GitHub Actions’s `permissions`?. Retrieved from https://www.scien.cx/2021/07/21/how-to-set-github-actionss-permissions/

MLA
" » How to set GitHub Actions’s `permissions`?." azu | Sciencx - Wednesday July 21, 2021, https://www.scien.cx/2021/07/21/how-to-set-github-actionss-permissions/
HARVARD
azu | Sciencx Wednesday July 21, 2021 » How to set GitHub Actions’s `permissions`?., viewed ,<https://www.scien.cx/2021/07/21/how-to-set-github-actionss-permissions/>
VANCOUVER
azu | Sciencx - » How to set GitHub Actions’s `permissions`?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/21/how-to-set-github-actionss-permissions/
CHICAGO
" » How to set GitHub Actions’s `permissions`?." azu | Sciencx - Accessed . https://www.scien.cx/2021/07/21/how-to-set-github-actionss-permissions/
IEEE
" » How to set GitHub Actions’s `permissions`?." azu | Sciencx [Online]. Available: https://www.scien.cx/2021/07/21/how-to-set-github-actionss-permissions/. [Accessed: ]
rf:citation
» How to set GitHub Actions’s `permissions`? | azu | Sciencx | https://www.scien.cx/2021/07/21/how-to-set-github-actionss-permissions/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.