fix: exclude deprecations from Yarn Berry audit results#8380
Draft
chadlwilson wants to merge 6 commits intodependency-check:mainfrom
Draft
fix: exclude deprecations from Yarn Berry audit results#8380chadlwilson wants to merge 6 commits intodependency-check:mainfrom
chadlwilson wants to merge 6 commits intodependency-check:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Yarn Berry audit integration to exclude deprecation findings from audit output (since they are not vulnerabilities and can produce malformed entries), and improves diagnostics when Yarn version detection fails.
Changes:
- Add
--no-deprecationsto the Yarn Berry (yarn npm audit) invocation to prevent deprecation items from appearing in results. - Improve Yarn version detection failure reporting by including process exit code and captured output.
- Update/add Yarn Berry test fixtures and integration tests to cover “no vulnerabilities”, “exclude deprecations”, and “bad yarnPath/packageManager” scenarios.
Reviewed changes
Copilot reviewed 11 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/main/java/org/owasp/dependencycheck/analyzer/YarnAuditAnalyzer.java | Adds --no-deprecations and improves yarn version failure diagnostics. |
| core/src/test/java/org/owasp/dependencycheck/analyzer/YarnAuditAnalyzerIT.java | Refactors Yarn audit ITs, adds new Berry test cases for deprecations and bad configuration. |
| core/src/test/resources/yarn/yarn-berry-audit/package.json | Bumps test fixture packageManager Yarn version. |
| core/src/test/resources/yarn/yarn-berry-audit/.yarnrc.yml | Updates Yarn Berry config used by the fixture. |
| core/src/test/resources/yarn/yarn-berry-audit-no-vulnerability/package.json | Bumps test fixture packageManager Yarn version. |
| core/src/test/resources/yarn/yarn-berry-audit-no-vulnerability/.yarnrc.yml | Updates Yarn Berry config used by the fixture. |
| core/src/test/resources/yarn/yarn-berry-audit-no-vulnerability/.yarn/install-state.gz | Adds/updates Yarn state for fixture execution. |
| core/src/test/resources/yarn/yarn-berry-audit-no-deprecations/* | Adds a minimal fixture used to verify deprecations are excluded. |
| core/src/test/resources/yarn/yarn-berry-audit-bad-package-manager/* | Adds a fixture used to validate improved error reporting for misconfigured Yarn. |
| core/src/test/resources/yarn/.gitignore | Ignores .yarn/ and node_modules/ under yarn test resources. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
core/src/main/java/org/owasp/dependencycheck/analyzer/YarnAuditAnalyzer.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/owasp/dependencycheck/analyzer/YarnAuditAnalyzerIT.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/owasp/dependencycheck/analyzer/YarnAuditAnalyzer.java
Outdated
Show resolved
Hide resolved
7596b82 to
3a03063
Compare
…ntrolling yarn The required version can be dynamically downloaded. Source controlling it is not necessary. Signed-off-by: Chad Wilson <29788154+chadlwilson@users.noreply.github.com>
Signed-off-by: Chad Wilson <29788154+chadlwilson@users.noreply.github.com>
If your yarn config/.yarnrc.yml, package.json or corepack setup is incorrect; the `yarn` stub can fail for a number of reasons and some are specific to ODC. Signed-off-by: Chad Wilson <29788154+chadlwilson@users.noreply.github.com>
…r pnpm/yarn/npm testing Signed-off-by: Chad Wilson <29788154+chadlwilson@users.noreply.github.com>
b01d0b6 to
d6104d3
Compare
Collaborator
Author
|
This is OK now, but I am still working on the error handling for fallback to Yarn Classic to see if it can be improved. |
…c on Yarn Berry project This can happen currently when users are relying on corepack to switch from Yarn 1 to Yarn 2+; but corepack is not enabled or on the path correctly. A better approach would be more reliable Yarn version detection (from intent), but this improves the situation by improving the feedback to users to more than an opaque `IllegalArgumentException`. Signed-off-by: Chad Wilson <29788154+chadlwilson@users.noreply.github.com>
No need to use a separate `--help`, and we can reduce synchronization by doing so during analyzer preparation phase. Signed-off-by: Chad Wilson <29788154+chadlwilson@users.noreply.github.com>
cb6615e to
620e9d5
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.
Description of Change
Currently deprecations are included within the yarn berry results. They do not format properly, and there seems to be some API consistency as to when they are included/excluded leading to some inconsistency in ODC results from one run to another.
They do not format properly as they are missing normal metadata/descriptions and have null
vulnerabilityNames, no identifiers etc so you can't suppress them properly either. (Suppressing vulnerablityName = null is very dodgy)Since deprecated doesn't mean vulnerable; and I think ODC should focus on vulnerabilities (outside dedicated analyzers such as retirejs); although my main concern is that the scanning seems unstable and sometimes deprecations will be included, and sometimes excluded from the API.
Also improves the error reporting when the correct yarn version cannot be determined, e.g due to misconfiguration.
Related issues
N/A
Have test cases been added to cover the new functionality?
yes
The
--no-deprecationsflag was introduced in Yarn 2.0 which means all Berry (2.0+) versions support it.