Skip to content

Commit

Permalink
github: Minimize permissions granted to automated workflows / jobs
Browse files Browse the repository at this point in the history
Jobs that use the GITHUB_TOKEN to perform sensitive actions on behalf of
a real user may be granted a range of permissions. Instead of granting
blanket permissions to read and write "all" APIs, we should really limit
the permissions what any individual workflow or job can do.

This commit sets the default permissions for each workflow to "contents:
read", which allows jobs to only read from the repository. The one job
that requires additional permission is our "deploy" job which additionally
requires write access.

Link: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idpermissions
Signed-off-by: Jason Gerecke <[email protected]>
  • Loading branch information
jigpu committed Nov 30, 2023
1 parent 628e301 commit c011b69
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/check-for-sysinfo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: "Check for sysinfo in data files"

on: [ pull_request ]

permissions:
contents: read

jobs:
checksysinfo:
runs-on: ubuntu-22.04
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: "FreeBSD build and test"

on: [ push, pull_request ]

permissions:
contents: read

jobs:
###
#
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: "Build and test"

on: [ push, pull_request ]

permissions:
contents: read

env:
CFLAGS: "-Werror -Wno-error=missing-field-initializers"
UBUNTU_PACKAGES: libgudev-1.0-dev libxml++2.6-dev valgrind tree python3-pip python3-setuptools libevdev-dev
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ on:
branches:
- master

permissions:
contents: read

env:
UBUNTU_PACKAGES: libgudev-1.0-dev libxml++2.6-dev valgrind tree python3-pip python3-setuptools libevdev-dev doxygen
PIP_PACKAGES: meson ninja libevdev pyudev pytest yq

jobs:
deploy:
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/pkginstall
Expand Down

0 comments on commit c011b69

Please sign in to comment.