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

feat(checksums): add integrity field with sha512 authentication to yarn.lock #5042

Merged
merged 68 commits into from
Aug 1, 2018

Conversation

imsnif
Copy link
Member

@imsnif imsnif commented Dec 5, 2017

Summary
Continuing the discussion in: #816
This turned out to be a feature that touched quite a few parts of the code base. The diff is a little big, mostly because this required (minor) changes in a lot of the tests and fixtures (since we've added a new field to yarn.lock).

I tried to adjust the commits to "tell a story", to make this PR easier to follow. That being said, if anything is unclear, I would be happy to explain or adjust it to make it more understandable (I have made an effort to do so in the code as much as possible).

Since this is not a trivial change, what guided me through it is the will to concentrate on it as much as possible without changing other things. Thus for example, I did not change the validationStream in other non-tarball fetchers to use the ssri module, even though it creates an inconsistency, so as not to distract from the feature at hand. I think this PR does introduce some wanted changes (such as the stream example) but I believe they are all very minor, and would be best fixed in additional refactoring PRs (that I or someone else will perform once this is approved and merged).

Test plan
I added both integration and unit tests where appropriate.
Please note though: since there are no tests for publish (unless I missed them!) I did not add tests, because I felt it would be out of scope. I tested this manually with verdaccio and it worked. I would urge the reviewer to do the same to make sure I was not mistaken!

@buildsize
Copy link

buildsize bot commented Dec 5, 2017

File name Previous Size New Size Change
yarn-[version].noarch.rpm 915.45 KB 919.92 KB 4.47 KB (0%)
yarn-[version].js 4 MB 4.02 MB 16.54 KB (0%)
yarn-legacy-[version].js 4.17 MB 4.18 MB 17.6 KB (0%)
yarn-v[version].tar.gz 920.73 KB 924.87 KB 4.14 KB (0%)
yarn_[version]all.deb 671.45 KB 675.1 KB 3.65 KB (1%)

@imsnif
Copy link
Member Author

imsnif commented Dec 5, 2017

Regarding CI issues: The issues on previous versions of node in appveyor seem to be mostly due to different behaviour of the Buffer object. These can be trivially remedied and I'll get to them in the next few days.
Regarding the failed circleci builds: I'm not quite sure what the issue is here. It seems not to recognize the ssri module. Is there some sort of caching involved? Any tips on debugging this?

@zkat
Copy link
Contributor

zkat commented Dec 6, 2017

I recommend you make sure your tests also check that this behaves if you hand it an integrity field with sha384-deadbeef, sha3-c0ffee, and madeupalgorithm-abad1dea, and that things still work in those cases.

I also recommend you add tests to make sure ?option syntax is handled reasonably well: sha1-deadbeef?foo and sha512-deadbeefc0ffee?key=value1234!@# should both be ok.

@imsnif
Copy link
Member Author

imsnif commented Dec 6, 2017

Thanks @zkat ! I'll add those test cases (the madeupchecksum scenario would even require a small code adjustment to get a proper error message).
Would love to hear more comments.

@imsnif
Copy link
Member Author

imsnif commented Dec 8, 2017

Hey @zkat - I added the test cases (and made the relevant code changes) you mentioned. If you have the time and feel like commenting, I'd very much appreciate it!

@BYK - the CircleCI builds for node6 and node8 are failing. I think this is because they cache node_modules and I added the ssri module which they thus do not see. I do not have permission to clear the cache. If you have time to take a look, it would be great! I fixed the other issues that made some builds fail previously.

@BYK BYK requested review from arcanis, BYK and bestander December 8, 2017 13:52
@BYK
Copy link
Member

BYK commented Dec 8, 2017

@imsnif thanks a lot for the PR and heads up about the cache issues. I've submitted #5060 to fix the invalid cache setup. You can merge from that and see if it fixes your builds. Or wait until it lands on master and merge from there.

Right now, as long as Linux tests pass, I'm okay until right before merging.

@imsnif
Copy link
Member Author

imsnif commented Dec 8, 2017

Thanks @BYK ! I think I'll wait with merging (either from #5060 or from master) until we finish discussing this, seeing as you're okay with it. I have a feeling it will make reviewing this easier. :)

@BYK
Copy link
Member

BYK commented Dec 8, 2017

@imsnif merged to master. Merge from there and your builds should pass. I'll review the code later. I've also pinged a few more people since this is a fairly large change. Thanks a lot for all the effort you've put into this.

@BYK BYK self-assigned this Dec 8, 2017
@imsnif
Copy link
Member Author

imsnif commented Feb 22, 2018

@BYK @arcanis @bestander - Hello friends! I hope you don't mind me making this public ping regarding the review progress. I'd very much like to continue working on this and see it merged. Hoping we'll find time soon!

@bestander
Copy link
Member

@imsnif, thanks for pinging, this is a right thing to do, no need to apologize.
Could you rebase the PR to merge conflicts

Copy link
Member

@bestander bestander left a comment

Choose a reason for hiding this comment

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

Amazing work on fixing all the tests, thanks @imsnif!

This PR looks fine to me.
@BYK @arcanis @Daniel15 you've had more context on this feature, any concerns?

@imsnif
Copy link
Member Author

imsnif commented Feb 26, 2018

Hey @bestander , thanks!
I rebased and pushed (as you can see) there are some non-trivial conflicts (namely the offline mirror feature makes some assumptions that contradict some of my assumptions when making this PR). :) It's no biggy though, I started working on it and hoping to update and have this fixed tonight or tomorrow. Will keep this thread posted.

@imsnif
Copy link
Member Author

imsnif commented Aug 1, 2018

Thanks @arcanis and @BYK! Great to see this merged.
Been a fun ride. :)

epaminond pushed a commit to botpress/botpress that referenced this pull request Oct 1, 2018
The hashes are added automatically when you run the latest Yarn version. So good to get this merged so it won't show up as added lines when people run `$ yarn` in the repo. It doesn't change any functionality. This is merely to reduce noise.

More info: yarnpkg/yarn#5042
IvanGoncharov added a commit to IvanGoncharov/graphql-js that referenced this pull request Oct 1, 2018
Field was added in yarn@1.1.0.
See yarnpkg/yarn#5042 for more information.
tigefa4u pushed a commit to tigefa4u/gitlabhq that referenced this pull request Oct 1, 2018
yarn >= 1.10.0 adds sha512 integrity checks to the yarn.lock file. For
more details see yarnpkg/yarn#5042. The
behaviour is backwards compatible.
karlhorky added a commit to uselagoon/lagoon that referenced this pull request Oct 2, 2018
IvanGoncharov added a commit to graphql/graphql-js that referenced this pull request Oct 2, 2018
The field was added in yarn@1.1.0.
See yarnpkg/yarn#5042 for more information.
It fully compatible with previous versions of Yarn
gnprice added a commit to zulip/zulip-mobile that referenced this pull request Oct 10, 2018
Yarn 1.10.x adds these by default any time you run `yarn`.  There's
not a lot in the way of release notes, but see yarnpkg/yarn#5042 .
Sounds like a good idea!

And they're said to be backward compatible with older versions of
`yarn`, as you'd hope.  So, go ahead and add them.
intelliot added a commit to XRPLF/xrpl.js that referenced this pull request Oct 16, 2018
legenddam added a commit to legenddam/nodejs_admim_client that referenced this pull request Feb 25, 2020
Heather0303 pushed a commit to Heather0303/keycloak-nodejs-admin-client that referenced this pull request Apr 3, 2020
HappyVirgo added a commit to HappyVirgo/nodejs-admin-client that referenced this pull request Jul 27, 2021
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.

6 participants