Skip to content

Commit b997f22

Browse files
committed
Declare permissions
Repositories can be configured with Default access (restricted) https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token Best practice says that workflows should declare the minimal permissions they require. Without declaring permissions, paranoid forks fail miserably.
1 parent aeae208 commit b997f22

30 files changed

+110
-0
lines changed

Diff for: .github/workflows/check-change-note.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Check change note
22

3+
permissions:
4+
pull-requests: read
5+
36
on:
47
pull_request_target:
58
types: [labeled, unlabeled, opened, synchronize, reopened, ready_for_review]

Diff for: .github/workflows/check-implicit-this.yml

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
- main
1010
- "rc/*"
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
check:
1417
runs-on: ubuntu-latest

Diff for: .github/workflows/check-qldoc.yml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
- main
1111
- "rc/*"
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
1417
qldoc:
1518
runs-on: ubuntu-latest

Diff for: .github/workflows/check-query-ids.yml

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
- "rc/*"
1212
workflow_dispatch:
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
check:
1619
name: Check query IDs

Diff for: .github/workflows/close-stale.yml

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
schedule:
66
- cron: "30 1 * * *"
77

8+
permissions:
9+
issues: write
10+
811
jobs:
912
stale:
1013
if: github.repository == 'github/codeql'

Diff for: .github/workflows/compile-queries.yml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
- "codeql-cli-*"
99
pull_request:
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
compile-queries:
1316
runs-on: ubuntu-latest-xl

Diff for: .github/workflows/csharp-qltest.yml

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ defaults:
2525
run:
2626
working-directory: csharp
2727

28+
permissions:
29+
contents: read
30+
security-events: read
31+
2832
jobs:
2933
qlupgrade:
3034
runs-on: ubuntu-latest
@@ -51,6 +55,9 @@ jobs:
5155
fail-fast: false
5256
matrix:
5357
slice: ["1/2", "2/2"]
58+
permissions:
59+
contents: read
60+
security-events: write
5461
steps:
5562
- uses: actions/checkout@v4
5663
- uses: ./csharp/actions/create-extractor-pack

Diff for: .github/workflows/csv-coverage-metrics.yml

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ on:
1414
- ".github/workflows/csv-coverage-metrics.yml"
1515
- ".github/actions/fetch-codeql/action.yml"
1616

17+
permissions:
18+
contents: read
19+
security-events: write
20+
1721
jobs:
1822
publish-java:
1923
runs-on: ubuntu-latest

Diff for: .github/workflows/csv-coverage-pr-artifacts.yml

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ on:
1919
- main
2020
- "rc/*"
2121

22+
permissions:
23+
contents: read
24+
pull-requests: read
25+
2226
jobs:
2327
generate:
2428
name: Generate framework coverage artifacts

Diff for: .github/workflows/csv-coverage-pr-comment.yml

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
types:
77
- completed
88

9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
913
jobs:
1014
check:
1115
name: Check framework coverage differences and comment

Diff for: .github/workflows/csv-coverage-timeseries.yml

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: Build framework coverage timeseries reports
33
on:
44
workflow_dispatch:
55

6+
permissions:
7+
contents: read
8+
69
jobs:
710
build:
811
runs-on: ubuntu-latest

Diff for: .github/workflows/csv-coverage-update.yml

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
schedule:
66
- cron: "0 0 * * *"
77

8+
permissions:
9+
contents: read
10+
security-events: write
11+
812
jobs:
913
update:
1014
name: Update framework coverage report

Diff for: .github/workflows/csv-coverage.yml

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
description: "github/codeql repo SHA used for looking up the CSV models"
88
required: false
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
1114
build:
1215
runs-on: ubuntu-latest

Diff for: .github/workflows/fast-forward.yml

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ name: Fast-forward tracking branch for selected CodeQL version
77
on:
88
workflow_dispatch:
99

10+
permissions:
11+
contents: write
12+
1013
jobs:
1114
fast-forward:
1215
name: Fast-forward tracking branch for selected CodeQL version

Diff for: .github/workflows/go-tests-other-os.yml

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
- codeql-workspace.yml
1010
env:
1111
GO_VERSION: '~1.21.0'
12+
13+
permissions:
14+
contents: read
15+
1216
jobs:
1317
test-mac:
1418
name: Test MacOS

