Repository navigation
fix: make fix safe by default, new health score, verified typosquat check - #15
Open
AjayBThorat-20 wants to merge 1 commit into
Open
AjayBThorat-20 wants to merge 1 commit into
AjayBThorat-20 wants to merge 1 commit into
Conversation
… check `fix` could make breaking changes in its default safe mode. On a project with axios@0.21.1, esbuild@0.19.0 and express@4.17.1 it would install axios@0.33.0, esbuild@0.25.0, cookie@0.7.0 and send@0.19.0, install transitive packages at the top level, and uninstall packages flagged as unused. fix: - "Safe" now means within semver's caret range: never a major, never a 0.x minor bump. npm audit's fixAvailable object only counts when isSemVerMajor is false, and a merged finding is judged on the fix version actually chosen, not on any one source's own safeFix. - A security finding with no concrete fix version is a review item instead of an install of @latest. - A vulnerable transitive package is never installed at the top level; it's listed under "Needs manual action" with `npm audit fix` and one combined overrides/pnpm.overrides/resolutions snippet. - Packages are only removed with the new --remove-unused flag, never by --all. Unused findings are no longer counted as safe fixes. - Each package is installed once, at the highest selected version, and the dry-run summary shows versions again. Health score: each category's penalty approaches a fixed cap (security 5, license/quality/outdated 1.5, unused 0.5) instead of growing with the number of findings. Any CRITICAL or known-exploited vulnerability caps the score at 3.9, any HIGH at 5.9. Typosquat: a one-character name match (two swapped letters now count as one) is only reported when npm download counts confirm the look-alike is 50x+ more popular and the package has under 100k downloads a month. The scan is reported incomplete when the counts can't be fetched. The fix text is "Review before using", never "Replace with" the look-alike. Install scripts: the regex scan of the project's own scripts is gone. Dependencies that run code at install are listed from the lockfile as information (analyze, --deep, metadata.installScripts), never scored.
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 and why
devcompass fixcould make breaking changes in its default safe mode. On a project withaxios@0.21.1,esbuild@0.19.0andexpress@4.17.1it would installaxios@0.33.0,esbuild@0.25.0,cookie@0.7.0andsend@0.19.0, install transitive packages at the top level, and uninstall packages flagged as unused.fixfixAvailableobject only counts whenisSemVerMajoris false, and a merged finding is judged on the fix version actually chosen, not on any one source'ssafeFix.@latest.npm audit fixand one combinedoverrides/pnpm.overrides/resolutionssnippet.--remove-unusedflag, never by--all.Health score: each category's penalty approaches a fixed cap (security 5, license/quality/outdated 1.5, unused 0.5) instead of growing with the number of findings, so 30 outdated packages can't outweigh one critical vulnerability. Any CRITICAL or known-exploited vulnerability caps the score at 3.9, any HIGH at 5.9. Scores change for most projects, so
--ci --thresholdusers should re-check theirs.Typosquat: a one-character name match (two swapped letters now count as one, catching
loadshandaxois) is only reported when npm download counts confirm the look-alike is ≥50× more popular and the package has under 100k downloads a month. Thresholds come from real numbers: typo packages get 55 to 30k a month, while real look-alikes likepreact,vuex,nuxiandcuidget 0.7M to 164M. The scan is reported incomplete if the counts can't be fetched, and the fix text is "Review before using", never "Replace with" the look-alike.Install scripts: the regex scan of the project's own scripts is gone. Dependencies that run code at install time are listed from the lockfile as information (
analyze,--deep,metadata.installScripts) and never scored.Stacked on #14.
Merging the stack: use Create a merge commit, not squash (squashing makes every later PR show these commits again). After merging the PR below this one, click Delete branch on it; GitHub then retargets this PR to
mainand CI runs.How I tested it
npm run test:coverageon Node 24.21.0, cleannpm ci, network disabled: 206/206 pass, 40.7% linesnpm audit --audit-level=highcleanfix --dry-runlists 6 transitive packages and theloadshtyposquat under "Needs manual action" with oneoverridessnippetfix --yeson a scratch project: 3 in-place updates, backup created, unused package left alone, score 3.2 → 3.8🤖 Generated with Claude Code