Skip to content

Commit

Permalink
.github: harden permissions on GH workflows
Browse files Browse the repository at this point in the history
None of the GH workflows need the GITHUB_TOKEN to have write
permissions for all scopes. This commit hardens the access values for
each GH workflow accordingly their needs.

Signed-off-by: André Martins <andre@cilium.io>
  • Loading branch information
aanm committed Jul 19, 2021
1 parent 6cf9eaa commit 4286608
Show file tree
Hide file tree
Showing 21 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-images-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:
- images/runtime/**
- images/builder/**

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-images-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:
branches:
- master

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-images-hotfixes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
branches:
- hf/master/**

permissions: read-all

jobs:
build-and-push:
if: ${{ github.repository == 'cilium/cilium' }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-images-releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+

permissions: read-all

jobs:
build-and-push:
if: ${{ github.repository == 'cilium/cilium' }}
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/conformance-aks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ on:
# pull_request: {}
###

# By specifying the access of one of the scopes, all of those that are not
# specified are set to 'none'.
permissions:
# So that Sibz/github-status-action can write into the status API
statuses: write

concurrency:
# Structure:
# - Workflow name
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/conformance-aws-cni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ on:
# pull_request: {}
###

# By specifying the access of one of the scopes, all of those that are not
# specified are set to 'none'.
permissions:
# So that Sibz/github-status-action can write into the status API
statuses: write

concurrency:
# Structure:
# - Workflow name
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/conformance-eks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ on:
# pull_request: {}
###

# By specifying the access of one of the scopes, all of those that are not
# specified are set to 'none'.
permissions:
# So that Sibz/github-status-action can write into the status API
statuses: write

concurrency:
# Structure:
# - Workflow name
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/conformance-gke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ on:
# pull_request: {}
###

# By specifying the access of one of the scopes, all of those that are not
# specified are set to 'none'.
permissions:
# So that Sibz/github-status-action can write into the status API
statuses: write

concurrency:
# Structure:
# - Workflow name
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/conformance-k8s-network-policies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
# run once a day at midnight
- cron: '0 0 * * *'

permissions: read-all

env:
KIND_VERSION: v0.11.1
KIND_CONFIG: .github/kind-config.yaml
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/conformance-kind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ on:
- 'Documentation/**'
- 'test/**'

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/conformance-multicluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ on:
# pull_request: {}
###

# By specifying the access of one of the scopes, all of those that are not
# specified are set to 'none'.
permissions:
# So that Sibz/github-status-action can write into the status API
statuses: write

concurrency:
# Structure:
# - Workflow name
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
branches:
- master

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/lint-bpf-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
branches:
- master

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/lint-build-commits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: build-commits
# Any change in triggers needs to be reflected in the concurrency group.
on: [pull_request]

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/lint-codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
schedule:
- cron: "45 6 * * 3"

permissions: read-all

jobs:
check_changes:
name: Deduce required tests from code changes
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/lint-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
branches:
- master

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/lint-images-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:
branches:
- master

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests-l4lb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ on:
# pull_request: {}
###

permissions: read-all

concurrency:
# Structure:
# - Workflow name
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Nightly
on:
schedule:
- cron: '0 2 * * *' # run at 2 AM UTC

permissions: read-all

jobs:
policy-stress-test:
name: Start Nightly Policy Stress tests
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests-smoke-ipv6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
branches:
- master

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests-smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
branches:
- master

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true
Expand Down

0 comments on commit 4286608

Please sign in to comment.