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

Fix yarn lockfile with unknown resolvers #345

Merged
merged 4 commits into from
May 5, 2022
Merged

Fix yarn lockfile with unknown resolvers #345

merged 4 commits into from
May 5, 2022

Conversation

cd-work
Copy link
Contributor

@cd-work cd-work commented May 4, 2022

The yarn lockfile allows various different resolvers other than the
standard one which pulls from npm. Some of these include the filesystem
(@workspace), http/s (@http/s), and ssh (@ssh).

To ensure our parser is robust against all types of possible resolvers,
this patch checks for the presence of @npm to ensure that the
dependency can be resolved through npm. All other dependencies are
silently ignored.

This comes with the trade-off that it is easier for a failure to parse a
dependency, that can be resolved through npm, to be hidden from the
user, opening up the possibility for hidden vulnerabilities. It also
assumes that no package scope starts with @npm, otherwise the parser
might throw an error.

Closes #344.

@cd-work cd-work requested a review from a team May 4, 2022 18:37
@cd-work cd-work requested a review from a team as a code owner May 4, 2022 18:37
louislang
louislang previously approved these changes May 4, 2022
matt-phylum
matt-phylum previously approved these changes May 4, 2022
Copy link
Contributor

@kylewillmon kylewillmon left a comment

Choose a reason for hiding this comment

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

At a minimum, I think we need to print a warning for any packages that we ignore.

I've put additional concerns on the related issue (#344)

kylewillmon
kylewillmon previously approved these changes May 5, 2022
The yarn lockfile allows various different resolvers other than the
standard one which pulls from npm. Some of these include the filesystem
(@workspace), http/s (@http/s), and ssh (@ssh).

To ensure our parser is robust against all types of possible resolvers,
this patch checks for the presence of `@npm` to ensure that the
dependency can be resolved through npm. All other dependencies are
silently ignored.

This comes with the trade-off that it is easier for a failure to parse a
dependency, that can be resolved through npm, to be hidden from the
user, opening up the possibility for hidden vulnerabilities. It also
assumes that no package scope starts with `@npm`, otherwise the parser
might throw an error.

Closes #344.
This is a complete change in how the yarn v2 parser parses the
resolution field, which should hopefully both make the parser simpler
and more error-resistent.

Instead of complex splitting logic, the parser now makes use of the fact
that dependencies inclued at most one `@` at the beginning of their
name, thus clearly identifying the resolver as anything past the second
`@`.

The supported resolvers are now explicitly handled by checking the
format of the resolution's resolver, an unrecognized resolver will cause
an error.
@cd-work cd-work requested a review from kylewillmon May 5, 2022 20:29
@cd-work cd-work merged commit db3e281 into main May 5, 2022
@cd-work cd-work deleted the remoteyarn branch May 5, 2022 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for yarn v2 remote dependencies
4 participants