Skip to content

feat: detect phantom dependencies#753

Open
goureeshreddy7 wants to merge 1 commit into
OWASP:mainfrom
goureeshreddy7:feat/phantom-dependencies
Open

feat: detect phantom dependencies#753
goureeshreddy7 wants to merge 1 commit into
OWASP:mainfrom
goureeshreddy7:feat/phantom-dependencies

Conversation

@goureeshreddy7

Copy link
Copy Markdown
Collaborator

Fixes #731

What does this PR do? Implements the Phantom Dependency detection engine to catch unlisted imports that break strict environments like Vercel deployments (PD001 and PD002).

Key Changes:

AST Import Scanner: Upgraded scanProjectForPackageUsage in src/usage/scanner.ts to capture all bare module imports across the source code rather than just a pre-filtered list.
Overrides parsing: Added readOverridesAndResolutions to src/utils/package-json.ts to properly parse the overrides and resolutions blocks.
Cross-Referencing: Updated src/index.ts to cross-reference the import map against the declared dependencies.
Ranked Output: Output is ranked by build impact as requested, with strict deploy-breakers (PD001 - override pins) surfaced above standard transitive ghosts (PD002).

Testing: Verified locally that the CLI correctly catches ghost dependencies and exits with an error code, effectively stopping the build before deployment.

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.

feat: detect phantom dependencies - packages imported but not declared (PD001/PD002)

1 participant