Skip to content
New issue

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

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

Already on GitHub? # to your account

Update snyk parser and added tests for yarn berry #793

Merged
merged 4 commits into from
Aug 7, 2023

Conversation

ethriel3695
Copy link
Contributor

I've had a couple of users reach out saying that the manifest dependency tracing does not work for yarn berry.

It appears that yarn2 / lockfile v2 with resolutions is specifically what is not working.

Given a package.json with a resolution like so:
"resolutions": {
  "chalk": "^4.1.2"
}

In v1, yarn would list every version of chalk needed by the various dependencies and then specify the resolved version.

In v2, this has been reduced to just the forced version.

OutOfSyncError: Dependency chalk@^4.1.2 was not found in yarn.lock. 
Your package.json and yarn.lock are probably out of sync. Please run "yarn install" and try again.

Recent versions of https://github.com/snyk/nodejs-lockfile-parser have changed how lockfile v2 is parsed.

I also added tests to verify that the yarn berry lock file format is read successfully, and, changes between v2 lock files are detected as expected.

Screen Shot 2023-07-26 at 4 11 30 PM

@ethriel3695
Copy link
Contributor Author

@ghengeveld @tmeasday

I updated the lock files to match the resolution format and the structure for yarn berry in pnp mode.
I also added tests to verify the behavior and verify we trace the packages correctly.

Please let me know what you think.

Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

LGTM! thanks for updating the tests.

Do we have a sample repo we can test this against?

@ghengeveld ghengeveld merged commit dbd5be8 into main Aug 7, 2023
@ghengeveld ghengeveld deleted the update-snyk-parser branch August 7, 2023 10:37
@ghengeveld
Copy link
Member

Released in 6.21.0.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants