Skip to content

Commit

Permalink
chore: Set permissions for GitHub actions (#1230)
Browse files Browse the repository at this point in the history
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: naveen <172697+naveensrinivasan@users.noreply.github.com>

Co-authored-by: Todd Leonhardt <todd.leonhardt@gmail.com>
  • Loading branch information
naveensrinivasan and tleonhardt committed Jul 14, 2022
1 parent 755c780 commit 6f53558
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ on:
schedule:
- cron: '0 6 * * 4'

permissions:
contents: read

jobs:
analyze:
permissions:
actions: read # for github/codeql-action/init to get workflow details
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/autobuild to send a status report
name: Analyze
runs-on: ubuntu-latest

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ name: Doc

on: [push, pull_request]

permissions:
contents: read

jobs:
doc:
strategy:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ name: Format

on: [push, pull_request]

permissions:
contents: read

jobs:
lint:
strategy:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ name: Lint

on: [push, pull_request]

permissions:
contents: read

jobs:
lint:
strategy:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ name: MyPy

on: [push, pull_request]

permissions:
contents: read

jobs:
mypy:
strategy:
Expand Down

0 comments on commit 6f53558

Please sign in to comment.