Skip to content

fix(init): harden npx execution and config writer safety#614

Merged
horza-bora merged 1 commit intomainfrom
fix/init-security-hardening-612
Feb 24, 2026
Merged

fix(init): harden npx execution and config writer safety#614
horza-bora merged 1 commit intomainfrom
fix/init-security-hardening-612

Conversation

@Dave-London
Copy link
Owner

Summary

Fixes #612

  • Package name allowlist for doctor health checks: validateServerPackage() validates @paretools/* package names in npx args against PARETOOLS_PACKAGES allowlist before spawning. Unknown @paretools/* packages trigger a typosquatting warning in the doctor report. Non-paretools servers (user's own) pass through without warning.
  • .bak backup creation for config writers: mergeConfig() creates a .bak backup of existing config files before any modification, protecting against data loss from malformed file merges. Backup path is tracked in MergeResult and printed in CLI output.
  • Tests: 12 new tests covering allowlist validation (known/unknown/non-paretools/empty args), report warning display, and backup creation across JSON/TOML/YAML config formats.

Test plan

  • pnpm --filter @paretools/init test passes (122 tests, 14 files)
  • tsc --noEmit passes with no new errors
  • prettier --check passes on all modified files
  • Includes changeset for @paretools/init patch bump

Generated with Claude Code

Add package name allowlist for doctor health checks:
- PARETOOLS_PACKAGES set of known-good @paretools/* packages
- validateServerPackage() checks args against allowlist before npx
- Warns on unknown @paretools/* packages (typosquatting risk)
- Non-paretools servers pass through without warning

Add .bak backup creation for config file modifications:
- FileSystem interface gains backupFile() method
- mergeConfig() creates backup before any config write
- MergeResult.backupPath tracks backup location
- CLI prints backup path when config is modified

Tests cover both features:
- validateServerPackage: known, unknown, non-paretools, empty args
- formatReport: warning display in doctor report
- mergeConfig backup: creation, absence, content preservation,
  TOML and YAML formats

Fixes #612

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@horza-bora horza-bora merged commit 7e2e014 into main Feb 24, 2026
11 checks passed
@horza-bora horza-bora deleted the fix/init-security-hardening-612 branch February 24, 2026 04:17
@pare-ci-bot pare-ci-bot bot mentioned this pull request Feb 24, 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.

fix(init): harden npx execution and config writer safety

2 participants