Skip to content

Commit

Permalink
restrict permissions for GitHub actions
Browse files Browse the repository at this point in the history
This commit introduces two changes. First, the actions are changed to only have
read access to repositories. Second, we specify that GitHub should not persist
the authorization token for write access to a repository on disk (see the
option `persist-credentials: false`).
  • Loading branch information
Vincent Mutolo committed May 27, 2021
1 parent 5357329 commit 79cacc5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
- master

name: Code coverage
permissions:
contents: read

jobs:
check:
Expand All @@ -12,6 +14,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/daily_tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: Daily tests
permissions:
contents: read

on:
schedule:
- cron: '0 0 * * *' # Midnight of each day
Expand All @@ -15,6 +18,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Install toolchain
uses: actions-rs/toolchain@v1
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/lints.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
on: [push, pull_request]

name: Lints
permissions:
contents: read

jobs:
lints:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/security_audit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: Security Audit
permissions:
contents: read

on:
push:
# Check immediately if dependencies are altered
Expand All @@ -15,6 +18,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:
# NOTE: Should we use fail-fast: false?

name: Tests
permissions:
contents: read

jobs:
test:
Expand All @@ -30,6 +32,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Install toolchain
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -80,6 +84,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Install toolchain
uses: actions-rs/toolchain@v1
Expand All @@ -103,6 +109,8 @@ jobs:
- nightly
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- uses: actions-rs/toolchain@v1
with:
profile: minimal
Expand All @@ -126,6 +134,8 @@ jobs:
- mips64-unknown-linux-gnuabi64
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
Expand All @@ -148,6 +158,8 @@ jobs:
- wasm32-unknown-unknown
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
Expand All @@ -163,6 +175,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
Expand All @@ -185,6 +199,8 @@ jobs:

steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check ${{ matrix.checks }}

0 comments on commit 79cacc5

Please sign in to comment.