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

Errors parsing yarn.lock files with quoted properties #249

Closed
spencerschrock opened this issue Feb 27, 2023 · 2 comments · Fixed by #250
Closed

Errors parsing yarn.lock files with quoted properties #249

spencerschrock opened this issue Feb 27, 2023 · 2 comments · Fixed by #250
Assignees
Labels
bug Something isn't working

Comments

@spencerschrock
Copy link
Contributor

spencerschrock commented Feb 27, 2023

Scorecard currently calls DoScan here when checking for vulns. When we scan public repos, we sometimes encounter yarn.lock files that write hundred of lines to os.Stderr due to the issue discussed in #102 and #142.

Here are a few of the offending files that we've encountered:
https://github.com/Glissir/react-trello/blob/565dd41fd2263787412b6e131c9f21b26c7204cd/yarn.lock
https://github.com/nodeWechat/wechat4u/blob/93972863435ba0cfe98c316bbe6b739da390897d/yarn.lock

#102 mentioned being unable to reproduced with yarn, but a few search results have mentioned the issue is caused when npm manipulates the yarn.lock file:

npm/cli#5126

https://stackoverflow.com/q/74272832
https://bstefanski.com/upgrading-one-dependency-causes-whole-yarnlock-change-fix

@G-Rath G-Rath self-assigned this Feb 27, 2023
@oliverchang oliverchang added the bug Something isn't working label Feb 28, 2023
@andrewpollock
Copy link
Contributor

Drive-by observation: from reading https://bstefanski.com/upgrading-one-dependency-causes-whole-yarnlock-change-fix something is very wrong with a tool that makes unnecessary wholesale changes to the file like that. Makes reviewing changes unnecessarily onerous and provides an easy opportunity for a bad actor to slip in something under the reviewer's radar...

From a quick search, this sounds like yarnpkg/yarn#4953, which has been open for a concerning amount of time...

@G-Rath
Copy link
Collaborator

G-Rath commented Feb 28, 2023

Ok it looks like this is because npm v7+ formats yarn.lock in a technically valid but slightly different way to yarn v1 (I swear I tested that when I wrote the parser originally, but I guess not 🤷) - so long as you use the same tool, you shouldn't see huge diffs, it's only if you switch between npm and yarn that the lockfile will change dramatically.

I've created #250 to fix this

another-rex pushed a commit that referenced this issue Mar 1, 2023
Resolves #249

This files are actually valid, and generated by npm v7+
hayleycd pushed a commit that referenced this issue Mar 9, 2023
Resolves #249

This files are actually valid, and generated by npm v7+
julieqiu pushed a commit to julieqiu/osv-scanner that referenced this issue May 2, 2023
Resolves google#249

This files are actually valid, and generated by npm v7+
julieqiu pushed a commit to julieqiu/osv-scanner that referenced this issue May 2, 2023
Resolves google#249

This files are actually valid, and generated by npm v7+
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.

4 participants