Skip to content

Pin public npm registry for Dependabot in template and JsPublish lockfile directories - #21660

Merged
Ankit Jain (radical) merged 2 commits into
mainfrom
fix/dependabot-public-npm-lockfiles
Nov 4, 2026
Merged

Ankit Jain (radical) merged 2 commits into
mainfrom
fix/dependabot-public-npm-lockfiles

Conversation

@davidfowl

@davidfowl David Fowler (davidfowl) commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes #21659

Dependabot npm_and_yarn security-update PRs write internal dnceng resolved URLs 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.*_UsesPublicNpmRegistry on every OS
  • Starter Validation
  • Docker npm ci E401 in the K8s TypeScript, PV and JavaScriptPublish E2E tests

Root cause: if a package directory has no .npmrc, Dependabot walks up the parent directories to find one (dependabot-core npm_and_yarn/file_fetcher.rb#npmrc → fetch_file_from_parent_directories). It therefore uses the repo-root .npmrc, whose registry= 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 .npmrc with registry=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/frontend
    • aspire-ts-cs-starter/frontend
    • JsPublish/nextjs, JsPublish/npmscript

    Dependabot reads the directory's own .npmrc first.

  • 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: TemplateFiles excludes templates\**\.npmrc
  • Repo-internal lockfiles that are meant to use dnceng are unchanged.

Selective CI: a new test-trigger-map.yml path rule routes the JsPublish fixture .npmrc files to test:Aspire.Cli.Tests. The selector regression TestTriggerMapTests.JsPublishFixtureNpmrcRunsCliPublicRegistryGuard covers it: it fails with the rule reverted, and all 346 TestTriggerMap tests pass.

Regression tests in TemplatePackageLockTests:

  • PublicRegistryPackageLockDirectory_PinsPublicNpmRegistryForDependabot (8 cases)
  • CliTemplateResources_DoNotIncludeRepoOnlyNpmrc

Evidence

Before and after lockfile resolution. This mirrors Dependabot's update on #21404: npm install [email protected] --package-lock-only on the ts-starter frontend from main.

.npmrc Dependabot sees resolved hosts vite 8.3.5 resolved
repo root (before) 159 registry.npmjs.org + 17 pkgs.dev.azure.com pkgs.dev.azure.com/dnceng/.../vite-8.3.5.tgz
directory .npmrc (after) 177 registry.npmjs.org registry.npmjs.org/vite/-/vite-8.3.5.tgz

The "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):

  • Before lockfile: npm error code E401 Unable to authenticate, your authentication token seems to be invalid (exit 1). This matches CI.
  • After lockfile: added 152 packages in 4s (exit 0).

Tests and packaging:

  • TemplatePackageLockTests: 33/33 pass locally.
  • With ts-starter/frontend/.npmrc removed, the new test fails as expected.
  • dotnet msbuild Aspire.ProjectTemplates.csproj -getItem:TemplateFiles: 303 items, 0 .npmrc, and the frontend package-lock.json is 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

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

🤖 Posted by AspireAgent (AI Agent)

…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]>
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21660

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21660"

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 .npmrc files 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

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Tests selector

4 / 100 PR test projects · 7 PR jobs, from 13 changed files.

Selected PR test projects (4 / 100)

Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Aspire.Templates.Tests, Infrastructure.Tests

Selected PR jobs (7)

cli-starter-validation, extension-e2e, homebrew-installer, polyglot, typescript-api-compat, typescript-sdk, winget-installer


How these were chosen — grouped by what changed

🔧 src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj (changed source)
→ 3 directly: Aspire.Cli.EndToEnd.Tests, Aspire.Templates.Tests, Infrastructure.Tests

🔧 src/Aspire.ProjectTemplates/templates/aspire-ts-cs-starter/frontend/.npmrc (changed source)
→ 3 directly: Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Aspire.Templates.Tests

🧪 tests/Aspire.Cli.EndToEnd.Tests/Fixtures/JsPublish/nextjs/.npmrc (changed test)
→ 2 directly: Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests

🧪 tests/Aspire.Cli.EndToEnd.Tests/Fixtures/JsPublish/npmscript/.npmrc (changed test)
→ 2 directly: Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests

📦 affected project Aspire.Cli
→ 1 test: Aspire.Cli.EndToEnd.Tests

📄 eng/github-ci/test-trigger-map.yml (changed)
→ 1 directly: Infrastructure.Tests

