Skip to content

Commit 6311fd7

Browse files
authored
Merge pull request #481 from vechain/fix/zizmor-security-fixes-20251110-101130
[zizmor] Security fixes for workflow vulnerabilities
2 parents 7933f9e + 00f8c96 commit 6311fd7

File tree

7 files changed

+54
-17
lines changed

7 files changed

+54
-17
lines changed

.github/workflows/deploy-api-lambda.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ jobs:
2020
uses: actions/checkout@v4
2121

2222
- name: Configure AWS credentials
23-
uses: aws-actions/configure-aws-credentials@v4
23+
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4
2424
with:
2525
role-to-assume: ${{ secrets.AWS_ACC_ROLE }}
2626
aws-region: ${{ env.AWS_REGION }}
2727

2828
- name: Setup SAM CLI
29-
uses: aws-actions/setup-sam@v2
29+
uses: aws-actions/setup-sam@c71dd89d980e49367c70391e8ada4353f52f2800 # v2
3030
with:
3131
use-installer: true
3232
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/deploy-cloudfront.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
done
5151
5252
- name: Configure AWS credentials
53-
uses: aws-actions/configure-aws-credentials@v4
53+
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4
5454
with:
5555
role-to-assume: ${{ secrets.AWS_ACC_ROLE }}
5656
aws-region: ${{ env.AWS_REGION }}

.github/workflows/deploy-preview.yaml

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,51 @@
11
name: Deploy Preview Environment
22

33
on:
4-
pull_request_target:
4+
pull_request_target: # zizmor: ignore[dangerous-triggers] - Mitigated with label-based approval
5+
types: [labeled, synchronize, opened, reopened]
56
branches:
67
- main
78
paths: ['examples/homepage/**', 'packages/vechain-kit/**', 'yarn.lock']
89

910
permissions:
1011
contents: read
11-
id-token: write
12-
pull-requests: write
1312

1413
jobs:
14+
# Job 1: Post instruction comment for external PRs
15+
comment-external-pr:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
pull-requests: write
19+
if: |
20+
github.event.pull_request.head.repo.full_name != github.repository &&
21+
github.event.action == 'opened'
22+
steps:
23+
- name: Comment on external PR
24+
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
25+
with:
26+
issue-number: ${{ github.event.pull_request.number }}
27+
body: |
28+
## 👋 Thanks for your contribution!
29+
30+
Since this PR comes from a forked repository, preview deployment requires approval from a maintainer for security reasons.
31+
32+
**Next steps:**
33+
1. A maintainer will review your code
34+
2. If approved, they'll add the `safe-to-deploy` label to trigger deployment
35+
3. **After each new commit**, the maintainer will need to remove and re-add the label for security
36+
37+
This ensures every version of the code is explicitly reviewed before deployment. Thank you for your patience! 🙏
38+
39+
# Job 2: Deploy (runs for internal PRs OR when external PR gets labeled)
1540
deploy:
1641
runs-on: ubuntu-latest
42+
permissions:
43+
id-token: write
44+
pull-requests: write
45+
# Security gate: Only run when 'safe-to-deploy' label is ADDED OR from internal branch
46+
if: |
47+
(github.event.label.name == 'safe-to-deploy') ||
48+
(github.event.pull_request.head.repo.full_name == github.repository)
1749
env:
1850
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID }}
1951
NEXT_PUBLIC_PRIVY_APP_ID: ${{ secrets.NEXT_PUBLIC_PRIVY_APP_ID }}
@@ -34,11 +66,12 @@ jobs:
3466
run: |
3567
sanitized_branch_name=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]//g')
3668
echo "processedBranchName=$sanitized_branch_name" >> $GITHUB_OUTPUT
37-
echo "NEXT_PUBLIC_BASE_PATH=/$sanitized_branch_name" >> $GITHUB_ENV
69+
echo "basePath=/$sanitized_branch_name" >> $GITHUB_OUTPUT
3870
3971
- name: Build App
4072
env:
4173
NODE_OPTIONS: '--max-old-space-size=8192'
74+
NEXT_PUBLIC_BASE_PATH: ${{ steps.process-branch-name.outputs.basePath }}
4275
run: |
4376
yarn install
4477
yarn install:all
@@ -51,7 +84,7 @@ jobs:
5184
done
5285
5386
- name: Configure AWS credentials
54-
uses: aws-actions/configure-aws-credentials@v4
87+
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4
5588
with:
5689
role-to-assume: ${{ secrets.AWS_ACC_ROLE }}
5790
aws-region: ${{ env.AWS_REGION }}
@@ -65,7 +98,6 @@ jobs:
6598
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_PREVIEW_CLOUDFRONT_DISTRIBUTION_ID }} --paths '/' '/*'
6699
67100
- name: Create Deployment Comment
68-
if: github.event.action == 'opened' || github.event.action == 'reopened'
69101
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
70102
with:
71103
issue-number: ${{ github.event.pull_request.number }}

.github/workflows/destroy-preview-env.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
2020
steps:
2121
- name: Configure AWS credentials
22-
uses: aws-actions/configure-aws-credentials@v4
22+
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4
2323
with:
2424
role-to-assume: ${{ secrets.AWS_ACC_ROLE }}
2525
aws-region: eu-west-1

.github/workflows/publish-vechain-kit.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ on:
77

88
permissions:
99
contents: read
10-
packages: write
11-
id-token: write # Required for OIDC
1210

1311
jobs:
1412
publish-to-github-packages:
1513
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
1617
steps:
1718
- uses: actions/checkout@v4
1819
with:
@@ -36,13 +37,16 @@ jobs:
3637
- name: Publish VeChain-Kit to GitHub Packages
3738
run: |
3839
cd packages/vechain-kit
39-
yarn version --immediate ${{ github.ref_name }}
40+
yarn version --immediate ${GITHUB_REF_NAME}
4041
npm publish --tag latest
4142
env:
4243
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4344

4445
publish-to-npmjs:
4546
runs-on: ubuntu-latest
47+
permissions:
48+
contents: read
49+
id-token: write
4650
steps:
4751
- uses: actions/checkout@v4
4852
with:
@@ -66,5 +70,5 @@ jobs:
6670
- name: Publish VeChain-Kit to npmjs.org
6771
run: |
6872
cd packages/vechain-kit
69-
yarn version --immediate ${{ github.ref_name }}
73+
yarn version --immediate ${GITHUB_REF_NAME}
7074
npm publish --tag latest

.github/workflows/scan-workflows.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ permissions: {}
1111

1212
jobs:
1313
zizmor:
14-
uses: vechain/github-actions-public/.github/workflows/scan-workflows.yaml@cf384c612d562dbc17022d23ed094751e92921e5 # v.1.0.0
14+
uses: vechain/github-actions-public/.github/workflows/scan-workflows.yaml@77660aeff2fac9bbb704b3a2ce786814d0b632fa # v.1.1.0
1515
with:
1616
persona: 'auditor'
1717
min_severity: 'medium'
18+
min_confidence: 'high'
1819
permissions:
1920
contents: read
2021
actions: read

.github/workflows/sonar-scan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request_target:
7+
pull_request:
88

99
jobs:
1010
sonar-scan:
@@ -25,7 +25,7 @@ jobs:
2525
restore-keys: ${{ runner.os }}-sonar
2626

2727
- name: SonarCloud Scan
28-
uses: sonarsource/sonarcloud-github-action@master
28+
uses: sonarsource/sonarcloud-github-action@ba3875ecf642b2129de2b589510c81a8b53dbf4e # master
2929
env:
3030
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3131
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

0 commit comments

Comments
 (0)