Skip to content

Commit

Permalink
Set permissions for GitHub actions (#2232)
Browse files Browse the repository at this point in the history
- 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/)

 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.

Signed-off-by: naveensrinivasan <[email protected]>

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
naveensrinivasan and github-actions[bot] authored May 3, 2022
1 parent b677b38 commit 5eaa2c9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
push:
branches:
- master
permissions:
contents: read

jobs:
benchmark:
name: Benchmark ${{ matrix.project }} | PARALLEL= ${{ matrix.parallel }}
Expand Down Expand Up @@ -66,6 +69,8 @@ jobs:
path: gauge-benchmarks/out

publish-benchmark:
permissions:
contents: write # for Git to git push
name: Publish Benchmark
runs-on: ubuntu-latest
needs: [ benchmark ]
Expand Down
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 21 * * 5'

permissions:
contents: read

jobs:
analyse:
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: Analyse
runs-on: ubuntu-latest

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ on:
- master
- main
pull_request:
permissions:
contents: read

jobs:
golangci:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
name: lint
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Deploy

on: deployment

permissions:
contents: read

jobs:
package:
if: github.event.deployment.environment == 'production'
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
pull_request:
branches:
- master
permissions:
contents: read

jobs:
tests:
name: UTs ${{ matrix.os }}
Expand Down

0 comments on commit 5eaa2c9

Please sign in to comment.