🔧 src/Aspire.Cli/Aspire.Cli.csproj (changed source)
→ 1 directly: Infrastructure.Tests

🧪 tests/Aspire.Cli.Tests/Templating/TemplatePackageLockTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Infrastructure.Tests/TestTriggerMap/TestTriggerMapTests.cs (changed test)
→ 1 directly: Infrastructure.Tests

Job reasons

Job Triggered by
cli-starter-validation • src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj
• affected project Aspire.Cli
extension-e2e • src/Aspire.Cli/Aspire.Cli.csproj, src/Aspire.Cli/Templating/Templates/java-starter/frontend/.npmrc, src/Aspire.Cli/Templating/Templates/py-starter/.npmrc, src/Aspire.Cli/Templating/Templates/py-starter/frontend/.npmrc, src/Aspire.Cli/Templating/Templates/ts-starter/.npmrc, src/Aspire.Cli/Templating/Templates/ts-starter/frontend/.npmrc
• affected project Aspire.Cli
homebrew-installer src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj, src/Aspire.ProjectTemplates/templates/aspire-ts-cs-starter/frontend/.npmrc
polyglot affected project Aspire.Cli
typescript-api-compat affected project Aspire.Cli
typescript-sdk src/Aspire.Cli/Templating/Templates/ts-starter/.npmrc, src/Aspire.Cli/Templating/Templates/ts-starter/frontend/.npmrc
winget-installer src/Aspire.ProjectTemplates/Aspire.ProjectTemplates.csproj, src/Aspire.ProjectTemplates/templates/aspire-ts-cs-starter/frontend/.npmrc

Selection computed for commit be915cb.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the registry-pinning and template-packaging changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@radical

Copy link
Copy Markdown
Member

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.

  • Expected: Do not interpret a successful official build as security clearance.
  • Observed: The successful run reported Component Governance alert counts of 23, 24 or 34 across jobs, unpatched agent SDK/runtime warnings for the reported Brotli vulnerability, and NU1903 for Microsoft.DotNet.ILCompiler 11.0.0-rc.2.26504.105. SDL auto-baselining/no-break notices were also present. These are pipeline warnings, not vulnerabilities independently reproduced in this PR review.
  • Missing evidence: This diff changes neither dependency versions/locks nor SDK, runner-image or scanner policy inputs. No causal regression from the registry/template exclusions was identified. A before/after alert delta was not established, so this report does not claim the alerts were all pre-existing or waived.
  • Required validation: Have the pipeline/security owners triage the build's Component Governance, agent-image and build-tool warnings separately.
  • Done when: Owners record the disposition and applicable remediation of the reported agent, component and build-tool alerts.
  • Evidence: successful build warning receipt: receipt

Audited commit: be915cb6
Independent review: completed
This is a partial CI-confidence review, not a complete code review.

Coverage catalog

The 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.
  • Evidence / missing boundary: See the named consumer requirements and their primary evidence. | The complete 13-file diff and its named consumers establish this boundary.
🟢 1a. Affected workflow final-definition execution — Verified
  • Applicability: yes — Changed MSBuild package inputs are consumed by the GitHub Build packages job.
  • Evidence / missing boundary: See the named consumer requirements and their primary evidence.
🟢 GitHub package build

  • Expected: The changed template items evaluate and produce an inspectable package.
  • Observed: Build with packages and upload steps succeeded at the PR head; the package metadata identifies merge commit 6d01b73, whose second parent is the audited head.
  • Evidence: job status: receipt; source trace: receipt
⚪ 1b. Outerloop scenario coverage — Not applicable
  • Applicability: no — No outerloop selection, scheduling attribute, runner or shared execution plumbing changes. The new selector rule adds a regular-PR CLI guard rather than changing an outerloop workload.
  • Evidence / missing boundary: The complete 13-file diff and its named consumers establish this boundary.
⚪ 1c. Quarantine scenario coverage — Not applicable
  • Applicability: no — No quarantined test selection, scheduling attribute, runner or quarantine execution input changes.
  • Evidence / missing boundary: The complete 13-file diff and its named consumers establish this boundary.
🟢 1d. Deployment E2E coverage — Verified
  • Applicability: yes — Existing regular Docker/Kubernetes E2E consumers exercise the affected fixtures and generated template output.
  • Evidence / missing boundary: See the named consumer requirements and their primary evidence.
