Skip to content

Commit 4eff8b9

Browse files
potiukagupta01
authored andcommitted
Add explicit permissions for all workflow-run workflows (apache#45548)
Those workflows inherit permissions from the calling workflows but it's good to add explicit permissions to indicate what is needed and in case we will also use the workflows for other purposes in the future - default permissions for older repos might be write so it's best to be explicit about the permissions. Found by CodeQL scanning
1 parent 1cf1c78 commit 4eff8b9

20 files changed

+45
-6
lines changed

Diff for: .github/workflows/additional-ci-image-checks.yml

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ on: # yamllint disable-line rule:truthy
8484
description: "Whether to use uv to build the image (true/false)"
8585
required: true
8686
type: string
87+
permissions:
88+
contents: read
8789
jobs:
8890
# Push early BuildX cache to GitHub Registry in Apache repository, This cache does not wait for all the
8991
# tests to complete - it is run very early in the build process for "main" merges in order to refresh

Diff for: .github/workflows/additional-prod-image-tests.yml

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ on: # yamllint disable-line rule:truthy
6060
description: "Whether to use uv"
6161
required: true
6262
type: string
63+
permissions:
64+
contents: read
6365
jobs:
6466
prod-image-extra-checks-main:
6567
name: PROD image extra checks (main)

Diff for: .github/workflows/automatic-backport.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ on: # yamllint disable-line rule:truthy
2121
push:
2222
branches:
2323
- main
24-
24+
permissions:
25+
contents: read
2526
jobs:
2627
get-pr-info:
2728
name: "Get PR information"

Diff for: .github/workflows/backport-cli.yml

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ on: # yamllint disable-line rule:truthy
4141
type: string
4242

4343
permissions:
44+
# Those permissions are only active for workflow dispatch (only committers can trigger it) and workflow call
45+
# Which is triggered automatically by "automatic-backport" push workflow (only when merging by committer)
46+
# Branch protection prevents from pushing to the "code" branches
4447
contents: write
4548
pull-requests: write
4649
jobs:

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

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ on: # yamllint disable-line rule:truthy
6060
description: "Whether to use uv in the image"
6161
required: true
6262
type: string
63+
permissions:
64+
contents: read
6365
jobs:
6466
run-breeze-tests:
6567
timeout-minutes: 10

Diff for: .github/workflows/ci-image-build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ on: # yamllint disable-line rule:truthy
9696
description: "Disable airflow repo cache read from main."
9797
required: true
9898
type: string
99+
permissions:
100+
contents: read
99101
jobs:
100102
build-ci-images:
101103
strategy:

Diff for: .github/workflows/ci-image-checks.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ on: # yamllint disable-line rule:truthy
108108
description: "Whether to use uv to build the image (true/false)"
109109
required: true
110110
type: string
111-
111+
permissions:
112+
contents: read
112113
jobs:
113114
install-pre-commit:
114115
timeout-minutes: 5

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

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ on: # yamllint disable-line rule:truthy
7676
description: "Whether to debug resources or not (true/false)"
7777
required: true
7878
type: string
79+
permissions:
80+
contents: read
7981
jobs:
8082
update-constraints:
8183
runs-on: ${{ fromJSON(inputs.runs-on-as-json-public) }}

Diff for: .github/workflows/generate-constraints.yml

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ on: # yamllint disable-line rule:truthy
4444
description: "Whether to use uvloop (true/false)"
4545
required: true
4646
type: string
47+
permissions:
48+
# This permission is only active for "canary" builds and PRs from the main repo
49+
# All fork PRs are not allowed to have write permissions and this one is automatically downgraded to read
50+
# Branch protection also prevents from pushing to the "code" branches so we can safely use this one to
51+
# Push constraints to "constraints" branches which are non-code branches and are not protected
52+
contents: write
4753
jobs:
4854
generate-constraints:
4955
permissions:

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

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ on: # yamllint disable-line rule:truthy
4040
description: "Whether to use uvloop (true/false)"
4141
required: true
4242
type: string
43+
permissions:
44+
contents: read
4345
jobs:
4446
tests-helm:
4547
timeout-minutes: 80

Diff for: .github/workflows/integration-system-tests.yml

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ on: # yamllint disable-line rule:truthy
6464
description: "Whether to use uv"
6565
required: true
6666
type: string
67+
permissions:
68+
contents: read
6769
jobs:
6870
tests-core-integration:
6971
timeout-minutes: 130

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

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ on: # yamllint disable-line rule:truthy
4848
description: "Whether to debug resources"
4949
required: true
5050
type: string
51+
permissions:
52+
contents: read
5153
jobs:
5254
tests-kubernetes:
5355
timeout-minutes: 60

Diff for: .github/workflows/news-fragment.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ name: CI
2121
on: # yamllint disable-line rule:truthy
2222
pull_request:
2323
types: [labeled, unlabeled, opened, reopened, synchronize]
24-
24+
permissions:
25+
contents: read
2526
jobs:
2627
check-news-fragment:
2728
name: Check News Fragment

Diff for: .github/workflows/prod-image-build.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ on: # yamllint disable-line rule:truthy
116116
description: "Whether this is a prod-image build (true/false)"
117117
required: true
118118
type: string
119+
permissions:
120+
contents: read
119121
jobs:
120-
121122
build-prod-packages:
122123
name: "Build Airflow and provider packages"
123124
timeout-minutes: 10

Diff for: .github/workflows/prod-image-extra-checks.yml

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ on: # yamllint disable-line rule:truthy
6464
description: "Disable airflow repo cache read from main."
6565
required: true
6666
type: string
67+
permissions:
68+
contents: read
6769
jobs:
6870
myssql-client-image:
6971
uses: ./.github/workflows/prod-image-build.yml

Diff for: .github/workflows/push-image-cache.yml

+2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ on: # yamllint disable-line rule:truthy
8080
description: "Disable airflow repo cache read from main."
8181
required: true
8282
type: string
83+
permissions:
84+
contents: read
8385
jobs:
8486
push-ci-image-cache:
8587
name: "Push CI ${{ inputs.cache-type }}:${{ matrix.python }} image cache "

Diff for: .github/workflows/run-unit-tests.yml

+2
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ on: # yamllint disable-line rule:truthy
116116
description: "Whether to use uv"
117117
required: true
118118
type: string
119+
permissions:
120+
contents: read
119121
jobs:
120122
tests:
121123
timeout-minutes: 120

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ on: # yamllint disable-line rule:truthy
8080
description: "Whether to use uv or not (true/false)"
8181
required: true
8282
type: string
83-
83+
permissions:
84+
contents: read
8485
jobs:
8586
tests-min-sqlalchemy:
8687
name: "Min SQLAlchemy test"

Diff for: .github/workflows/task-sdk-tests.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ on: # yamllint disable-line rule:truthy
4444
description: "Whether this is a canary run (true/false)"
4545
required: true
4646
type: string
47-
47+
permissions:
48+
contents: read
4849
jobs:
4950
task-sdk-tests:
5051
timeout-minutes: 80

Diff for: .github/workflows/test-provider-packages.yml

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ on: # yamllint disable-line rule:truthy
6262
description: "Whether to use uv"
6363
required: true
6464
type: string
65+
permissions:
66+
contents: read
6567
jobs:
6668
prepare-install-verify-provider-packages:
6769
timeout-minutes: 80

0 commit comments

Comments
 (0)