Diff for: .github/workflows/go-tests.yml

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ on:
1717
- codeql-workspace.yml
1818
env:
1919
GO_VERSION: '~1.21.0'
20+
21+
permissions:
22+
contents: read
23+
2024
jobs:
2125
test-linux:
2226
name: Test Linux (Ubuntu)

Diff for: .github/workflows/labeler.yml

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: "Pull Request Labeler"
22
on:
33
- pull_request_target
44

5+
permissions:
6+
contents: read
7+
pull-requests: write
8+
59
jobs:
610
triage:
711
permissions:

Diff for: .github/workflows/mad_regenerate-models.yml

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
- ".github/workflows/mad_regenerate-models.yml"
1212
- ".github/actions/fetch-codeql/action.yml"
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
regenerate-models:
1619
runs-on: ubuntu-latest

Diff for: .github/workflows/ql-for-ql-build.yml

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
env:
1010
CARGO_TERM_COLOR: always
1111

12+
permissions:
13+
contents: read
14+
security-events: read
15+
1216
jobs:
1317
analyze:
1418
runs-on: ubuntu-latest-xl

Diff for: .github/workflows/ql-for-ql-dataset_measure.yml

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
- ql/ql/src/ql.dbscheme
1212
workflow_dispatch:
1313

14+
permissions:
15+
contents: read
16+
security-events: read
17+
1418
jobs:
1519
measure:
1620
env:

Diff for: .github/workflows/ql-for-ql-tests.yml

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ on:
1717
env:
1818
CARGO_TERM_COLOR: always
1919

20+
permissions:
21+
contents: read
22+
security-events: write
23+
2024
jobs:
2125
qltest:
2226
runs-on: ubuntu-latest

Diff for: .github/workflows/query-list.yml

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ on:
1313
- '.github/actions/fetch-codeql/action.yml'
1414
- 'misc/scripts/generate-code-scanning-query-list.py'
1515

16+
permissions:
17+
contents: read
18+
security-events: read
19+
1620
jobs:
1721
build:
1822

Diff for: .github/workflows/ruby-build.yml

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ defaults:
3232
run:
3333
working-directory: ruby
3434

35+
permissions:
36+
contents: read
37+
3538
jobs:
3639
build:
3740
strategy:

Diff for: .github/workflows/ruby-dataset-measure.yml

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ on:
1717
- .github/workflows/ruby-dataset-measure.yml
1818
workflow_dispatch:
1919

20+
permissions:
21+
contents: read
22+
security-events: read
23+
2024
jobs:
2125
measure:
2226
env:

Diff for: .github/workflows/ruby-qltest.yml

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ defaults:
2929
run:
3030
working-directory: ruby
3131

32+
permissions:
33+
contents: read
34+
security-events: read
35+
3236
jobs:
3337
qlupgrade:
3438
runs-on: ubuntu-latest

Diff for: .github/workflows/swift.yml

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ on:
3333
- rc/*
3434
- codeql-cli-*
3535

36+
permissions:
37+
contents: read
38+
security-events: read
39+
3640
jobs:
3741
# not using a matrix as you cannot depend on a specific job in a matrix, and we want to start linux checks
3842
# without waiting for the macOS build

Diff for: .github/workflows/sync-files.yml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
- main
1111
- 'rc/*'
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
1417
sync:
1518
runs-on: ubuntu-latest

Diff for: .github/workflows/tree-sitter-extractor-test.yml

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ defaults:
2323
run:
2424
working-directory: shared/tree-sitter-extractor
2525

26+
permissions:
27+
contents: read
28+
2629
jobs:
2730
test:
2831
runs-on: ubuntu-latest

Diff for: .github/workflows/validate-change-notes.yml

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ on:
1515
- ".github/workflows/validate-change-notes.yml"
1616
- ".github/actions/fetch-codeql/action.yml"
1717

18+
permissions:
19+
contents: read
20+
security-events: write
21+
1822
jobs:
1923
check-change-note:
2024
runs-on: ubuntu-latest

Diff for: csharp/actions/create-extractor-pack/action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Build C# CodeQL pack
22
description: Builds the C# CodeQL pack
3+
4+
# permissions:
5+
# security-events: read
6+
37
runs:
48
using: composite
59
steps:

0 commit comments

Comments
 (0)