fix(security): remove postinstall script, download binary on first run only#306
Merged
Merged
Conversation
…n only Postinstall scripts are a known npm supply chain attack vector — they execute arbitrary code the moment a package is installed. The bin shim (`bin/archgate.cjs`) already handles on-demand binary download, making the postinstall purely a convenience pre-download. After this change, `npm install -g archgate` only places the lightweight shim on disk. No code executes until the user explicitly runs `archgate`. Also fixes ARCH-010 warnings in `src/commands/adr/import.ts` by replacing `readFileSync` + `JSON.parse` with `Bun.file().json()`. Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
|
✅ All tests passed. |
Deploying archgate-cli with
|
| Latest commit: |
76ff1d5
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://cdb270f9.archgate-cli.pages.dev |
| Branch Preview URL: | https://security-remove-postinstall.archgate-cli.pages.dev |
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.
Summary
scripts/postinstall.cjsand all references frompackage.json— postinstall scripts are a known npm supply chain attack vector that execute arbitrary code duringnpm installbin/archgate.cjs) already handles on-demand binary download from GitHub Releases, making the postinstall purely a convenience pre-downloadnpm install -g archgateonly places the lightweight shim on disk — no code executes until the user explicitly runsarchgatesrc/commands/adr/import.tsby replacingreadFileSync+JSON.parsewithBun.file().json()(ADR check now reports 0 warnings)Test plan
bun run validatepasses (828 tests, 26 ADR rules, 0 violations, 0 warnings)npm pack --dry-runconfirms tarball contains onlypackage.json,README.md,LICENSE.md,bin/archgate.cjs— noscripts/postinstall.cjspostinstallreferences in codebase (verified via grep)