fix: reinstate the NodeAuditAnalyzer via use of npm audit via CLI - #8725
Draft
chadlwilson wants to merge 3 commits into
Draft
fix: reinstate the NodeAuditAnalyzer via use of npm audit via CLI#8725chadlwilson wants to merge 3 commits into
npm audit via CLI#8725chadlwilson wants to merge 3 commits into
Conversation
Signed-off-by: Chad Wilson <29788154+chadlwilson@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Reinstates Node Audit analysis using the local npm CLI, replacing the retired legacy audit API integration and addressing #8422.
Changes:
- Uses
npm auditandnpm lsfor vulnerability and dependency data. - Adds npm executable configuration across supported integrations.
- Removes legacy API code and adds npm audit v2 parser tests and documentation.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
utils/src/test/resources/dependencycheck.properties |
Removes the retired API URL. |
utils/src/main/java/org/owasp/dependencycheck/utils/Settings.java |
Deprecates the API URL and adds npm path configuration. |
src/site/markdown/dependency-check-gradle/configuration.md |
Updates Gradle Node Audit documentation. |
src/site/markdown/dependency-check-gradle/configuration-aggregate.md |
Updates aggregate Gradle documentation. |
src/site/markdown/analyzers/node-audit-analyzer.md |
Documents npm CLI requirements and supported files. |
src/site/markdown/analyzers/index.md |
Updates the Node Audit analysis method. |
maven/src/site/markdown/configuration.md |
Documents Maven npm path configuration. |
maven/src/main/java/org/owasp/dependencycheck/maven/BaseDependencyCheckMojo.java |
Wires Maven npm path settings. |
Dockerfile |
Enables and prepares npm through Corepack. |
core/src/test/resources/nodeaudit/npm-audit-report.json |
Adds an npm audit v2 fixture. |
core/src/test/resources/dependencycheck.properties |
Removes the retired test API URL. |
core/src/test/java/org/owasp/dependencycheck/data/nodeaudit/NpmPayloadBuilderTest.java |
Removes obsolete payload-builder tests. |
core/src/test/java/org/owasp/dependencycheck/data/nodeaudit/NpmCliAuditParserTest.java |
Tests npm audit v2 parsing. |
core/src/test/java/org/owasp/dependencycheck/data/nodeaudit/NodeAuditSearchTest.java |
Removes obsolete API search tests. |
core/src/main/resources/dependencycheck.properties |
Removes the retired URL default. |
core/src/main/java/org/owasp/dependencycheck/data/nodeaudit/package-info.java |
Updates package documentation. |
core/src/main/java/org/owasp/dependencycheck/data/nodeaudit/NpmPayloadBuilder.java |
Removes legacy API payload generation. |
core/src/main/java/org/owasp/dependencycheck/data/nodeaudit/NpmCliAuditParser.java |
Adds npm audit v2 report parsing. |
core/src/main/java/org/owasp/dependencycheck/data/nodeaudit/NodeAuditSearch.java |
Removes direct API communication. |
core/src/main/java/org/owasp/dependencycheck/data/nodeaudit/Advisory.java |
Centralizes GHSA extraction. |
core/src/main/java/org/owasp/dependencycheck/analyzer/YarnAuditAnalyzer.java |
Reuses centralized GHSA extraction. |
core/src/main/java/org/owasp/dependencycheck/analyzer/NodeAuditAnalyzer.java |
Runs npm audit and inventory commands. |
core/src/main/java/org/owasp/dependencycheck/analyzer/AbstractNpmAnalyzer.java |
Removes legacy search initialization. |
cli/src/site/markdown/arguments.md |
Documents the --npm option. |
cli/src/main/java/org/owasp/dependencycheck/CliParser.java |
Adds the npm path CLI argument. |
cli/src/main/java/org/owasp/dependencycheck/App.java |
Applies the CLI npm path setting. |
ant/src/site/markdown/configuration.md |
Documents Ant npm path configuration. |
ant/src/main/java/org/owasp/dependencycheck/taskdefs/Check.java |
Wires Ant npm path settings. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Description of Change
This reinstates the NodeAuditAnalyzer by implementing the approach suggested at #8422 (comment) to replace the manual package-lock parsing with use of
npm ls --json(inventory) andnpm audit --json(analysis).This has been largely done with guided use of Claude, alongside some tweaks and edits made by me, but still needs testing & validation of approach - and more careful review of the code. Initially raising a PR for transparency & feedback, and anyone who wants to help smoke test it, since the automated testing within ODC is probably somewhat limited.
I evaluated other approaches to avoid manual package-lock parsing and could not find any decent Java libraries to do so.
Design guidelines/constraints
npm ls --jsonfor full inventoryNodePackageAnalyzeris untouched, and still does manual parsing (although Claude found many bugs with this)TODO
NodePackageAnalyzerto ensure they still make sense.Related issues
Have test cases been added to cover the new functionality?
yes