feat: OA009 stale floor detector#770
Open
sonukapoor wants to merge 20 commits into
Open
Conversation
15 cases covering: fires for >= and ^ floor when all parents meet it, fires for exact-version and >= parent ranges, silent for partial parent coverage, empty parents, missing installed version, concrete pins, floating tags, ~ and > operators (out of scope v1), nested object values, unparseable parent ranges, and skippedDetectors bypass.
Detects override entries using >= or ^ floor ranges where every parent package already declares a minimum version meeting or exceeding the floor. When all parents independently enforce the floor, the override is redundant and safe to remove. Emits a low-severity finding with an rfc6902 remove patch and a runnable fix command. Skips: concrete version pins (OA004 territory), floating tags, ~ and > operators (out of scope v1), nested object values, missing installed versions, empty parent declarations, and unparseable parent range specs (conservative - returns false rather than assuming floor met).
After applying patches, filter applied findings from the terminal table and remaining-findings check so the output only shows issues still needing attention. Exit code also now reflects post-fix state.
…nclude the scanned path
… after pruning lands
OA009 was absent from the OA_RULES constant in override-findings-sarif.ts. SARIF consumers (GitHub Code Scanning, SARIF Multitool) would encounter a result referencing a rule with no matching entry in the extension component, breaking validation. Updated the test assertion to cover OA001-OA009.
walkInstalledTree only reads node_modules manifests and never sees the root package.json. When the root project is the sole direct consumer of an overridden package (no transitive package also declares it), parentDeclarations was empty and OA009 skipped the entry. seedRootDeclarations() now seeds dependencies, devDependencies, optionalDependencies, and peerDependencies from the root into parentDeclarations before the detectors run. This is also the correct foundation for PD001/PD002 and DM001 which share the same context.
When the override is ^4.2.0 and a parent declares ^5.0.0, coerceVersion strips the operator and compareVersions(5.0.0, 4.2.0) returns >= 0, causing OA009 to fire. But ^4.2.0 means >=4.2.0 <5.0.0 and ^5.0.0 means >=5.0.0 <6.0.0 - the ranges do not overlap, so removing the override would change the resolved version from 4.x to 5.x. Added a majorOf() guard: when the override uses ^, each parent must also be in the same major before it counts as meeting the floor. Added a test case covering the cross-major non-firing case.
Extends detectors.test.ts to cover OA009 through the real CLI binary. Uses the existing examples/oa009-stale-floor fixture (build-tool@2.0.0 declares semver ^7.5.4; override semver >=5.7.2 is therefore redundant). Asserts the finding fires, package name, severity, and the remove patch. No temp directory needed - the fixture already has the full node_modules structure.
b318916 to
ae9125e
Compare
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.
Adds OA009 (stale override floor) to the override hygiene auditor - the ninth and final rule in the OA series.
OA009 fires when a
>=or^range floor in an override is already met by every parent declaration, making the override have no net effect on the resolved version. Safe to remove automatically.What changed
--fix, the now-emptyoverrides/pnpm.overridescontainer is also removed frompackage.jsonrather than leaving"overrides": {}.(e.g.cve-lite ./apps/web overrides --fix --rule OA009)cve-lite <path> overrides [flags]now works alongsidecve-lite overrides <path> [flags]; both orderings are acceptedCloses #730