Skip to content

Commit

Permalink
chore: Set permissions for GitHub actions (#12462)
Browse files Browse the repository at this point in the history
Motivation:

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.

Modifications:

- 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

Result:

Secure GitHub actions

Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
  • Loading branch information
naveensrinivasan committed Mar 29, 2023
1 parent cf5c467 commit ccc5e01
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ on:
env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryhandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=240

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/ci-pr-reports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ on:
env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryhandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=240

permissions:
contents: read

jobs:
tests:
permissions:
actions: read # for dawidd6/action-download-artifact to query and download artifacts
checks: write # for scacap/action-surefire-report to publish result as PR check
pull-requests: read # for dawidd6/action-download-artifact to query commit hash
runs-on: ubuntu-latest
strategy:
fail-fast: false
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 @@ -32,8 +32,15 @@ on:
env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryhandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=240

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/analyze to upload SARIF results
name: Analyze
runs-on: ubuntu-latest

Expand Down

0 comments on commit ccc5e01

Please sign in to comment.