Skip to content

Commit 63f7c1b

Browse files
Boshenclaudefengmk2
authored
ci: address zizmor findings in actions and release workflow (#1630)
## Summary - Apply zizmor auto-fixes to `build-upstream`, `clone`, and `set-snapshot-version` composite actions: untrusted `${{ inputs.* }}` values now flow through `env:` and are referenced as shell variables, closing the template-injection vector. - Add `persist-credentials: false` to the upstream `rolldown/rolldown` and `vitejs/vite` checkouts in `actions/clone`. - Drop `cache: 'pnpm'` from `actions/setup-node` in `release.yml` to remove the cache-poisoning warning on the publish job. - Replace `actions-cool/issues-helper` (repository has been disabled, which broke the zizmor `impostor-commit` audit) with inline `gh` CLI scripts in both `issue-close-require.yml` and `issue-labeled.yml`, removing the third-party dependency. After these changes, `zizmor --min-severity=high .` reports no findings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: MK (fengmk2) <fengmk2@gmail.com>
1 parent 2a44bce commit 63f7c1b

6 files changed

Lines changed: 88 additions & 53 deletions

File tree

.github/actions/build-upstream/action.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ runs:
2525
id: cache-key
2626
shell: bash
2727
run: |
28-
echo "key=napi-binding-v3-${{ inputs.target }}-${{ env.RELEASE_BUILD }}-${{ env.DEBUG }}-${{ env.VERSION }}-${{ env.NPM_TAG }}-${{ hashFiles('packages/tools/.upstream-versions.json', 'Cargo.lock', 'crates/**/*.rs', 'crates/*/Cargo.toml', 'packages/cli/binding/**/*.rs', 'packages/cli/binding/Cargo.toml', 'Cargo.toml', '.cargo/config.toml', 'packages/cli/package.json', 'packages/cli/build.ts', 'packages/cli/tsdown.config.ts') }}" >> $GITHUB_OUTPUT
28+
echo "key=napi-binding-v3-${INPUTS_TARGET}-${RELEASE_BUILD}-${DEBUG}-${VERSION}-${NPM_TAG}-${{ hashFiles('packages/tools/.upstream-versions.json', 'Cargo.lock', 'crates/**/*.rs', 'crates/*/Cargo.toml', 'packages/cli/binding/**/*.rs', 'packages/cli/binding/Cargo.toml', 'Cargo.toml', '.cargo/config.toml', 'packages/cli/package.json', 'packages/cli/build.ts', 'packages/cli/tsdown.config.ts') }}" >> $GITHUB_OUTPUT
29+
env:
30+
INPUTS_TARGET: ${{ inputs.target }}
2931

3032
# Resolve the Rust target directory (CARGO_TARGET_DIR from setup-rust, or default "target")
3133
- name: Resolve Rust target directory
@@ -70,7 +72,9 @@ runs:
7072
- name: Add musl Rust target
7173
if: steps.cache-restore.outputs.cache-hit != 'true' && contains(inputs.target, 'musl')
7274
shell: bash
73-
run: rustup target add ${{ inputs.target }}
75+
run: rustup target add ${INPUTS_TARGET}
76+
env:
77+
INPUTS_TARGET: ${{ inputs.target }}
7478

7579
- name: Setup zig (musl)
7680
if: steps.cache-restore.outputs.cache-hit != 'true' && contains(inputs.target, 'musl')
@@ -90,64 +94,75 @@ runs:
9094
shell: bash
9195
if: steps.cache-restore.outputs.cache-hit != 'true' && contains(inputs.target, 'linux') && !contains(inputs.target, 'musl')
9296
run: |
93-
pnpm --filter=vite-plus build-native --target ${{ inputs.target }} --use-napi-cross
97+
pnpm --filter=vite-plus build-native --target ${INPUTS_TARGET} --use-napi-cross
9498
env:
9599
TARGET_CC: clang
96100
TARGET_CFLAGS: ${{ contains(inputs.target, 'aarch64') && '-D_BSD_SOURCE' || '' }}
97101
DEBUG: napi:*
102+
INPUTS_TARGET: ${{ inputs.target }}
98103

99104
- name: Build NAPI bindings (Linux musl)
100105
shell: bash
101106
if: steps.cache-restore.outputs.cache-hit != 'true' && contains(inputs.target, 'musl')
102107
run: |
103-
pnpm --filter=vite-plus build-native --target ${{ inputs.target }} -x
108+
pnpm --filter=vite-plus build-native --target ${INPUTS_TARGET} -x
104109
env:
105110
TARGET_CC: clang
106111
TARGET_CFLAGS: ${{ contains(inputs.target, 'aarch64') && '-D_BSD_SOURCE' || '' }}
107112
DEBUG: napi:*
113+
INPUTS_TARGET: ${{ inputs.target }}
108114

109115
- name: Build NAPI bindings (non-Linux targets)
110116
shell: bash
111117
if: steps.cache-restore.outputs.cache-hit != 'true' && !contains(inputs.target, 'linux')
112118
run: |
113-
pnpm --filter=vite-plus build-native --target ${{ inputs.target }}
119+
pnpm --filter=vite-plus build-native --target ${INPUTS_TARGET}
114120
env:
115121
DEBUG: napi:*
122+
INPUTS_TARGET: ${{ inputs.target }}
116123

117124
- name: Build Rust CLI binary (Linux gnu)
118125
if: steps.cache-restore.outputs.cache-hit != 'true' && contains(inputs.target, 'linux') && !contains(inputs.target, 'musl')
119126
shell: bash
120127
run: |
121-
pnpm exec napi build --use-napi-cross --target ${{ inputs.target }} --release -p vite_global_cli
128+
pnpm exec napi build --use-napi-cross --target ${INPUTS_TARGET} --release -p vite_global_cli
122129
env:
123130
TARGET_CC: clang
124131
TARGET_CFLAGS: ${{ contains(inputs.target, 'aarch64') && '-D_BSD_SOURCE' || '' }}
125132
DEBUG: napi:*
133+
INPUTS_TARGET: ${{ inputs.target }}
126134

127135
- name: Build Rust CLI binary (Linux musl)
128136
if: steps.cache-restore.outputs.cache-hit != 'true' && contains(inputs.target, 'musl')
129137
shell: bash
130138
run: |
131-
pnpm exec napi build -x --target ${{ inputs.target }} --release -p vite_global_cli
139+
pnpm exec napi build -x --target ${INPUTS_TARGET} --release -p vite_global_cli
132140
env:
133141
TARGET_CC: clang
134142
TARGET_CFLAGS: ${{ contains(inputs.target, 'aarch64') && '-D_BSD_SOURCE' || '' }}
135143
DEBUG: napi:*
144+
INPUTS_TARGET: ${{ inputs.target }}
136145

137146
- name: Build Rust CLI binary (non-Linux targets)
138147
if: steps.cache-restore.outputs.cache-hit != 'true' && !contains(inputs.target, 'linux')
139148
shell: bash
140-
run: cargo build --release --target ${{ inputs.target }} -p vite_global_cli
149+
run: cargo build --release --target ${INPUTS_TARGET} -p vite_global_cli
150+
env:
151+
INPUTS_TARGET: ${{ inputs.target }}
141152

142153
- name: Build trampoline shim binary (Windows only)
143154
if: steps.cache-restore.outputs.cache-hit != 'true' && contains(inputs.target, 'windows')
144155
shell: bash
145-
run: cargo build --release --target ${{ inputs.target }} -p vite_trampoline
156+
run: cargo build --release --target ${INPUTS_TARGET} -p vite_trampoline
157+
env:
158+
INPUTS_TARGET: ${{ inputs.target }}
146159

147160
- name: Build installer binary (Windows only)
148161
if: steps.cache-restore.outputs.cache-hit != 'true' && contains(inputs.target, 'windows')
149162
shell: bash
150-
run: cargo build --release --target ${{ inputs.target }} -p vite_installer
163+
run: cargo build --release --target ${INPUTS_TARGET} -p vite_installer
164+
env:
165+
INPUTS_TARGET: ${{ inputs.target }}
151166

152167
- name: Save NAPI binding cache
153168
if: steps.cache-restore.outputs.cache-hit != 'true'

.github/actions/clone/action.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,25 @@ runs:
2727
id: ecosystem-ci-project-hash
2828
if: ${{ inputs.ecosystem-ci-project != '' }}
2929
run: |
30-
node -e "console.log('ECOSYSTEM_CI_PROJECT_HASH=' + require('./ecosystem-ci/repo.json')['${{ inputs.ecosystem-ci-project }}'].hash)" >> $GITHUB_OUTPUT
31-
node -e "console.log('ECOSYSTEM_CI_PROJECT_REPOSITORY=' + require('./ecosystem-ci/repo.json')['${{ inputs.ecosystem-ci-project }}'].repository.replace('https://github.com/', '').replace('.git', ''))" >> $GITHUB_OUTPUT
32-
echo "ECOSYSTEM_CI_PROJECT_PATH=${{ runner.temp }}/vite-plus-ecosystem-ci/${{ inputs.ecosystem-ci-project }}" >> $GITHUB_OUTPUT
30+
node -e "console.log('ECOSYSTEM_CI_PROJECT_HASH=' + require('./ecosystem-ci/repo.json')['${INPUTS_ECOSYSTEM_CI_PROJECT}'].hash)" >> $GITHUB_OUTPUT
31+
node -e "console.log('ECOSYSTEM_CI_PROJECT_REPOSITORY=' + require('./ecosystem-ci/repo.json')['${INPUTS_ECOSYSTEM_CI_PROJECT}'].repository.replace('https://github.com/', '').replace('.git', ''))" >> $GITHUB_OUTPUT
32+
echo "ECOSYSTEM_CI_PROJECT_PATH=${{ runner.temp }}/vite-plus-ecosystem-ci/${INPUTS_ECOSYSTEM_CI_PROJECT}" >> $GITHUB_OUTPUT
33+
env:
34+
INPUTS_ECOSYSTEM_CI_PROJECT: ${{ inputs.ecosystem-ci-project }}
3335

3436
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3537
with:
3638
repository: rolldown/rolldown
3739
path: rolldown
3840
ref: ${{ steps.upstream-versions.outputs.ROLLDOWN_HASH }}
41+
persist-credentials: false
3942

4043
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4144
with:
4245
repository: vitejs/vite
4346
path: vite
4447
ref: ${{ steps.upstream-versions.outputs.ROLLDOWN_VITE_HASH }}
48+
persist-credentials: false
4549

4650
# Disable autocrlf to preserve LF line endings on Windows
4751
# This prevents prettier/eslint from failing with "Delete ␍" errors
@@ -53,4 +57,6 @@ runs:
5357
- name: Clone ecosystem ci project
5458
if: ${{ inputs.ecosystem-ci-project != '' }}
5559
shell: bash
56-
run: npx tsx ecosystem-ci/clone.ts ${{ inputs.ecosystem-ci-project }}
60+
run: npx tsx ecosystem-ci/clone.ts ${INPUTS_ECOSYSTEM_CI_PROJECT}
61+
env:
62+
INPUTS_ECOSYSTEM_CI_PROJECT: ${{ inputs.ecosystem-ci-project }}

.github/actions/set-snapshot-version/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ runs:
2121
run: |
2222
git fetch --tags --quiet
2323
npm install --prefix ${{ github.action_path }} semver > /dev/null 2>&1
24-
VERSION_OUTPUT=$(node ${{ github.action_path }}/compute-version.mjs "${{ inputs.npm_tag }}")
24+
VERSION_OUTPUT=$(node ${{ github.action_path }}/compute-version.mjs "${INPUTS_NPM_TAG}")
2525
echo "$VERSION_OUTPUT"
2626
echo "$VERSION_OUTPUT" | tail -n 1 >> $GITHUB_OUTPUT
27+
env:
28+
INPUTS_NPM_TAG: ${{ inputs.npm_tag }}

.github/workflows/issue-close-require.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,24 @@ on:
77
jobs:
88
close-issues:
99
if: github.repository == 'voidzero-dev/vite-plus'
10-
runs-on: ubuntu-slim
10+
runs-on: ubuntu-latest
1111
permissions:
12-
issues: write # for actions-cool/issues-helper to update issues
13-
pull-requests: write # for actions-cool/issues-helper to update PRs
12+
issues: write
1413
steps:
15-
- name: needs reproduction
16-
uses: actions-cool/issues-helper@200c78641dbf33838311e5a1e0c31bbdb92d7cf0 # v3.8.0
17-
with:
18-
actions: 'close-issues'
19-
token: ${{ secrets.GITHUB_TOKEN }}
20-
labels: 'needs reproduction'
21-
inactive-day: 3
14+
- name: Close inactive "needs reproduction" issues
15+
env:
16+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
GH_REPO: ${{ github.repository }}
18+
shell: bash
19+
run: |
20+
cutoff=$(date -u -d '3 days ago' +%Y-%m-%dT%H:%M:%SZ)
21+
gh issue list \
22+
--state open \
23+
--label "needs reproduction" \
24+
--limit 200 \
25+
--json number,updatedAt \
26+
--jq ".[] | select(.updatedAt < \"$cutoff\") | .number" |
27+
while read -r number; do
28+
[ -z "$number" ] && continue
29+
gh issue close "$number"
30+
done

.github/workflows/issue-labeled.yml

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,42 @@ on:
77
jobs:
88
reply-labeled:
99
if: github.repository == 'voidzero-dev/vite-plus'
10-
runs-on: ubuntu-slim
10+
runs-on: ubuntu-latest
1111
permissions:
12-
issues: write # for actions-cool/issues-helper to update issues
13-
pull-requests: write # for actions-cool/issues-helper to update PRs
12+
issues: write
1413
steps:
15-
- name: contribution welcome
14+
- name: Remove triage labels (contribution welcome / help wanted)
1615
if: github.event.label.name == 'contribution welcome' || github.event.label.name == 'help wanted'
17-
uses: actions-cool/issues-helper@200c78641dbf33838311e5a1e0c31bbdb92d7cf0 # v3.8.0
18-
with:
19-
actions: 'remove-labels'
20-
token: ${{ secrets.GITHUB_TOKEN }}
21-
issue-number: ${{ github.event.issue.number }}
22-
labels: 'pending triage, needs reproduction'
23-
24-
- name: needs reproduction
16+
env:
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
GH_REPO: ${{ github.repository }}
19+
ISSUE_NUMBER: ${{ github.event.issue.number }}
20+
shell: bash
21+
run: |
22+
gh issue edit "$ISSUE_NUMBER" \
23+
--remove-label "pending triage" \
24+
--remove-label "needs reproduction" || true
25+
26+
- name: Comment and remove triage on "needs reproduction"
2527
if: github.event.label.name == 'needs reproduction'
26-
uses: actions-cool/issues-helper@200c78641dbf33838311e5a1e0c31bbdb92d7cf0 # v3.8.0
27-
with:
28-
actions: 'create-comment, remove-labels'
29-
token: ${{ secrets.GITHUB_TOKEN }}
30-
issue-number: ${{ github.event.issue.number }}
31-
labels: 'pending triage'
32-
body: |
33-
Hello @${{ github.event.issue.user.login }} 👋
28+
env:
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
GH_REPO: ${{ github.repository }}
31+
ISSUE_NUMBER: ${{ github.event.issue.number }}
32+
ISSUE_USER: ${{ github.event.issue.user.login }}
33+
shell: bash
34+
run: |
35+
gh issue comment "$ISSUE_NUMBER" --body "Hello @${ISSUE_USER} 👋
36+
37+
Please provide a [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) using a GitHub repository. This helps us understand and resolve your issue much faster.
3438
35-
Please provide a [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) using a GitHub repository. This helps us understand and resolve your issue much faster.
39+
**A good reproduction should be:**
40+
- **Minimal** – include only the code necessary to demonstrate the issue
41+
- **Complete** – contain everything needed to run and observe the problem
42+
- **Reproducible** – consistently show the issue with clear steps
3643
37-
**A good reproduction should be:**
38-
- **Minimal** – include only the code necessary to demonstrate the issue
39-
- **Complete** – contain everything needed to run and observe the problem
40-
- **Reproducible** – consistently show the issue with clear steps
44+
If no reproduction is provided, issues labeled \`needs reproduction\` will be closed after 3 days of inactivity.
4145
42-
If no reproduction is provided, issues labeled `needs reproduction` will be closed after 3 days of inactivity.
46+
For more context on why this is required, please read: https://antfu.me/posts/why-reproductions-are-required"
4347
44-
For more context on why this is required, please read: https://antfu.me/posts/why-reproductions-are-required
48+
gh issue edit "$ISSUE_NUMBER" --remove-label "pending triage" || true

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ jobs:
7676
node-version-file: .node-version
7777
package-manager-cache: false
7878
registry-url: 'https://registry.npmjs.org'
79-
cache: 'pnpm'
8079

8180
- name: Install dependencies
8281
run: pnpm install

0 commit comments

Comments
 (0)