Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: yarn npm audit mismatches a dependency version #5408

Closed
1 task done
joostvdwsd opened this issue Apr 25, 2023 · 0 comments · Fixed by #5501
Closed
1 task done

[Bug?]: yarn npm audit mismatches a dependency version #5408

joostvdwsd opened this issue Apr 25, 2023 · 0 comments · Fixed by #5501
Labels
bug Something isn't working

Comments

@joostvdwsd
Copy link

joostvdwsd commented Apr 25, 2023

Self-service

  • I'd be willing to implement a fix

Describe the bug

Scenario:

  • workspace depends on package@fixed version
  • subdependency of workspace depends on same package@vulnerable version

Expected results

yarn npm audit -> no issues
yarn npm audit -R -> issue on package

Actual real life results:

yarn why yaml

├─ patch-package@npm:6.5.1
│  └─ yaml@npm:1.10.2 (via npm:^1.10.2)
│
└─ yarnissue@workspace:.
   └─ yaml@npm:2.2.2 (via npm:^2.2.2)

yarn npm audit

└─ yaml: 1.10.2
   ├─ ID: 1091814
   ├─ Issue: Uncaught Exception in yaml
   ├─ URL: https://github.com/advisories/GHSA-f9xv-q969-pqx4
   ├─ Severity: moderate
   ├─ Vulnerable Versions: <2.2.2
   ├─ Patched Versions: >=2.2.2
   ├─ Via: yaml
   └─ Recommendation: Upgrade to version 2.2.2 or later

Tried to attach a sherlock but the vm was crashing. Included a repoducable package.json

To reproduce

{
"name": "yarnissue",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"patch-package": "6.5.1",
"yaml": "2.2.2"
},
"packageManager": "yarn@3.5.0"
}
yarn
yarn why yaml
yarn npm audit

Environment

System:
    OS: macOS 12.6.1
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 14.21.1 - /private/var/folders/v2/8k7t9jzj0ts0w2l2n72v2g6nc928z9/T/xfs-34fccac8/node
    Yarn: 3.5.0 - /private/var/folders/v2/8k7t9jzj0ts0w2l2n72v2g6nc928z9/T/xfs-34fccac8/yarn
    npm: 6.14.18 - ~/.nvm/versions/node/v14.21.1/bin/npm

Additional context

No response

@joostvdwsd joostvdwsd added the bug Something isn't working label Apr 25, 2023
joostvdwsd pushed a commit to joostvdwsd/yarn-berry that referenced this issue Apr 25, 2023
arcanis added a commit that referenced this issue Jun 16, 2023
**What's the problem this PR addresses?**

The current audit implementation uses the older `/audit/quick` endpoint,
which has various problems. One particular is that its design requires
to submit a nested payload, but since it doesn't make much sense in our
case (because most of Yarn installs are flat), we flatten the package
list. It causes problems when multiple packages with different versions
can be found in the tree.

Fixes #3861
Fixes #4117 
Fixes #5408

Closes #5409 (Supercedes it)

---
Edit by @merceyz 

Fixes #5450
Fixes #2507
Fixes #3778
Fixes #3945
Closes #5309 (Doesn't have a reproduction so I'm assuming it's the same
as the others)

---

**How did you fix it?**

This change rewrites `yarn npm audit` to use the new endpoint. As part
of the migration a couple of fields are reworked (`Via` is replaced by
`Dependents`, the versions are now part of a tree item rather than
concatenated, we don't get the "recommendation" anymore). The options
remain the same for now.

It's possible that some registries don't support the bulk endpoint.
Given that it's fairly straightforward to implement, that it's been
released for some time now, and that without it we would end up with an
invalid `audit` implementation, I'd tend to let them deal with that.

**Checklist**
<!--- Don't worry if you miss something, chores are automatically
tested. -->
<!--- This checklist exists to help you remember doing the chores when
you submit a PR. -->
<!--- Put an `x` in all the boxes that apply. -->
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).

<!-- See
https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released
for more details. -->
<!-- Check with `yarn version check` and fix with `yarn version check
-i` -->
- [x] I have set the packages that need to be released for my changes to
be effective.

<!-- The "Testing chores" workflow validates that your PR follows our
guidelines. -->
<!-- If it doesn't pass, click on it to see details as to what your PR
might be missing. -->
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant