Skip to content

Commit ccf5c17

Browse files
authored
Merge pull request #288 from swlodarski-sumoheavy/8.0.x-gh-actions-untrusted-input
Security: Fix untrusted input vulnerability in release workflow - 8.0.x
2 parents e6af529 + 877b883 commit ccf5c17

File tree

3 files changed

+39
-30
lines changed

3 files changed

+39
-30
lines changed

.github/workflows/release.yml

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,57 +38,63 @@ jobs:
3838

3939
- name: Push version bump and tag
4040
id: version
41+
env:
42+
BUMP: ${{ github.event.inputs.bump }}
43+
REF_NAME: ${{ github.ref_name }}
4144
run: |
4245
git config user.name "github-actions"
4346
git config user.email "[email protected]"
44-
npm version ${{ github.event.inputs.bump }} --no-git-tag-version
47+
npm version $BUMP --no-git-tag-version
4548
version=$(jq -r .version package.json)
4649
echo "version=$version" >> $GITHUB_OUTPUT
4750
sed -i "s/^export const BitpayPluginInfo = .*$/export const BitpayPluginInfo = 'BitPay_NodeJs_Client_v$version';/" src/Env.ts
4851
git add package.json package-lock.json src/Env.ts
4952
git commit -m "Bump version to $version"
5053
git tag $version
51-
git push origin ${{ github.ref_name }}
54+
git push origin $REF_NAME
5255
git push origin $version
5356
5457
- name: Get merged PR titles and format release notes
5558
id: changelog
59+
env:
60+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
REF_NAME: ${{ github.ref_name }}
62+
OVERVIEW: ${{ github.event.inputs.overview }}
63+
REPOSITORY: ${{ github.repository }}
5664
run: |
5765
git fetch --tags
5866
59-
# Get most recent and previous tags
6067
tags=($(git tag --sort=-creatordate))
6168
new_tag="${tags[0]}"
6269
prev_tag="${tags[1]}"
6370
6471
if [ -z "$prev_tag" ]; then
65-
echo "Warning: No previous tag found. Skipping full changelog link."
6672
changelog=""
6773
else
68-
changelog="**Full Changelog**: https://github.com/${{ github.repository }}/compare/$prev_tag...$new_tag"
74+
changelog="**Full Changelog**: https://github.com/$REPOSITORY/compare/$prev_tag...$new_tag"
6975
fi
7076
71-
prs=$(gh pr list --state merged --base "${{ github.ref_name }}" --json title,mergedAt --jq '[.[] | select(.mergedAt != null) | .title]')
77+
prs=$(gh pr list --state merged --base "$REF_NAME" --json title,mergedAt --jq '[.[] | select(.mergedAt != null) | .title]')
7278
joined=$(echo "$prs" | jq -r '.[]' | sed 's/^/* /')
7379
7480
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
75-
echo "${{ github.event.inputs.overview }}" >> $GITHUB_ENV
81+
echo "$OVERVIEW" >> $GITHUB_ENV
7682
echo "" >> $GITHUB_ENV
7783
echo "## What's Changed" >> $GITHUB_ENV
7884
echo "$joined" >> $GITHUB_ENV
7985
echo "" >> $GITHUB_ENV
8086
echo "$changelog" >> $GITHUB_ENV
8187
echo "EOF" >> $GITHUB_ENV
82-
env:
83-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8488
8589
- name: Create GitHub release
86-
run: |
87-
gh release create "${{ steps.version.outputs.version }}" \
88-
--title "${{ steps.version.outputs.version }}" \
89-
--notes "${{ env.RELEASE_NOTES }}"
9090
env:
9191
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
VERSION: ${{ steps.version.outputs.version }}
93+
RELEASE_NOTES: ${{ env.RELEASE_NOTES }}
94+
run: |
95+
gh release create "$VERSION" \
96+
--title "$VERSION" \
97+
--notes "$RELEASE_NOTES"
9298
9399
readme-changelog:
94100
name: Publish changelog to Readme
@@ -101,9 +107,12 @@ jobs:
101107

102108
- name: Extract release data
103109
id: release_data
110+
env:
111+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
VERSION: ${{ needs.release.outputs.version }}
104113
run: |
105-
echo "title=${{ needs.release.outputs.version }}" >> $GITHUB_OUTPUT
106-
body=$(gh release view ${{ needs.release.outputs.version }} --json body --jq .body)
114+
echo "title=$VERSION" >> $GITHUB_OUTPUT
115+
body=$(gh release view $VERSION --json body --jq .body)
107116
body_escaped=$(echo "$body" \
108117
| sed 's/&/\&#38;/g' \
109118
| sed 's/</\&#60;/g' \
@@ -115,15 +124,15 @@ jobs:
115124
echo "$body_escaped"
116125
echo "EOF"
117126
} >> $GITHUB_OUTPUT
118-
env:
119-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120127
121128
- name: Publish changelog to Readme
122129
env:
123130
README_API_KEY: ${{ secrets.README_API_KEY }}
131+
RELEASE_TITLE: ${{ steps.release_data.outputs.title }}
132+
RELEASE_BODY: ${{ steps.release_data.outputs.body }}
124133
run: |
125-
jq -n --arg title "Node.js Unified SDK v${{ steps.release_data.outputs.title }}" \
126-
--arg body "${{ steps.release_data.outputs.body }}" \
134+
jq -n --arg title "Node.js Unified SDK v$RELEASE_TITLE" \
135+
--arg body "$RELEASE_BODY" \
127136
'{
128137
title: $title,
129138
content: {
@@ -135,4 +144,4 @@ jobs:
135144
curl --location 'https://api.readme.com/v2/changelogs' \
136145
--header "Authorization: Bearer $README_API_KEY" \
137146
--header 'Content-Type: application/json' \
138-
--data @payload.json
147+
--data @payload.json

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@
5353
"dependencies": {
5454
"bs58": "6.0.0",
5555
"elliptic": "6.6.1",
56-
"lodash": "4.17.21",
56+
"lodash": "4.17.23",
5757
"zod": "4.3.5"
5858
},
5959
"devDependencies": {
6060
"@types/bs58": "5.0.0",
6161
"@types/elliptic": "6.4.18",
6262
"@types/jest": "30.0.0",
63-
"@types/lodash": "4.17.21",
63+
"@types/lodash": "4.17.23",
6464
"@types/node": "25.0.7",
6565
"@typescript-eslint/eslint-plugin": "8.53.0",
6666
"@typescript-eslint/parser": "8.53.0",

0 commit comments

Comments
 (0)