Skip to content

Commit c9f835d

Browse files
Security updates for versions update and check scripts (#784)
- Limit permissions of who can execute version update script - Always checkout version update script from main to prevent script injection Signed-off-by: Kate Goldenring <kate.goldenring@fermyon.com>
1 parent 4fe2f18 commit c9f835d

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

.github/workflows/check-versioning.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ jobs:
5959
with:
6060
persist-credentials: false
6161

62+
# Security: Checkout the trusted version.sh from main branch to prevent script injection
63+
- if: startsWith(github.event_name, 'pull_request')
64+
name: Checkout version.sh from main branch
65+
run: |
66+
git fetch origin main
67+
git checkout origin/main -- version.sh
68+
chmod +x version.sh
69+
6270
# Only run version check for PRs. If PR does NOT have "same version" label, then ensure that
6371
# version.txt is different from what is in main.
6472
- if: startsWith(github.event_name, 'pull_request') && !contains(github.event.pull_request.labels.*.name, 'same version')

.github/workflows/update-versions.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
})
3131
3232
build:
33-
if: ${{ github.event.issue.pull_request }} && contains(github.event.comment.body, '/version')
33+
if: github.event.issue.pull_request && contains(github.event.comment.body, '/version') && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER')
3434
runs-on: ubuntu-latest
3535

3636
steps:
@@ -57,7 +57,14 @@ jobs:
5757
with:
5858
repository: ${{ fromJSON(steps.get-pr.outputs.result).head.repo.full_name }}
5959
ref: ${{ fromJSON(steps.get-pr.outputs.result).head.ref }}
60-
60+
61+
# Security: Checkout the trusted version.sh from main branch to prevent script injection
62+
- name: Checkout version.sh from main branch
63+
run: |
64+
git fetch origin main
65+
git checkout origin/main -- version.sh
66+
chmod +x version.sh
67+
6168
- name: Update version minor
6269
if: contains(github.event.comment.body, '/version minor')
6370
run: |

0 commit comments

Comments
 (0)