chore: Set permissions for GitHub actions (#3225)

Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much.

- Included permissions for the action. https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions

https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

[Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)

Signed-off-by: nathannaveen <42319948+nathannaveen@users.noreply.github.com>
This commit is contained in:
nathannaveen 2022-05-24 14:07:23 -05:00 committed by Alexandre FLAMENT
parent 7101c5ecf2
commit b5ce39b536
1 changed files with 7 additions and 0 deletions

View File

@ -6,6 +6,9 @@ on:
pull_request: pull_request:
branches: ["master"] branches: ["master"]
permissions:
contents: read
jobs: jobs:
python: python:
name: Python ${{ matrix.python-version }} name: Python ${{ matrix.python-version }}
@ -81,6 +84,8 @@ jobs:
documentation: documentation:
name: Documentation name: Documentation
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
permissions:
contents: write # for JamesIves/github-pages-deploy-action to push changes in repo
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -125,6 +130,8 @@ jobs:
- python - python
- themes - themes
- documentation - documentation
permissions:
contents: write # for make V=1 weblate.push.translations
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2