Skip to content

Commit 9de7121

Browse files
committed
Update GHA GITHUB_TOKEN Permissions
Why these changes are being introduced: There is a potential conflict between GITHUB_TOKEN permissions declared in a caller workflow (like this) and the shared workflow that is being called. After testing various combinations, the end result is as simple as setting the correct GITHUB_TOKEN permissions in the shared workflow and not declaring any permissions in the calling workflow. If there is some need to declare GITHUB_TOKEN permissions in the calling workflow, they MUST match the permissions in the shared workflow. Since checkov will throw a warning if no permissions are declared at all there is a checkov:skip comment in the caller workflow. Sadly, for an unknown reason, checkov doesn't register this skip comment and still shows a warning. How this addresses that need: * Remove all permissions declared in the caller workflows * Add a checkov:skip comment in the workflows, even though it doesn't properly work (this at least lets any future developer know that there is a good reason for not having a permissions statement in the yaml) Side effects of this change: None. Related Jira Tickets: * https://mitlibraries.atlassian.net/browse/IR-238
1 parent d847de6 commit 9de7121

File tree

3 files changed

+15
-34
lines changed

3 files changed

+15
-34
lines changed

.github/workflows/dev-build.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
### This is the Terraform-generated dev-build.yml workflow for the ###
22
### docker-matomo-dev app repository. ###
3-
### If this is a Lambda repo, uncomment the FUNCTION line at the end of the ###
4-
### document. If the container requires any additional pre-build commands, ###
5-
### uncomment and edit the PREBUILD line at the end of the document. ###
63
name: Dev Container Build and Deploy
4+
5+
# checkov:skip=CKV2_GHA_1:The shared workflow contains the permissions constraints
6+
# NOTE: The above checkov skip command doesn't actually work and this workflow
7+
# will always show a checkov warning.
78
on:
89
workflow_dispatch:
910
pull_request:
@@ -12,21 +13,12 @@ on:
1213
paths-ignore:
1314
- '.github/**'
1415

15-
permissions: read-all
16-
1716
jobs:
1817
deploy:
19-
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
20-
permissions:
21-
id-token: write
22-
contents: read
23-
2418
name: Dev Container Deploy
25-
uses: mitlibraries/.github/.github/workflows/ecr-shared-deploy-dev.yml@main
19+
uses: mitlibraries/.github/.github/workflows/ecr-shared-deploy-dev.yml@INFRA-526
2620
secrets: inherit
2721
with:
2822
AWS_REGION: "us-east-1"
2923
GHA_ROLE: "docker-matomo-gha-dev"
3024
ECR: "docker-matomo-dev"
31-
# FUNCTION: ""
32-
# PREBUILD:

.github/workflows/prod-promote.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
### This is the Terraform-generated prod-promote.yml workflow for the ###
22
### docker-matomo-prod repository. ###
3-
### If this is a Lambda repo, uncomment the FUNCTION line at the end of the ###
4-
### document. ###
3+
54
name: Prod Container Promote
5+
# checkov:skip=CKV2_GHA_1:The shared workflow contains the permissions constraints
6+
# NOTE: The above checkov skip command doesn't actually work and this workflow
7+
# will always show a checkov warning.
8+
69
on:
710
workflow_dispatch:
811
release:
912
types: [published]
1013

11-
permissions: read-all
12-
1314
jobs:
1415
deploy:
15-
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
16-
permissions:
17-
id-token: write
18-
contents: read
19-
2016
name: Prod Container Promote
2117
uses: mitlibraries/.github/.github/workflows/ecr-shared-promote-prod.yml@main
2218
secrets: inherit

.github/workflows/stage-build.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
### This is the Terraform-generated dev-build.yml workflow for the ###
22
### docker-matomo-stage app repository. ###
3-
### If this is a Lambda repo, uncomment the FUNCTION line at the end of the ###
4-
### document. If the container requires any additional pre-build commands, ###
5-
### uncomment and edit the PREBUILD line at the end of the document. ###
63
name: Stage Container Build and Deploy
4+
# checkov:skip=CKV2_GHA_1:The shared workflow contains the permissions constraints
5+
# NOTE: The above checkov skip command doesn't actually work and this workflow
6+
# will always show a checkov warning.
7+
78
on:
89
workflow_dispatch:
910
push:
@@ -12,21 +13,13 @@ on:
1213
paths-ignore:
1314
- '.github/**'
1415

15-
permissions: read-all
16-
1716
jobs:
1817
deploy:
19-
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
20-
permissions:
21-
id-token: write
22-
contents: read
23-
2418
name: Stage Container Deploy
2519
uses: mitlibraries/.github/.github/workflows/ecr-shared-deploy-stage.yml@main
2620
secrets: inherit
2721
with:
2822
AWS_REGION: "us-east-1"
2923
GHA_ROLE: "docker-matomo-gha-stage"
3024
ECR: "docker-matomo-stage"
31-
# FUNCTION: ""
32-
# PREBUILD:
25+

0 commit comments

Comments
 (0)