简体   繁体   English

公共 NPM 注册表是否验证上传的 tarball 的校验和?

[英]Does the public NPM registry validate the checksums of uploaded tarballs?

I recently witnessed an instance of a corrupted package version being published to the npm registry.我最近目睹了一个损坏的 package 版本被发布到 npm 注册表的实例。 I've found many questions around what to do in this event (ie republish the package), but few around "What causes it to happen in the first place?"我发现很多关于在这个事件中做什么(即重新发布包)的问题,但很少有关于“什么导致它首先发生?”的问题。

In my case (which I sadly can't share - private organizational scope, etc etc), pulling the tarball with npm pack reveals that the file is indeed incomplete/corrupt, and does not match the expected checksum.在我的情况下(遗憾的是,我无法分享 - 私人组织 scope 等),使用npm pack提取 tarball 显示该文件确实不完整/损坏,并且与预期的校验和不匹配。

The npm publish payload includes a dist.Integrity field with a SHA-512 checksum, alongside each package upload. npm publish负载包括一个带有 SHA-512 校验和的dist.Integrity字段,以及每个 package 上传。 This might be a bit difficult to answer given its closed-source nature - But does the NPM registry do any validation on its side, to check that the uploaded contents actually match the checksum, before making the package version available for consumption?鉴于其闭源性质,这可能有点难以回答 - 但是 NPM 注册表是否会对其进行任何验证,以检查上传的内容是否与校验和匹配,然后再使 package 版本可供使用?

Thanks in advance!提前致谢!

Follow-up: Yes, it does.追问:是的,确实如此。 I verified this by capturing an npm upload payload and changing the dist.integrity checksum.我通过捕获npm upload有效负载并更改dist.integrity校验和来验证这一点。 NPM correctly diagnosed the checksum mismatch, and refused the package. NPM 正确诊断校验和不匹配,拒绝 package。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 列出 npm 注册表中的所有公共包 - List all public packages in the npm registry NPM 坚持使用 CodeArtifact,甚至在公共注册表上 - NPM insists on CodeArtifact, even on public registry npm 似乎忽略了我的私有模块和针对公共注册表的 404 - npm seems to ignore my private module and 404 against the public registry 为什么从 npm 注册表中删除 package 到 npm 后,使用 `npm publish` 无法正常工作? - Why does republishing a package to npm with `npm publish` not work after removing it from the npm registry? “ npm设置注册表https://registry.npmjs.org/”有什么作用? - What does “npm set registry https://registry.npmjs.org/” do? 无法使用 Github Actions 从 Github Package Registry 安装公共 NPM 包 - Unable to install public NPM-package from Github Package Registry using Github Actions 您配置的注册表不支持审计请求~关于 npm 审计 - Your configured registry does not support audit requests ~ On npm audit NPM 注册表在全球传播需要多长时间? - How long does it take for NPM registry to propagate globally? Visual Studio 2017 npm软件包intellisense找不到私有npm注册表中的软件包 - Visual studio 2017 npm package intellisense does not find package from private npm registry 有没有一种方法可以使用哈希/校验和来确保已发布的npm软件包的完整性? - Is there a way to assure the integrity of a published npm packages, using hashes/checksums?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM