fix: pin shadcn version instead of @latest in shadcn_add.py#284
Conversation
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>
537ea77 to
b029e79
Compare
|
Summary: I’m deferring this from the cron-safe lane because the change touches a runtime installer path and the existing test expectations are not updated with the new pinned-version behavior. Decision: deferred / needs test update Evidence:
Next step: please update the shadcn installer tests to cover the new command shape and version resolution. A merge-ready version should prove: dependency version is used, devDependency version is used, malformed/missing package.json falls back to the pinned default, and |
mrgoonie
left a comment
There was a problem hiding this comment.
Summary: This is a useful supply-chain hardening direction, but I’m keeping it comment-only for now because the behavior change still lacks regression coverage and it only patches the checked-in Claude skill copy.
Risk level: Medium
Mandatory gates:
- Duplicate/prior implementation: clear — no overlapping PR was found for pinning the shadcn installer version; related audit issues are #286/#289.
- Project standards: issue found — repo guidance treats source/canonical files and generated/package copies carefully, and this change only touches
.claude/skills/ui-styling/scripts/shadcn_add.py. - Strategic necessity: clear value — avoiding
shadcn@latestreduces nondeterministic installs and npm supply-chain drift. - CI/checks: missing — no checks are reported on this PR.
Findings:
- Important: the existing test suite is now stale.
.claude/skills/ui-styling/scripts/tests/test_shadcn_add.py::test_add_components_successstill asserts the old command prefix["npx", "shadcn@latest", "add"], and there are no tests for_get_shadcn_version()readingdependencies, readingdevDependencies, handling malformedpackage.json, or applying the same resolved version inadd_all_components(). Please update/add tests so this security behavior is locked instead of only manually reviewed. - Important: this PR changes only
.claude/skills/ui-styling/scripts/shadcn_add.py. Ifui-stylinghas a canonical source or packaged mirror for this script, apply/sync the same change there too; otherwise the next generation/package pass can silently drop the fix.
Verdict: COMMENT_ONLY / needs tests + source-of-truth check
mrgoonie
left a comment
There was a problem hiding this comment.
Approved for maintainer merge. I rechecked the diff and prior blockers: this PR is a narrow one-file hardening change for the runtime installer command, no duplicate PR covers the same shadcn pinning fix, and npm has a published shadcn 2.3.0 fallback package. Existing tests are stale for this new command shape, but the risk is bounded and this removes nondeterministic shadcn@latest execution from the helper path. Follow-up should still add regression tests for dependency/devDependency/fallback resolution and add_all_components(), but that can be tracked separately.
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:
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()`.