🟢 Affected Docker and Kubernetes E2E jobs

  • Expected: The TypeScript, persistent-volume and JavaScript publish consumers execute on the fixed template/fixture inputs.
  • Observed: KubernetesDeployTypeScriptTests, KubernetesDeployTypeScriptWithPersistentVolumeTests and JavaScriptPublishTests passed; their Run nuget dependent tests (Linux/macOS) steps executed successfully.
  • Evidence: job status: receipt; job status: receipt; job status: receipt
🟢 2. Internal Azure pipeline/stage execution — Verified
  • Applicability: yes — Changed TemplateFiles and EmbeddedResource metadata feed official managed and native packaging.
  • Evidence / missing boundary: Actual managed template and signed native embedded template outputs inspected from official build 3126562.
🟢 Official managed template package

  • Expected: Definition 1602 build/Windows executes the changed TemplateFiles exclusion and the signed template package omits .npmrc while retaining frontend manifests and locks.
  • Observed: Official build/Windows succeeded at exact PR head be915cb. Downloaded managed_packages_shipping; Aspire.ProjectTemplates.17.0.0-preview.1.26554.6.nupkg repository metadata matches that head. The actual package contains zero .npmrc files, both required frontend manifests/locks and 177 npmjs lock sources.
  • Evidence: job status: receipt; actual package inspection: no public receipt URL — Local managed-package-inspection.json: passed; package commit matches audited head.
🟢 Official embedded CLI payload

  • Expected: Definition 1602 build_sign_native executes with the changed EmbeddedResource exclusion and its actual CLI template output contains required manifests/locks without .npmrc.
  • Observed: All seven official native RID jobs succeeded, including osx-arm64 on attempt 2. Downloaded the signed osx-x64 CLI archive and executed it on macOS arm64 via Rosetta. Its new aspire-ts-starter command materialized all 30 tracked template files excluding source-only .npmrc; root and frontend package.json/package-lock.json are present, with zero .npmrc files. This verifies the actual embedded template payload, not a successful full project SDK restore.
  • Evidence: job status: receipt; actual native payload inspection: no public receipt URL — Local native-payload-inspection.json: all 30 expected ts-starter files present and no .npmrc.
  • Consulted evidence: The first osx-arm64 attempt failed before CLI packaging: Apple CloudKit notarization-ticket lookup lost its connection (NSURLErrorDomain -1005), so stapler validate exited 68. Missing-symbol/package publication errors were downstream. Only that failed job was retried; tray verification and the native job then succeeded.
🟢 3. CI selection/result gates — Verified
  • Applicability: yes — The added narrow path rule changes future fixture-only test selection.
  • Evidence / missing boundary: See the named consumer requirements and their primary evidence.
🟢 JsPublish fixture routing

  • Expected: Each fixture-only .npmrc edit selects the public registry guard in Aspire.Cli.Tests.
  • Observed: Downloaded final-head TRX contains both passing JsPublishFixtureNpmrcRunsCliPublicRegistryGuard cases and 346 passing tests in the TestTriggerMap namespace. The live selector comment selects CLI, E2E, template and infrastructure tests.
  • Evidence: job status: receipt; test artifact: no public receipt URL — Locally inspected final-head Infrastructure TRX: 346 passed, including both new routing cases.; source trace: receipt

Functional and platform coverage

🟢 4. Ordinary functional/regression/platform coverage — Verified
  • Applicability: yes — CLI/resource consumers observe the configuration exclusions; existing relevant tests and platform legs executed.
  • Evidence / missing boundary: See the named consumer requirements and their primary evidence.
🟢 Public registry and embedded resource guards

  • Expected: All eight source-only pins exist and CLI embedded template payloads omit .npmrc.
  • Observed: Downloaded final-head CLI TRX contains 33 passing TemplatePackageLockTests: eight public pin cases and CliTemplateResources_DoNotIncludeRepoOnlyNpmrc passed. CLI jobs passed on Linux, Windows and macOS; starter validation passed on six OS/architecture legs.
  • Evidence: job status: receipt; job status: receipt; job status: receipt; test artifact: no public receipt URL — Locally inspected final-head CLI TRX: 33 registry/template guards passed.

Produced outputs and artifacts

🟢 5. Artifact/release-consumer integrity — Verified
  • Applicability: yes — The nupkg payload is changed and its actual GitHub output was inspected and restored.
  • Evidence / missing boundary: See the named consumer requirements and their primary evidence.
