Skip to content

fix: improve consistency of results from YarnAuditAnalyzer - #8768

Open
chadlwilson wants to merge 2 commits into
dependency-check:mainfrom
chadlwilson:conservative-yarn
Open

fix: improve consistency of results from YarnAuditAnalyzer#8768
chadlwilson wants to merge 2 commits into
dependency-check:mainfrom
chadlwilson:conservative-yarn

Conversation

@chadlwilson

@chadlwilson chadlwilson commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Description of Change

Improves consistency of results from invoking yarn (via direct install or corepack) by ensuring use of the ODC environment-defined yarn version (via path or corepack validation)

  • The standard Yarn environment variable escape hatch is available to opt back into earlier behaviour.
  • Regenerated and minimised the test lockfiles to avoid needing to query the npm audit API for dependencies that aren't actually asserted against in tests.

Have test cases been added to cover the new functionality?

yes

@boring-cyborg boring-cyborg Bot added core changes to core tests test cases labels Aug 24, 2026
@chadlwilson
chadlwilson requested review from jeremylong and a balanced review from Copilot August 24, 2026 09:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chadlwilson
chadlwilson force-pushed the conservative-yarn branch 2 times, most recently from 6d4d6b2 to 6926258 Compare August 25, 2026 05:57
@chadlwilson
chadlwilson requested a balanced review from Copilot August 25, 2026 07:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 17 changed files in this pull request and generated 2 comments.

Comment thread core/src/main/java/org/owasp/dependencycheck/analyzer/YarnAuditAnalyzer.java Outdated
Comment thread core/src/main/java/org/owasp/dependencycheck/analyzer/YarnAuditAnalyzer.java Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 19 changed files in this pull request and generated 1 comment.

Suppressed comments (2)

core/src/main/java/org/owasp/dependencycheck/analyzer/YarnAuditAnalyzer.java:270

  • fetchYarnAdvisories now invokes yarn npm audit and no longer passes --offline, but the method Javadoc above still documents yarn audit --offline and says it generates a payload for the NPM API. Update that Javadoc to describe the actual command and behavior so maintainers are not misled.
        final String advisoriesJsons = startAndReadStdoutToString(createYarnBuilder(getDependencyDirectory(dependency.getActualFile()), args));

core/src/test/resources/yarn/yarn-classic-audit/package.json:19

  • This fixture no longer declares marked after the dependency minimization, so the retained comment block above is now false and misleading. Please remove it or replace it with a comment describing the remaining fixture dependency.
    "swig": "1.4.2"

Comment thread src/site/markdown/analyzers/yarn-audit.md Outdated
@chadlwilson
chadlwilson force-pushed the conservative-yarn branch 3 times, most recently from be63cf3 to 9c6348f Compare August 26, 2026 05:05
@chadlwilson
chadlwilson requested a lite review from Copilot August 26, 2026 05:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 19 changed files in this pull request and generated 6 comments.

Suppressed comments (1)

core/src/test/java/org/owasp/dependencycheck/analyzer/YarnAuditAnalyzerIT.java:110

  • The env var name is duplicated as a string literal. Using YarnAuditAnalyzer.YARN_ENV_IGNORE_PATH avoids drift if the production constant ever changes.
            try (MockedStatic<SystemUtils> systemMock = mockStatic(SystemUtils.class)) {
                systemMock.when(() -> SystemUtils.getEnvironmentVariable("YARN_IGNORE_PATH", null)).thenReturn(envValue);

Comment thread core/src/main/java/org/owasp/dependencycheck/analyzer/YarnAuditAnalyzer.java Outdated
Comment thread core/src/main/java/org/owasp/dependencycheck/analyzer/YarnAuditAnalyzer.java Outdated
Comment thread src/site/markdown/analyzers/yarn-audit.md
Comment thread src/site/markdown/analyzers/index.md
Signed-off-by: Chad Wilson <29788154+chadlwilson@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 19 changed files in this pull request and generated 4 comments.

Comment thread core/src/main/java/org/owasp/dependencycheck/analyzer/YarnAuditAnalyzer.java Outdated
Comment thread core/src/test/resources/yarn/yarn-classic-audit/package.json
Comment thread src/site/markdown/analyzers/yarn-audit.md
Comment thread src/site/markdown/analyzers/index.md
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core changes to core documentation site documentation npm tests test cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants