Repository navigation
Pin public npm registry for Dependabot in template and JsPublish lockfile directories - #21660
Conversation
…rectories Dependabot looks for .npmrc in parent directories when a package directory has none, so npm_and_yarn security updates inherited the repo-root .npmrc (internal dnceng feed). They wrote dnceng resolved URLs into the shipped template lockfiles and the JsPublish E2E fixtures, which then fail anonymous npm ci with E401. Add a directory .npmrc with registry=https://registry.npmjs.org/ to each of those 8 lockfile directories, exclude .npmrc from the CLI embedded templates and the ProjectTemplates package, and add regression tests. Fixes #21659 Co-authored-by: Copilot <[email protected]>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21660Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21660" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Fixture-only .npmrc changes do not trigger the new registry guard, leaving a CI coverage gap that needs targeted trigger rules and a selector regression test.
1 open issue
What changed in this PR
This PR addresses #21659 by pinning the public npm registry for starter templates and JsPublish fixtures, preventing Dependabot from introducing internal-feed URLs that cause unauthenticated installs to fail.
Changes:
- Add public-registry
.npmrcfiles to eight package directories. - Exclude repo-only registry settings from shipped template payloads.
- Add regression checks for registry pins and CLI resource exclusion.
| File | Description |
|---|---|
tests/Aspire.Cli.Tests/Templating/TemplatePackageLockTests.cs |
Tests registry pins and CLI template resource exclusion. |
tests/Aspire.Cli.EndToEnd.Tests/Fixtures/JsPublish/npmscript/.npmrc |
Pins the npm-script fixture to the public registry. |
tests/Aspire.Cli.EndToEnd.Tests/Fixtures/JsPublish/nextjs/.npmrc |
Pins the Next.js fixture to the public registry. |
src/Aspire.ProjectTemplates/templates/aspire-ts-cs-starter/frontend/.npmrc |
Pins the C#/TypeScript starter frontend registry. |
src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj |
Excludes .npmrc files from the template package. |
src/Aspire.Cli/Templating/Templates/ts-starter/frontend/.npmrc |
Pins the TypeScript starter frontend registry. |
src/Aspire.Cli/Templating/Templates/ts-starter/.npmrc |
Pins the TypeScript starter AppHost registry. |
src/Aspire.Cli/Templating/Templates/py-starter/frontend/.npmrc |
Pins the Python starter frontend registry. |
src/Aspire.Cli/Templating/Templates/py-starter/.npmrc |
Pins the Python starter root package registry. |
src/Aspire.Cli/Templating/Templates/java-starter/frontend/.npmrc |
Pins the Java starter frontend registry. |
src/Aspire.Cli/Aspire.Cli.csproj |
Excludes .npmrc files from embedded templates. |
Review effort: Balanced
Co-authored-by: Copilot <[email protected]>
Tests selector4 / 100 PR test projects · 7 PR jobs, from 13 changed files. Selected PR test projects (4 / 100)
Selected PR jobs (7)
How these were chosen — grouped by what changed🔧 🔧 🧪 🧪 📦 affected project 📄 🔧 🧪 🧪 Job reasons
Selection computed for commit |
CI confidence report🟡 ISSUES No blocker remains, but the limitations below still need attention. Attention🟡 Official build security warnings require separate triage — Track agent, dependency and toolchain security warnings separately from this registry fix.
Audited commit: be915cb6 Coverage catalogThe items below show the affected workflows, tests, artifacts and other validation evidence. Workflows and pipelines🟢 1. GitHub execution and coverage — Affected workflows and test lanes are verified.
🟢 1a. Affected workflow final-definition execution — Verified
🟢 GitHub package build
⚪ 1b. Outerloop scenario coverage — Not applicable
⚪ 1c. Quarantine scenario coverage — Not applicable
🟢 1d. Deployment E2E coverage — Verified
🟢 Affected Docker and Kubernetes E2E jobs
🟢 2. Internal Azure pipeline/stage execution — Verified
🟢 Official managed template package
🟢 Official embedded CLI payload
🟢 3. CI selection/result gates — Verified
🟢 JsPublish fixture routing
Functional and platform coverage🟢 4. Ordinary functional/regression/platform coverage — Verified
🟢 Public registry and embedded resource guards
Produced outputs and artifacts🟢 5. Artifact/release-consumer integrity — Verified
🟢 Actual PR template package and credential-less restore
Static checks and dependency safety⚪ 6. Lint/static analysis/generated consistency — Not applicable
⚪ 7. Dependency/action/task/tool version safety — Not applicable
Security and agent behavior🟡 8. Security/trust-boundary review — Attention
🟢 Registry and template configuration source review
⚪ 9. Representative agent behavior — Not applicable
|
Ankit Jain (radical)
left a comment
There was a problem hiding this comment.
[automated] Reviewed be915cb; no PR-specific blocking issue found.
GitHub validation passed. Official build 3126562 succeeded after a targeted retry of an Apple notarization network failure. Inspected the actual official template package and materialized the signed native CLI's embedded TypeScript starter: repository-only .npmrc files are excluded and required manifests/locks remain present.
Validation evidence and limits: #21660 (comment)
The report separately preserves agent/toolchain security warnings; this approval does not waive them or claim a successful full local project SDK restore.
|
✅ No documentation update needed. Proven false positive; no docs needed (docs_required → false positive, no user-facing change). Triggered signals:
|

Description
Fixes #21659
Dependabot
npm_and_yarnsecurity-update PRs write internal dncengresolvedURLs into lockfiles that must use the public npm registry. Over the last 7 days, 4 of 5 such PRs failed CI on attempt 1, with 7–18 jobs failed per run:TemplatePackageLockTests.*_UsesPublicNpmRegistryon every OSnpm ciE401 in the K8s TypeScript, PV and JavaScriptPublish E2E testsRoot cause: if a package directory has no
.npmrc, Dependabot walks up the parent directories to find one (dependabot-corenpm_and_yarn/file_fetcher.rb#npmrc→fetch_file_from_parent_directories). It therefore uses the repo-root.npmrc, whoseregistry=is the dnceng feed. Local npm stops at the package root, so locally regenerated lockfiles stay on npmjs. Only Dependabot drifts.Fix:
Add a directory
.npmrcwithregistry=https://registry.npmjs.org/to the 8 lockfile directories that must use the public registry:ts-starter,ts-starter/frontend,py-starter,py-starter/frontend,java-starter/frontendaspire-ts-cs-starter/frontendJsPublish/nextjs,JsPublish/npmscriptDependabot reads the directory's own
.npmrcfirst.Don't ship these repo-only files to customers, so a user's own registry config isn't overridden:
Aspire.Cli.csproj:EmbeddedResource Remove="Templating\Templates\**\.npmrc"Aspire.ProjectTemplates.csproj:TemplateFilesexcludestemplates\**\.npmrcRepo-internal lockfiles that are meant to use dnceng are unchanged.
Selective CI: a new
test-trigger-map.ymlpath rule routes the JsPublish fixture.npmrcfiles totest:Aspire.Cli.Tests. The selector regressionTestTriggerMapTests.JsPublishFixtureNpmrcRunsCliPublicRegistryGuardcovers it: it fails with the rule reverted, and all 346 TestTriggerMap tests pass.Regression tests in
TemplatePackageLockTests:PublicRegistryPackageLockDirectory_PinsPublicNpmRegistryForDependabot(8 cases)CliTemplateResources_DoNotIncludeRepoOnlyNpmrcEvidence
Before and after lockfile resolution. This mirrors Dependabot's update on #21404:
npm install [email protected] --package-lock-onlyon the ts-starter frontend frommain..npmrcDependabot seesresolvedhostsregistry.npmjs.org+ 17pkgs.dev.azure.compkgs.dev.azure.com/dnceng/.../vite-8.3.5.tgz.npmrc(after)registry.npmjs.orgregistry.npmjs.org/vite/-/vite-8.3.5.tgzThe "before" split is the same as the actual Dependabot commit on #21404 (17 dnceng URLs in this file).
Docker
npm ci(node:22-alpine, no credentials,npm ci --ignore-scripts):npm error code E401 Unable to authenticate, your authentication token seems to be invalid(exit 1). This matches CI.added 152 packages in 4s(exit 0).Tests and packaging:
TemplatePackageLockTests: 33/33 pass locally.ts-starter/frontend/.npmrcremoved, the new test fails as expected.dotnet msbuild Aspire.ProjectTemplates.csproj -getItem:TemplateFiles: 303 items, 0.npmrc, and the frontendpackage-lock.jsonis still included.Out of scope: the TypeScript SDK unit-test E401 comes from a lockfile that is meant to use dnceng and asks for versions the feed hasn't cached yet. dnceng 429 retries are covered by #18691 / #21657.
Checklist
🤖 Posted by AspireAgent (AI Agent)