Skip to content

fix: pin shadcn version instead of @latest in shadcn_add.py#284

Open
xiaolai wants to merge 1 commit intonextlevelbuilder:mainfrom
xiaolai:fix/nlpm-pin-shadcn-version
Open

fix: pin shadcn version instead of @latest in shadcn_add.py#284
xiaolai wants to merge 1 commit intonextlevelbuilder:mainfrom
xiaolai:fix/nlpm-pin-shadcn-version

Conversation

@xiaolai
Copy link
Copy Markdown

@xiaolai xiaolai commented Apr 26, 2026

Automated audit: This PR was generated by NLPM, a natural language programming linter, running via claude-code-action. Please evaluate the diff on its merits.

Security Fix (Medium)

`.claude/skills/ui-styling/scripts/shadcn_add.py` calls `npx shadcn@latest add` which silently downloads and runs whatever version npm has tagged as `latest` at the time of each invocation. While list-form `subprocess.run` prevents shell injection, the package itself is unverified at runtime — a supply-chain compromise of the `shadcn` npm package would be automatically installed on the next run.

Fix: Add a `_get_shadcn_version()` helper that:

  1. Reads the project's `package.json` and returns the `shadcn` version from `dependencies` or `devDependencies` if present
  2. Falls back to a pinned version string (`2.3.0`) when the project does not declare one

This ensures installations are reproducible. The pinned fallback version in the helper comment makes the version visible and easy to update deliberately.

Applied to both `add_components()` and `add_all_components()`.

npx shadcn@latest silently downloads whatever npm publishes as latest on
each run. Replace with a _get_shadcn_version() helper that reads the
installed shadcn version from the project package.json when available,
falling back to a pinned default (2.3.0). This ensures reproducible
installs and eliminates unverified-at-runtime supply chain drift.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@xiaolai xiaolai force-pushed the fix/nlpm-pin-shadcn-version branch from 537ea77 to b029e79 Compare April 26, 2026 06:57
@xiaolai xiaolai changed the title fix: pin shadcn CLI version instead of @latest (security) fix: pin shadcn version instead of @latest in shadcn_add.py Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant