Add check to ensure we actually get our commit#439
Add check to ensure we actually get our commit#439
Conversation
|
This is introducing a new integrity check to pacote itself. Typically pacote doesn't actually do the integrity check. Its responsibility is to assign the integrity (if one exists) and let the consumer decide if it needs to be checked. You can see in the commit that removed this for git refs how we are bypassing it. You can also see where we are ignoring integrity altogether when we clone git repos. If I understand correctly what is happening here is nothing more than checking that if we have a resolvedSha (which we set to the value of the commit sha in the git reference), we fetched that sha. But ... that's how the code is already set up. We have to trust that if we ask for a ref that's what our code does. What is this protecting against? Editing the package.json without updating the lockfile? I think understanding HOW these could be different will help inform how we want to approach this, and from where we want to throw the error. Finally, when and if we do throw we need it to effectively be the same kind of error as an integrity error. So a code will need to be attached that is either |
Cloning in For example, these conditions will replace an existing
For me, there are two main cases where we already have a resolved sha:
We should protect the consumer of the cloned temporary directory from using a different commit than requested. This change only trusts |
|
Ok thanks for the detailed response. The only thing left then is to make sure we are attaching an appropriate code to the thrown error to help npm (and other consumers) inform the user better. |
I've enabled edits by maintainers, not sure what you need here |
|
Something like this: https://github.com/npm/cacache/blob/d171fe9c9f5ccdcd27a9c68e965ca6056de76f87/lib/content/read.js#L161
|
In npm/rfcs#525 about ignoring
integrityvalues in lockfiles it was stated:This is only true for resolutions from non-commits to commits.
A dependency like
git://...#4b559c4c663a23f988f6be5094c9a45faf6231bcwill be stored using the same "reference" inresolvedeven when it cloned a branch or a tag that resolved to a different sha.The update is only done if it hasn't been resolved yet, which is already the case if a full "commit" was specified:
pacote/lib/git.js
Lines 263 to 265 in 4b559c4
This also applies to
npm ciafter readingpackage-lock.jsonas it will use the same resolution.This will compare the newly returned commit-hash with a previously set
resolvedShaand prevent that from happening.