Skip to content

Commit df4b89c

Browse files
committed
chore: enhance security more
1 parent 2ac0be1 commit df4b89c

3 files changed

Lines changed: 29 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
runs-on: ubuntu-latest
1717

1818
steps:
19-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2020

2121
- name: Set up Node
22-
uses: actions/setup-node@v4
22+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
2323

2424
- run: npm ci
2525

@@ -36,10 +36,10 @@ jobs:
3636
runs-on: ubuntu-latest
3737

3838
steps:
39-
- uses: actions/checkout@v4
39+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
4040

4141
- name: Set up Node
42-
uses: actions/setup-node@v4
42+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
4343

4444
- run: npm ci
4545

.github/workflows/conventional-commits.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
env:
2727
EVENT: ${{ toJSON(github.event) }}
2828
steps:
29-
- uses: actions/checkout@v4
29+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
3030
with:
3131
sparse-checkout: |
3232
.github

.github/workflows/release.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
permissions:
1010
contents: read
1111

12+
concurrency:
13+
group: release-${{ github.ref }}
14+
cancel-in-progress: false
15+
1216
jobs:
1317
release:
1418
runs-on: ubuntu-latest
@@ -20,7 +24,7 @@ jobs:
2024
steps:
2125
- name: Generate GitHub App token
2226
id: generate-token
23-
uses: actions/create-github-app-token@v1
27+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf
2428
with:
2529
app-id: ${{ secrets.GH_APP_ID }}
2630
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
@@ -30,11 +34,11 @@ jobs:
3034
with:
3135
token: ${{ steps.generate-token.outputs.token }}
3236

33-
- uses: actions/checkout@v4
37+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
3438
with:
3539
fetch-depth: 0
3640

37-
- uses: actions/setup-node@v4
41+
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
3842
with:
3943
node-version: 22
4044
registry-url: "https://registry.npmjs.org"
@@ -48,6 +52,8 @@ jobs:
4852
RELEASE_VERSION: ${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}
4953
PR_HEAD_BRANCH: ${{ steps.release.outputs.pr && fromJSON(steps.release.outputs.pr).headBranchName }}
5054
run: |
55+
set -euo pipefail
56+
5157
if [ "$RELEASE_CREATED" == "true" ]; then
5258
VERSION="$RELEASE_VERSION"
5359
TAG="latest"
@@ -73,12 +79,19 @@ jobs:
7379
exit 0
7480
fi
7581
76-
git fetch origin "$PR_HEAD_BRANCH"
77-
NEXT_VERSION=$(git show "origin/$PR_HEAD_BRANCH:package.json" | node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).version")
82+
# Validate branch name to prevent git ref injection
83+
if [[ ! "$PR_HEAD_BRANCH" =~ ^[A-Za-z0-9._/-]+$ ]]; then
84+
echo "Invalid PR_HEAD_BRANCH: $PR_HEAD_BRANCH"
85+
exit 1
86+
fi
87+
88+
git fetch origin "refs/heads/$PR_HEAD_BRANCH"
89+
NEXT_VERSION=$(git show "FETCH_HEAD:package.json" | node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).version")
7890
79-
if [ -z "$NEXT_VERSION" ]; then
80-
echo "skip=true" >> $GITHUB_OUTPUT
81-
exit 0
91+
# Validate strict semver before use
92+
if [[ ! "$NEXT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
93+
echo "Invalid version in PR branch package.json: $NEXT_VERSION"
94+
exit 1
8295
fi
8396
8497
VERSION="${NEXT_VERSION}-rc.${{ github.run_number }}"
@@ -90,6 +103,7 @@ jobs:
90103
- name: Build
91104
if: ${{ steps.version.outputs.skip != 'true' }}
92105
run: |
106+
set -euo pipefail
93107
echo "export const VERSION = '${{ steps.version.outputs.version }}';" > src/version.ts
94108
npm ci
95109
npm run build
@@ -98,6 +112,7 @@ jobs:
98112
- name: Publish
99113
if: ${{ steps.version.outputs.skip != 'true' }}
100114
run: |
115+
set -euo pipefail
101116
EXISTING=$(npm view "@supabase/ssr@${{ steps.version.outputs.version }}" version 2>/dev/null || true)
102117
if [ -n "$EXISTING" ]; then
103118
echo "Version ${{ steps.version.outputs.version }} already published on npm, skipping."
@@ -111,6 +126,7 @@ jobs:
111126
env:
112127
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
113128
run: |
129+
set -euo pipefail
114130
gh release create "v${{ steps.version.outputs.version }}" \
115131
--title "v${{ steps.version.outputs.version }}" \
116132
--generate-notes \

0 commit comments

Comments
 (0)