Skip to content

fix(create): reject non-semver versions in org-template manifests - #2665

Merged
fengmk2 merged 3 commits into
mainfrom
fix/org-template-version-validation
Sep 11, 2026
Merged

fix(create): reject non-semver versions in org-template manifests#2665
fengmk2 merged 3 commits into
mainfrom
fix/org-template-version-validation

Conversation

@fengmk2

@fengmk2 fengmk2 commented Sep 11, 2026

Copy link
Copy Markdown
Member

Malformed registry versions can place org-template files outside the cache root. readOrgManifest() now rejects versions that fail semver.valid(), including targets from dist-tags.latest and tags that match a requested version.

resolveExtractionDir() also checks that the extraction path stays within the cache root. Tests cover invalid versions, path traversal, and valid versions with prerelease or build metadata.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 11, 2026

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-org-template-version-validation-viteplus-dev.voidzero-docs.workers.dev (commit 481b6f5)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://ad70f9b7-viteplus-dev.voidzero-docs.workers.dev 481b6f5 2026-09-11T08:53:25.761Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://c8c0e2f4-viteplus-dev.voidzero-docs.workers.dev fe1a99c 2026-09-11T08:01:37.621Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://6c09a337-viteplus-dev.voidzero-docs.workers.dev cd6f5ca 2026-09-11T07:06:44.683Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://4f1ca19c-viteplus-dev.voidzero-docs.workers.dev 0e24d6c 2026-09-11T04:07:47.759Z Visit the dashboard ↗

@fengmk2 fengmk2 added the preview-build Publish this PR's commits to the registry bridge as preview builds label Sep 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Registry bridge build (0e24d6c)

This commit build is published to the registry bridge, which serves these as ordinary npm versions (every other package proxies to npmjs):

Package Version
vite-plus 0.0.0-commit.0e24d6c2139ea8733ee4a1dd70e4a2a1ba8b4a4a
@voidzero-dev/vite-plus-core 0.0.0-commit.0e24d6c2139ea8733ee4a1dd70e4a2a1ba8b4a4a

Install the Vite+ CLI built from this commit, then migrate a project:

# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/voidzero-dev/vite-plus/0e24d6c2139ea8733ee4a1dd70e4a2a1ba8b4a4a/packages/cli/install.sh | VP_PR_VERSION=2665 VP_LEGACY_INSTALLER_URL=https://raw.githubusercontent.com/voidzero-dev/vite-plus/0e24d6c2139ea8733ee4a1dd70e4a2a1ba8b4a4a/packages/cli/install-legacy.sh bash
# Windows (PowerShell)
$env:VP_PR_VERSION="2665"; $env:VP_LEGACY_INSTALLER_URL="https://raw.githubusercontent.com/voidzero-dev/vite-plus/0e24d6c2139ea8733ee4a1dd70e4a2a1ba8b4a4a/packages/cli/install-legacy.ps1"; irm https://raw.githubusercontent.com/voidzero-dev/vite-plus/0e24d6c2139ea8733ee4a1dd70e4a2a1ba8b4a4a/packages/cli/install.ps1 | iex

Or download the standalone Windows installer built from this commit:

Architecture Installer
x64 vp-setup-x86_64-pc-windows-msvc.exe
Arm64 vp-setup-aarch64-pc-windows-msvc.exe

GitHub requires you to sign in and downloads each installer as a ZIP artifact. Extract vp-setup.exe, then run it against this preview build:

.\vp-setup.exe --version "0.0.0-commit.0e24d6c2139ea8733ee4a1dd70e4a2a1ba8b4a4a" --registry "https://registry-bridge.viteplus.dev/"

After installing, upgrade the current project's vite-plus to this test build with:

vp migrate

Or point your package manager at the bridge registry https://registry-bridge.viteplus.dev/:

Package manager Registry config
npm / pnpm / Bun .npmrc: registry=https://registry-bridge.viteplus.dev/
Yarn (v2+) .yarnrc.yml: npmRegistryServer: "https://registry-bridge.viteplus.dev/"

Then pin the build (vite aliases to vite-plus-core; pnpm can use a catalog, npm an overrides entry):

{
  "devDependencies": {
    "vite-plus": "0.0.0-commit.0e24d6c2139ea8733ee4a1dd70e4a2a1ba8b4a4a",
    "vite": "npm:@voidzero-dev/vite-plus-core@0.0.0-commit.0e24d6c2139ea8733ee4a1dd70e4a2a1ba8b4a4a"
  }
}

@github-actions

Copy link
Copy Markdown
Contributor

🐳 Docker preview image

Built from this PR's registry bridge build:

Image Compressed size
ghcr.io/voidzero-dev/vite-plus:pr-2665 228MB
# remove any stale local copy from a previous run, then pull fresh
docker rmi ghcr.io/voidzero-dev/vite-plus:pr-2665 2>/dev/null; docker pull ghcr.io/voidzero-dev/vite-plus:pr-2665

Quick check:

docker run --rm ghcr.io/voidzero-dev/vite-plus:pr-2665 vp --version

See docs/guide/docker.md for usage.

@fengmk2 fengmk2 self-assigned this Sep 11, 2026
@fengmk2
fengmk2 marked this pull request as ready for review September 11, 2026 07:41
@fengmk2
fengmk2 requested a review from cpojer September 11, 2026 07:41
@fengmk2 fengmk2 added test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: create-e2e Run `vp create` e2e tests labels Sep 11, 2026
A registry response can point a dist-tag at a non-semver string, and
readOrgManifest() copied that value into OrgManifest.version without
validation. The version later becomes a path component in the
org-template extraction cache (<cache>/<host>/<scope>/create/<version>),
where '..' segments in a malformed value place the extraction directory
outside the cache root.

Validate the resolved version with semver.valid() at resolution time,
covering both the dist-tags.latest branch and the pinned
dist-tags[requestedVersion] branch, and keep the same containment
invariant at the path construction sink.
@fengmk2
fengmk2 force-pushed the fix/org-template-version-validation branch from fe1a99c to 481b6f5 Compare September 11, 2026 08:52
@fengmk2
fengmk2 merged commit 316dd7b into main Sep 11, 2026
108 checks passed
@fengmk2
fengmk2 deleted the fix/org-template-version-validation branch September 11, 2026 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview-build Publish this PR's commits to the registry bridge as preview builds test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests test: install-e2e run vite install e2e test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants