Skip to content

Commit 95fbfd8

Browse files
authored
fix: prevent script injection in workflows (release/v0.0.x) (#615)
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 7a49fca commit 95fbfd8

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

.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: ${{ github.event.inputs.version }}
1718

1819
permissions:
1920
id-token: write
@@ -95,7 +96,7 @@ jobs:
9596
TWINE_USERNAME: '__token__'
9697
TWINE_PASSWORD: ${{ env.TEST_PYPI_TOKEN_API_TOKEN }}
9798
run: |
98-
twine upload --repository testpypi --skip-existing --verbose dist/aws_opentelemetry_distro-${{ github.event.inputs.version }}-py3-none-any.whl
99+
twine upload --repository testpypi --skip-existing --verbose dist/aws_opentelemetry_distro-${{ env.VERSION }}-py3-none-any.whl
99100
100101
# The following step publish to ECR
101102
- name: Build and push images
@@ -106,24 +107,24 @@ jobs:
106107
file: ./Dockerfile
107108
platforms: linux/amd64,linux/arm64
108109
tags: |
109-
${{ env.RELEASE_PRIVATE_REPOSITORY }}:v${{ github.event.inputs.version }}
110-
${{ env.RELEASE_PUBLIC_REPOSITORY }}:v${{ github.event.inputs.version }}
110+
${{ env.RELEASE_PRIVATE_REPOSITORY }}:v${{ env.VERSION }}
111+
${{ env.RELEASE_PUBLIC_REPOSITORY }}:v${{ env.VERSION }}
111112
112113
# Publish to prod PyPI
113114
- name: Publish to PyPI
114115
env:
115116
TWINE_USERNAME: '__token__'
116117
TWINE_PASSWORD: ${{ env.PROD_PYPI_TOKEN_API_TOKEN }}
117118
run: |
118-
twine upload --skip-existing --verbose dist/aws_opentelemetry_distro-${{ github.event.inputs.version }}-py3-none-any.whl
119+
twine upload --skip-existing --verbose dist/aws_opentelemetry_distro-${{ env.VERSION }}-py3-none-any.whl
119120
120121
- name: Create GH release
121122
id: create_release
122123
env:
123124
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
124125
run: |
125126
gh release create --target "$GITHUB_REF_NAME" \
126-
--title "Release v${{ github.event.inputs.version }}" \
127+
--title "Release v${{ env.VERSION }}" \
127128
--draft \
128-
"v${{ github.event.inputs.version }}" \
129-
dist/aws_opentelemetry_distro-${{ github.event.inputs.version }}-py3-none-any.whl
129+
"v${{ env.VERSION }}" \
130+
dist/aws_opentelemetry_distro-${{ env.VERSION }}-py3-none-any.whl

0 commit comments

Comments
 (0)