Skip to content

Commit 4857672

Browse files
authored
ci: workflow hygiene gaps (permissions scoping, concurrency, persist-credentials) (#290)
- Move write permissions from workflow level to job level in 5 workflows (auto-approve, pr-size, labeler, stale, e2e-nightly) for Scorecard Token-Permissions compliance - Add concurrency group to sign-old-releases.yaml - Add persist-credentials: false to all checkout steps in security.yaml - Upload E2E debug logs as artifact on failure in ci.yaml - Add code_scanning rule with CodeQL to branch ruleset (via API, not in this commit) to block PRs introducing high-severity findings Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent bea26b7 commit 4857672

8 files changed

Lines changed: 39 additions & 7 deletions

File tree

.github/workflows/auto-approve.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77

88
permissions:
99
contents: read
10-
pull-requests: write
1110

1211
concurrency:
1312
group: auto-approve-${{ github.event.pull_request.number || github.run_id }}
@@ -18,6 +17,8 @@ jobs:
1817
name: Auto Approve
1918
runs-on: ubuntu-latest
2019
timeout-minutes: 5
20+
permissions:
21+
pull-requests: write
2122
if: >
2223
github.actor == 'SebTardif' ||
2324
github.actor == 'dependabot[bot]'

.github/workflows/ci.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,15 @@ jobs:
563563
echo "=== Events ==="
564564
kubectl get events -A --sort-by='.lastTimestamp' | tail -50
565565
566+
- name: Upload debug logs on failure
567+
if: failure()
568+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
569+
with:
570+
name: e2e-debug-logs
571+
path: test-results/
572+
retention-days: 7
573+
if-no-files-found: ignore
574+
566575
- name: Cleanup k3d cluster
567576
if: always()
568577
shell: bash -Eeuo pipefail {0}

.github/workflows/e2e-nightly.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ on:
2929

3030
permissions:
3131
contents: read
32-
issues: write
3332

3433
concurrency:
3534
group: e2e-nightly-${{ github.ref }}-${{ github.event_name }}-${{ inputs.k8s-version || 'all' }}-${{ inputs.suite || 'all' }}
@@ -457,6 +456,8 @@ jobs:
457456
name: Nightly Results
458457
runs-on: ${{ vars.RUNNER || 'ubuntu-latest' }}
459458
timeout-minutes: 5
459+
permissions:
460+
issues: write
460461
needs: [test-e2e, fuzz]
461462
if: always() && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
462463
steps:

.github/workflows/labeler.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55

66
permissions:
77
contents: read
8-
pull-requests: write
98

109
concurrency:
1110
group: labeler-${{ github.event.pull_request.number }}
@@ -16,6 +15,9 @@ jobs:
1615
name: Auto-label PR
1716
runs-on: ubuntu-latest
1817
timeout-minutes: 5
18+
permissions:
19+
contents: read
20+
pull-requests: write
1921
steps:
2022
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
2123
with:

.github/workflows/pr-size.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ on:
55

66
permissions:
77
contents: read
8-
pull-requests: write
9-
issues: write
108

119
concurrency:
1210
group: pr-size-${{ github.event.pull_request.number }}
@@ -17,6 +15,10 @@ jobs:
1715
name: Label PR size
1816
runs-on: ubuntu-latest
1917
timeout-minutes: 5
18+
permissions:
19+
contents: read
20+
pull-requests: write
21+
issues: write
2022
steps:
2123
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
2224
with:

.github/workflows/security.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ jobs:
3939
with:
4040
egress-policy: audit
4141
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
42+
with:
43+
persist-credentials: false
4244

4345
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
4446
if: matrix.language == 'go'
@@ -71,6 +73,8 @@ jobs:
7173
with:
7274
egress-policy: audit
7375
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
76+
with:
77+
persist-credentials: false
7478

7579
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
7680
with:
@@ -96,6 +100,8 @@ jobs:
96100
with:
97101
egress-policy: audit
98102
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
103+
with:
104+
persist-credentials: false
99105

100106
- uses: ./.github/actions/setup-clean-docker-config
101107

@@ -118,6 +124,8 @@ jobs:
118124
with:
119125
egress-policy: audit
120126
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
127+
with:
128+
persist-credentials: false
121129

122130
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
123131
with:
@@ -177,6 +185,7 @@ jobs:
177185
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
178186
with:
179187
fetch-depth: 0
188+
persist-credentials: false
180189

181190
- uses: ./.github/actions/install-binary-tool
182191
with:
@@ -206,6 +215,8 @@ jobs:
206215
with:
207216
egress-policy: audit
208217
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
218+
with:
219+
persist-credentials: false
209220
- uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
210221
with:
211222
fail-on-severity: high

.github/workflows/sign-old-releases.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
permissions:
1212
contents: read
1313

14+
concurrency:
15+
group: sign-old-releases
16+
cancel-in-progress: false
17+
1418
jobs:
1519
sign:
1620
name: Sign Releases

.github/workflows/stale.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ on:
66
workflow_dispatch: {}
77

88
permissions:
9-
issues: write
10-
pull-requests: write
9+
contents: read
1110

1211
concurrency:
1312
group: stale
@@ -18,6 +17,9 @@ jobs:
1817
name: Close stale issues and PRs
1918
runs-on: ubuntu-latest
2019
timeout-minutes: 10
20+
permissions:
21+
issues: write
22+
pull-requests: write
2123
steps:
2224
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
2325
with:

0 commit comments

Comments
 (0)