Skip to content

Commit 2277d92

Browse files
Merge pull request #171 from learnsoftwaredevelopment/resolved-github-actions-bug-due-to-new-github-changes
Resolved GitHub actions bug due to new GitHub changes on 1 March 2021
2 parents 27aeee3 + 1e18245 commit 2277d92

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

.github/workflows/app-test-container-no-docker-cache.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,41 @@ on:
55
branches: [master]
66
pull_request:
77
branches: [master]
8+
# Added in response to recent changes by GitHub on 1 March 2021 involving dependabot pull requests running with read only permissions which resulted in by default GitHub secrets are unable to be read.
9+
# References:
10+
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target (Announcement of changes to be made to dependabot pull requests)
11+
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ (Recommended security mitigations by GitHub)
12+
# https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-797125425 (Ongoing GitHub issues by users in response to the changes)
13+
pull_request_target:
14+
branches: [master]
815

916
jobs:
1017
build:
1118
runs-on: ubuntu-latest
1219

1320
timeout-minutes: 18
1421

22+
# If the Pull Request is coming from a fork (pull_request_target), ensure it's opened by "dependabot[bot]". Otherwise, clone it normally.
23+
# References:
24+
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target
25+
# https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-797125425 (dependabot PM recommended solution)
26+
27+
if:
28+
${{ (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') ||
29+
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') }}
30+
1531
steps:
1632
- name: checkout
33+
if: ${{ github.event_name != 'pull_request_target' }}
1734
uses: actions/checkout@v2.3.4
35+
36+
- name: checkout Pull Request (dependabot[bot] only)
37+
if: ${{ github.event_name == 'pull_request_target' }}
38+
uses: actions/checkout@v2.3.4
39+
with:
40+
# Without ref with pull_request_target, it does not actually build the PR, instead it builds the latest changeset from the target repository which is not the intended behaviour. (Reference: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ [Last example])
41+
ref: ${{ github.event.pull_request.head.sha }}
42+
1843
# Pull the latest image to build, and avoid caching pull-only images.
1944
# (docker pull is faster than caching in most cases.)
2045
- name: docker-compose pull

.github/workflows/app-test-container.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,50 @@ on:
55
branches: [master]
66
pull_request:
77
branches: [master]
8+
# Added in response to recent changes by GitHub on 1 March 2021 involving dependabot pull requests running with read only permissions which resulted in by default GitHub secrets are unable to be read.
9+
# References:
10+
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target (Announcement of changes to be made to dependabot pull requests)
11+
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ (Recommended security mitigations by GitHub)
12+
# https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-797125425 (Ongoing GitHub issues by users in response to the changes)
13+
pull_request_target:
14+
branches: [master]
815

916
jobs:
1017
build:
1118
runs-on: ubuntu-latest
1219

1320
timeout-minutes: 18
1421

22+
# If the Pull Request is coming from a fork (pull_request_target), ensure it's opened by "dependabot[bot]". Otherwise, clone it normally.
23+
# References:
24+
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target
25+
# https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-797125425 (dependabot PM recommended solution)
26+
27+
if:
28+
${{ (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') ||
29+
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') }}
30+
1531
steps:
1632
- name: checkout
33+
if: ${{ github.event_name != 'pull_request_target' }}
34+
uses: actions/checkout@v2.3.4
35+
36+
- name: checkout Pull Request (dependabot[bot] only)
37+
if: ${{ github.event_name == 'pull_request_target' }}
1738
uses: actions/checkout@v2.3.4
39+
with:
40+
# Without ref with pull_request_target, it does not actually build the PR, instead it builds the latest changeset from the target repository which is not the intended behaviour. (Reference: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ [Last example])
41+
ref: ${{ github.event.pull_request.head.sha }}
42+
1843
# Pull the latest image to build, and avoid caching pull-only images.
1944
# (docker pull is faster than caching in most cases.)
2045
- name: docker-compose pull
2146
run: docker-compose pull
47+
2248
- name: docker layer caching
2349
uses: satackey/action-docker-layer-caching@v0.0.11
2450
continue-on-error: true
51+
2552
- name: Run test in container
2653
shell: bash
2754
env:

.github/workflows/node.js.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
33
# Addition of Cache Action
44

5+
## TODO: Add mitigations for GitHub Actions dependabot read only changes which resulted in GitHub Secrets cannot be read.
6+
## References:
7+
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target (Announcement of changes to be made to dependabot pull requests)
8+
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ (Recommended security mitigations by GitHub)
9+
# https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-797125425 (Ongoing GitHub issues by users in response to the changes)
10+
511
name: Node.js CI
612

713
on:

0 commit comments

Comments
 (0)