Skip to content

Commit 89dad9d

Browse files
kgmwang1GitHub CopilotWilliamBerryiiikatriendg
authored
fix(build): resolve Pinned-Dependencies alerts for vsce npm commands in extension workflows (#782)
## Description Replaced all `npm install -g @vscode/vsce@3.7.1` commands in extension workflows with lockfile-backed `npm ci` installs, resolving OpenSSF Scorecard Pinned-Dependencies alerts #2#5. > Version pinning alone (`@3.7.1`) does not satisfy the Scorecard check — it requires cryptographic hash verification. Moving vsce to a root devDependency with `npm ci` provides SHA-512 integrity hashes from `package-lock.json`, which the Scorecard recognizes as "pinned." ### Workflow Changes Updated **extension-package.yml** and **extension-publish-marketplace.yml** to use `npm ci` instead of `npm install -g @vscode/vsce@3.7.1`. The marketplace workflow's `vsce publish` invocation switched to `npx vsce publish` to resolve from the locally installed package. ### Dependency and Script Changes Added `@vscode/vsce@3.7.1` as a root devDependency alongside existing tools (*cspell*, *markdownlint-cli2*, etc.), with integrity hashes automatically generated in *package-lock.json*. Pinned the version in `Package-Extension.ps1`'s npx fallback path to `@vscode/vsce@3.7.1` for consistency, and updated the corresponding Pester test assertion. ### Documentation Updated *extension/PACKAGING.md* prerequisites to instruct `npm ci` at the repo root and `npx vsce` for CLI invocations. ## Related Issue(s) Fixes #457 ## Type of Change Select all that apply: **Code & Documentation:** * [x] Bug fix (non-breaking change fixing an issue) * [ ] New feature (non-breaking change adding functionality) * [ ] Breaking change (fix or feature causing existing functionality to change) * [x] Documentation update **Infrastructure & Configuration:** * [x] GitHub Actions workflow * [ ] Linting configuration (markdown, PowerShell, etc.) * [x] Security configuration * [ ] DevContainer configuration * [x] Dependency update **AI Artifacts:** * [ ] Reviewed contribution with `prompt-builder` agent and addressed all feedback * [ ] Copilot instructions (`.github/instructions/*.instructions.md`) * [ ] Copilot prompt (`.github/prompts/*.prompt.md`) * [ ] Copilot agent (`.github/agents/*.agent.md`) * [ ] Copilot skill (`.github/skills/*/SKILL.md`) **Other:** * [x] Script/automation (`.ps1`, `.sh`, `.py`) * [ ] Other (please describe): ## Sample Prompts (for AI Artifact Contributions) <!-- Not applicable — no AI artifact changes in this PR --> ## Testing * **YAML linting**: `npm run lint:yaml` — 31/31 workflow files passed actionlint * **Markdown linting**: `npm run lint:md` on *extension/PACKAGING.md* — 0 errors * **PowerShell analysis**: `npm run lint:ps` — all scripts passed PSScriptAnalyzer * **Workflow permissions**: `npm run lint:permissions` — all workflows compliant * **Pester tests**: `npm run test:ps -- -TestPath "scripts/tests/extension/Package-Extension.Tests.ps1"` — 96/96 passed (including updated `Get-VscePackageCommand` assertion) * **Dry-run workflow**: Triggered `Publish Extension` workflow with `dry-run: true` on the feature branch — completed successfully in 5m16s, confirming `npm ci` + `npx vsce package` works end-to-end * **Manual verification**: `npx vsce --version` returns `3.7.1` after `npm ci`; zero `npm install -g @vscode/vsce` matches remain in the repository * Manual testing of actual marketplace publishing was not performed (requires marketplace credentials) ## Checklist ### Required Checks * [x] Documentation is updated (if applicable) * [x] Files follow existing naming conventions * [x] Changes are backwards compatible (if applicable) * [x] Tests added for new functionality (if applicable) ### AI Artifact Contributions <!-- Not applicable — no AI artifact changes --> * [ ] Used `/prompt-analyze` to review contribution * [ ] Addressed all feedback from `prompt-builder` review * [ ] Verified contribution follows common standards and type-specific requirements ### Required Automated Checks The following validation commands must pass before merging: * [x] Markdown linting: `npm run lint:md` * [ ] Spell checking: `npm run spell-check` * [ ] Frontmatter validation: `npm run lint:frontmatter` * [ ] Skill structure validation: `npm run validate:skills` * [ ] Link validation: `npm run lint:md-links` * [x] PowerShell analysis: `npm run lint:ps` * [ ] Plugin freshness: `npm run plugin:generate` ## Security Considerations * [x] This PR does not contain any sensitive or NDA information * [x] Any new dependencies have been reviewed for security issues * [x] Security-related scripts follow the principle of least privilege ## Additional Notes * The `extension-publish.yml` and `extension-publish-prerelease.yml` workflows delegate to the two modified reusable workflows — no direct changes needed in those callers. * OpenSSF Scorecard alerts #2#5 should resolve on the next scheduled scan after merge, since `npm ci` is syntactically recognized as "pinned" by the Scorecard's `isNpmUnpinnedDownload()` check. * Adding vsce to root devDependencies means `npm ci` in extension workflow jobs also installs other dev tools (cspell, markdownlint, etc.) — an acceptable ~30s tradeoff for security compliance. Co-authored-by: GitHub Copilot <copilot@github.com> Co-authored-by: Bill Berry <WilliamBerryiii@users.noreply.github.com> Co-authored-by: Katrien De Graeve <katriendg@users.noreply.github.com>
1 parent eb45d69 commit 89dad9d

File tree

7 files changed

+3196
-121
lines changed

7 files changed

+3196
-121
lines changed

.github/workflows/extension-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
node-version: "20"
9696

9797
- name: Install dependencies
98-
run: npm install -g @vscode/vsce@3.7.1
98+
run: npm ci
9999

100100
- name: Setup PowerShell
101101
shell: pwsh

.github/workflows/extension-publish-marketplace.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ jobs:
4545
with:
4646
node-version: "20"
4747

48-
- name: Install VSCE
49-
run: npm install -g @vscode/vsce@3.7.1
48+
- name: Install dependencies
49+
run: npm ci
5050

5151
- name: Download VSIX artifact
5252
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
@@ -76,7 +76,7 @@ jobs:
7676
fi
7777
7878
echo "📦 Publishing $COLLECTION_ID: $VSIX_FILE (v$VSIX_VERSION) [$CHANNEL_LABEL]"
79-
vsce publish --packagePath "$VSIX_FILE" $PRE_RELEASE_FLAG --azure-credential
79+
npx vsce publish --packagePath "$VSIX_FILE" $PRE_RELEASE_FLAG --azure-credential
8080
8181
- name: Summary
8282
env:

extension/PACKAGING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ This is a declarative extension: it contributes configuration and file paths, an
3737

3838
## Prerequisites
3939

40-
Install the VS Code Extension Manager CLI:
40+
Install project dependencies (includes the VS Code Extension Manager CLI):
4141

4242
```bash
43-
npm install -g @vscode/vsce
43+
npm ci
4444
```
4545

46+
After installation, use `npx vsce` to invoke the CLI.
47+
4648
Install the PowerShell-Yaml module (required for Prepare-Extension.ps1):
4749

4850
```powershell

0 commit comments

Comments
 (0)