Skip to content

Commit 288c207

Browse files
authored
fix: prevent script injection in workflows (release/v0.12.x) (#632)
Move github.event references to env vars to prevent script injection vulnerabilities in run steps. This change follows the same pattern as the main branch fix. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent d9a55c2 commit 288c207

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

.github/workflows/post-release-version-bump.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
required: true
99

1010
env:
11+
VERSION: ${{ github.event.inputs.version }}
1112
AWS_DEFAULT_REGION: us-east-1
1213

1314
permissions:
@@ -96,9 +97,9 @@ jobs:
9697
9798
- name: Update version to next development version in main
9899
run: |
99-
DEV_VERSION="${{ github.event.inputs.version }}.dev0"
100+
DEV_VERSION="${{ env.VERSION }}.dev0"
100101
sed -i 's/__version__ = ".*"/__version__ = "'$DEV_VERSION'"/' aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py
101-
VERSION="${{ github.event.inputs.version }}"
102+
VERSION="${{ env.VERSION }}"
102103
sed -i 's/python:v.*"/python:v'$VERSION'"/' .github/workflows/daily-scan.yml
103104
git add aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py
104105
git add .github/workflows/daily-scan.yml
@@ -109,7 +110,7 @@ jobs:
109110
env:
110111
GITHUB_TOKEN: ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }}
111112
run: |
112-
DEV_VERSION="${{ github.event.inputs.version }}.dev0"
113+
DEV_VERSION="${{ env.VERSION }}.dev0"
113114
gh pr create --title "Post release $VERSION: Update version to $DEV_VERSION" \
114115
--body "This PR prepares the main branch for the next development cycle by updating the version to $DEV_VERSION and updating the image version to be scanned to the latest released.
115116

.github/workflows/pre-release-prepare.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ on:
1212
default: 'false'
1313

1414
env:
15+
VERSION: ${{ github.event.inputs.version }}
16+
IS_PATCH: ${{ github.event.inputs.is_patch }}
1517
AWS_DEFAULT_REGION: us-east-1
1618

1719
permissions:
@@ -56,7 +58,7 @@ jobs:
5658
5759
- name: Create branches
5860
run: |
59-
IS_PATCH=${{ github.event.inputs.is_patch }}
61+
IS_PATCH=${{ env.IS_PATCH }}
6062
if [[ "$IS_PATCH" != "true" && "$IS_PATCH" != "false" ]]; then
6163
echo "Invalid input for IS_PATCH. Must be 'true' or 'false'."
6264
exit 1
@@ -102,5 +104,5 @@ jobs:
102104
--body "This PR updates the version to ${VERSION}.
103105
104106
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice." \
105-
--head v${{ github.event.inputs.version }}_release \
107+
--head v${{ env.VERSION }}_release \
106108
--base release/v${MAJOR_MINOR}.x

.github/workflows/release-build.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ on:
1111
default: 'us-east-1, us-east-2, us-west-1, us-west-2, ap-south-1, ap-northeast-3, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-northeast-1, ca-central-1, eu-central-1, eu-west-1, eu-west-2, eu-west-3, eu-north-1, sa-east-1, af-south-1, ap-east-1, ap-south-2, ap-southeast-3, ap-southeast-4, eu-central-2, eu-south-1, eu-south-2, il-central-1, me-central-1, me-south-1, ap-southeast-5, ap-southeast-7, mx-central-1, ca-west-1, cn-north-1, cn-northwest-1'
1212

1313
env:
14+
VERSION: ${{ github.event.inputs.version }}
15+
AWS_REGIONS: ${{ github.event.inputs.aws_region }}
1416
AWS_DEFAULT_REGION: us-east-1
1517
AWS_PUBLIC_ECR_REGION: us-east-1
1618
AWS_PRIVATE_ECR_REGION: us-west-2
@@ -82,7 +84,7 @@ jobs:
8284
- name: Set up regions matrix
8385
id: set-matrix
8486
env:
85-
AWS_REGIONS: ${{ github.event.inputs.aws_region }}
87+
AWS_REGIONS: ${{ env.AWS_REGIONS }}
8688
run: |
8789
IFS=',' read -ra REGIONS <<< "$AWS_REGIONS"
8890
MATRIX="["
@@ -191,7 +193,7 @@ jobs:
191193
file: ./Dockerfile
192194
platforms: linux/amd64,linux/arm64
193195
tags: |
194-
${{ env.RELEASE_PUBLIC_REPOSITORY }}:v${{ github.event.inputs.version }}
196+
${{ env.RELEASE_PUBLIC_REPOSITORY }}:v${{ env.VERSION }}
195197
196198
# Publish to private ECR
197199
- name: Build and push private ECR image
@@ -202,7 +204,7 @@ jobs:
202204
file: ./Dockerfile
203205
platforms: linux/amd64,linux/arm64
204206
tags: |
205-
${{ env.RELEASE_PRIVATE_REPOSITORY }}:v${{ github.event.inputs.version }}
207+
${{ env.RELEASE_PRIVATE_REPOSITORY }}:v${{ env.VERSION }}
206208
207209
publish-layer-prod:
208210
runs-on: ubuntu-latest
@@ -450,4 +452,4 @@ jobs:
450452
${{ env.ARTIFACT_NAME }} \
451453
${{ env.ARTIFACT_NAME }}.sha256 \
452454
layer.zip \
453-
layer.zip.sha256
455+
layer.zip.sha256

0 commit comments

Comments
 (0)