Repository navigation
fix(remove): validate config capability names; delete only a strict child (PHARN-01) - #195
Merged
Merged
Conversation
…hild (PHARN-01)
A hand-edited `pharn.config.json` entry such as `{"name":"../..","role":"lens"}`
made `pharn remove ../..` recursively delete the project root (including
`.git`): capability names were never validated at ingest, and `safeJoin`
accepts the base directory itself.
- `readPharnConfig` now validates every `capabilities[]` entry: an object whose
`name` matches `CAPABILITY_NAME_RE` (no control characters) and whose `role`
is `griller|lens`, else the new named `CapabilityEntryError` (joins
`isConfigValidationError`, so every command exits 1 with the offender named).
- `remove` deletes through the new `safeChildJoin`, which only returns a
single-segment child of the role subtree — a second, independent floor.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TvcuVhk8hTeDskp5pAJhnc
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
A hand-edited
pharn.config.jsonentry such as{"name":"../..","role":"lens"}madepharn remove ../..recursively delete the whole project root,.gitincluded. A name like../../srcdeletedsrc/, and the interactive picker was affected the same way. Two causes: capabilityname/rolewere never validated at ingest, andsafeJoinaccepts the base directory itself.src/lib/pharn-config.ts): everycapabilities[]entry must now be an object whosenamematchesCAPABILITY_NAME_RE(no control chars) and whoseroleisgriller|lens. Otherwise config loading throws the new namedCapabilityEntryError. It joinsisConfigValidationError, so every command exits 1 and names the offending entry. No config this CLI ever wrote is newly rejected, because names come from the already-validated index.src/commands/remove.ts,src/lib/validate.ts): the delete now goes through the newsafeChildJoin, which returns only a single-segment child of the role subtree — never the base itself, never a deeper path. This is a second, independent check.CLAUDE.md,SECURITY.md.Built via
/pharn-dev-ship; stage artifacts are in.dev/features/config-capability-name-validation/. Results:no-regressionsPASSType of change
feat— new stack option, wizard step, or command capabilityfix— bug fixdocs— docs-only changechore/refactor— tooling or internal restructure, no behavior changeArea(s) touched
commands/remove | lib/validate | lib/pharn-config | docs (CLAUDE.md, SECURITY.md)
Checklist
.js-extension import convention.tests/*.test.ts(pharn-config,validate,remove). 38 of the new cases fail on the old source.src/lib/validate.ts; this PR addssafeChildJoinand does not changesafeJoin.Quality gates
npm run checkpasses locally (1277/1277 tests; run as a non-root user on node 22).npm run buildsucceeds.npm run test:coveragepasses.Notes for the reviewer
Start with
validateCapabilityEntriesandsafeChildJoin. The remaining/pharn-dev-reviewfindings are advisory and not addressed here (details in.dev/features/config-capability-name-validation/REVIEW.md):list --jsonis covered only via the shared error union.🤖 Generated with Claude Code
https://claude.ai/code/session_01TvcuVhk8hTeDskp5pAJhnc
Generated by Claude Code