Skip to content

Commit a574b6f

Browse files
authored
fix: prevent script injection in workflows (release/v0.1.x) (#616)
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 855b5ec commit a574b6f

3 files changed

Lines changed: 19 additions & 12 deletions

File tree

.github/workflows/post_release_version_bump.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ permissions:
1111
contents: write
1212
pull-requests: write
1313

14+
env:
15+
VERSION: ${{ github.event.inputs.version }}
16+
1417
jobs:
1518
check-version:
1619
runs-on: ubuntu-latest
@@ -77,9 +80,9 @@ jobs:
7780
7881
- name: Update version to next development version in main
7982
run: |
80-
DEV_VERSION="${{ github.event.inputs.version }}.dev0"
83+
DEV_VERSION="${{ env.VERSION }}.dev0"
8184
sed -i 's/__version__ = ".*"/__version__ = "'$DEV_VERSION'"/' aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py
82-
VERSION="${{ github.event.inputs.version }}"
85+
VERSION="${{ env.VERSION }}"
8386
sed -i 's/python:v.*"/python:v'$VERSION'"/' .github/workflows/released_image_scan.yml
8487
git add aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py
8588
git add .github/workflows/released_image_scan.yml
@@ -90,7 +93,7 @@ jobs:
9093
env:
9194
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9295
run: |
93-
DEV_VERSION="${{ github.event.inputs.version }}.dev0"
96+
DEV_VERSION="${{ env.VERSION }}.dev0"
9497
gh pr create --title "Post release $VERSION: Update version to $DEV_VERSION" \
9598
--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.
9699

.github/workflows/pre_release_prepare.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ permissions:
1515
contents: write
1616
pull-requests: write
1717

18+
env:
19+
VERSION: ${{ github.event.inputs.version }}
20+
IS_PATCH: ${{ github.event.inputs.is_patch }}
1821

1922
jobs:
2023
update-version-and-create-pr:
@@ -37,7 +40,7 @@ jobs:
3740
3841
- name: Create branches
3942
run: |
40-
IS_PATCH=${{ github.event.inputs.is_patch }}
43+
IS_PATCH=${{ env.IS_PATCH }}
4144
if [[ "$IS_PATCH" != "true" && "$IS_PATCH" != "false" ]]; then
4245
echo "Invalid input for IS_PATCH. Must be 'true' or 'false'."
4346
exit 1
@@ -83,5 +86,5 @@ jobs:
8386
--body "This PR updates the version to ${VERSION}.
8487
8588
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice." \
86-
--head ${{ github.event.inputs.version }}_release \
89+
--head ${{ env.VERSION }}_release \
8790
--base release/${MAJOR_MINOR}.x

.github/workflows/release_build.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ env:
1414
RELEASE_PRIVATE_REPOSITORY: 020628701572.dkr.ecr.us-west-2.amazonaws.com/adot-autoinstrumentation-python
1515
RELEASE_PRIVATE_REGISTRY: 020628701572.dkr.ecr.us-west-2.amazonaws.com
1616
PACKAGE_NAME: aws-opentelemetry-distro
17+
VERSION: ${{ env.VERSION }}
1718

1819
permissions:
1920
id-token: write
@@ -88,15 +89,15 @@ jobs:
8889
TWINE_USERNAME: '__token__'
8990
TWINE_PASSWORD: ${{ env.TEST_PYPI_TOKEN_API_TOKEN }}
9091
run: |
91-
twine upload --repository testpypi --skip-existing --verbose dist/aws_opentelemetry_distro-${{ github.event.inputs.version }}-py3-none-any.whl
92+
twine upload --repository testpypi --skip-existing --verbose dist/aws_opentelemetry_distro-${{ env.VERSION }}-py3-none-any.whl
9293
9394
# Publish to prod PyPI
9495
- name: Publish to PyPI
9596
env:
9697
TWINE_USERNAME: '__token__'
9798
TWINE_PASSWORD: ${{ env.PROD_PYPI_TOKEN_API_TOKEN }}
9899
run: |
99-
twine upload --skip-existing --verbose dist/aws_opentelemetry_distro-${{ github.event.inputs.version }}-py3-none-any.whl
100+
twine upload --skip-existing --verbose dist/aws_opentelemetry_distro-${{ env.VERSION }}-py3-none-any.whl
100101
101102
# Publish to public ECR
102103
- name: Build and push public ECR image
@@ -107,7 +108,7 @@ jobs:
107108
file: ./Dockerfile
108109
platforms: linux/amd64,linux/arm64
109110
tags: |
110-
${{ env.RELEASE_PUBLIC_REPOSITORY }}:v${{ github.event.inputs.version }}
111+
${{ env.RELEASE_PUBLIC_REPOSITORY }}:v${{ env.VERSION }}
111112
112113
# Publish to private ECR
113114
- name: Build and push private ECR image
@@ -118,7 +119,7 @@ jobs:
118119
file: ./Dockerfile
119120
platforms: linux/amd64,linux/arm64
120121
tags: |
121-
${{ env.RELEASE_PRIVATE_REPOSITORY }}:v${{ github.event.inputs.version }}
122+
${{ env.RELEASE_PRIVATE_REPOSITORY }}:v${{ env.VERSION }}
122123
123124
# Publish to GitHub releases
124125
- name: Create GH release
@@ -127,7 +128,7 @@ jobs:
127128
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
128129
run: |
129130
gh release create --target "$GITHUB_REF_NAME" \
130-
--title "Release v${{ github.event.inputs.version }}" \
131+
--title "Release v${{ env.VERSION }}" \
131132
--draft \
132-
"v${{ github.event.inputs.version }}" \
133-
dist/aws_opentelemetry_distro-${{ github.event.inputs.version }}-py3-none-any.whl
133+
"v${{ env.VERSION }}" \
134+
dist/aws_opentelemetry_distro-${{ env.VERSION }}-py3-none-any.whl

0 commit comments

Comments
 (0)