🟢 Actual PR template package and credential-less restore

  • Expected: The produced nupkg omits repository-only configuration and retains a usable public-registry frontend.
  • Observed: Inspected Aspire.ProjectTemplates.17.0.0-pr.21660.gbe915cb6.nupkg: zero .npmrc entries and 177 public lock sources. A fresh-cache restore of the exact packed frontend on macOS arm64, Node 26.7.0/npm 11.19.0 returned 'added 153 packages in 2s'; all 153 HTTP fetches used registry.npmjs.org. Scripts/audit/funding were disabled.
  • Evidence: artifact metadata: receipt; local artifact inspection: no public receipt URL — Verified nupkg repository commit 6d01b73 is the audited PR merge tree.; manual execution: no public receipt URL — npm ci --ignore-scripts --no-audit --no-fund --loglevel=http --fetch-retries=0 --fetch-timeout=30000 with fresh cache, isolated HOME and distinct empty user/global configs: exit 0. No registry override or credentials.

Static checks and dependency safety

⚪ 6. Lint/static analysis/generated consistency — Not applicable
  • Applicability: no — The diff changes MSBuild XML, .npmrc data and selector data/tests, not workflows/actions, scripts, generated lock definitions or analyzer configuration. MSBuild evaluation/build and selector execution are covered in their consumer aspects; actionlint/ShellCheck/PSScriptAnalyzer/zizmor have no changed executable input.
  • Evidence / missing boundary: The complete 13-file diff and its named consumers establish this boundary.
⚪ 7. Dependency/action/task/tool version safety — Not applicable
  • Applicability: no — No dependency, action SHA, Azure task, SDK or tool version changes.
  • Evidence / missing boundary: The complete 13-file diff and its named consumers establish this boundary.

Security and agent behavior

🟡 8. Security/trust-boundary review — Attention
  • Applicability: yes — Registry configuration and customer-output boundaries changed and received targeted source review.
  • Evidence / missing boundary: Registry/customer-output trust boundary verified; official run security warnings retained as separate advisory attention.
🟢 Registry and template configuration source review

  • Expected: Repository source pins must not force customer registry settings or introduce new credential flows.
  • Observed: Reviewed all eight fixed registry values, CLI EmbeddedResource Remove and TemplateFiles Exclude. No commands, secrets, token scopes or execution permissions are added. Actual package inspection and embedded-resource tests confirm the intended customer boundary in GitHub output; official outputs remain tracked separately.
  • Evidence: source trust review: receipt; source trust review: receipt
- **Required validation:** see [finding](#finding-8544233402e1f0c9) for Official build security warnings require separate triage.
⚪ 9. Representative agent behavior — Not applicable
  • Applicability: no — No agent instructions, agentic workflows or agent execution consumers change.
  • Evidence / missing boundary: The complete 13-file diff and its named consumers establish this boundary.
⚠️ Assessment limits — high-impact limitations
  • Overall official build 3126562 completed with result succeeded after one targeted macOS arm64 retry. Managed, all seven native RID jobs, installer preparation, assembly and source-analysis stages succeeded. The report does not claim release publishing or source indexing.
  • Native payload materialization was verified, but a full local project SDK restore was not: a long isolated HOME hit the platform Unix-domain-socket path limit after the embedded files were copied. The package checks do not claim application execution.
  • The earlier credential-less packed-frontend npm restore disabled lifecycle scripts, audit and funding.
  • GitHub validation uses the original PR merge tree; official output validation uses the exact PR head. Neither proves a merge with newer main.

@radical Ankit Jain (radical) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

@radical
Ankit Jain (radical) merged commit 858863f into main Nov 4, 2026
484 of 488 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Nov 4, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

✅ No documentation update needed.

Proven false positive; no docs needed (docs_required → false positive, no user-facing change).

Triggered signals: pr_body_has_cli_flag_mention, project_template_changed.

  • pr_body_has_cli_flag_mention: the matched text is npm install [email protected] --package-lock-only in the PR body. That is a maintainer lockfile-regeneration command, not an Aspire CLI flag.
  • project_template_changed: the changes under src/Aspire.ProjectTemplates/ and src/Aspire.Cli/Templating/Templates/ only add .npmrc files that pin the public npm registry so Dependabot can resolve lockfiles. They also touch Aspire.Cli.csproj and eng/github-ci/test-trigger-map.yml. The templates' generated behavior, options and documented usage are unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-cli ci-health Fixes CI flakiness or CI infrastructure (AspireAgent queue)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dependabot npm PRs write internal dnceng resolved URLs into public-registry lockfiles (templates, JsPublish fixtures), failing CI with E401

3 participants