我在 github 中的存储库显示以下警报:
Dependabot 无法将 ssri 更新到无漏洞版本。由于以下依赖项冲突,可以安装的最新可能版本是 6.0.1:
ter[email protected] requires ssri@^7.0.0 via [email protected]
[email protected] requires ssri@^6.0.1 via a transitive dependency on [email protected]
最早的修复版本是8.0.1。
据我所知,我应该将 package.json 中的根包(即 terser-webpack-plugin)更新为较新的版本,但是如何确定可以支持依赖项的非易受攻击版本的最低版本(在本例中为 ssri 8.0.1),因为我不想更新到太高的版本并冒破坏事物的风险。我正在考虑手动检查 terser-webpack-plugin 的所有发行版本,但这样检查非常繁琐,而且似乎是错误的。有什么建议吗?
最佳答案
为了加快进程并节省安装每个版本及其关联的依赖关系树,我们可以使用 npm-remote-ls
( https://stackoverflow.com/a/26005786/2815338 )
首先获取可用版本列表:
> npm view terser-webpack-plugin versions
[
'1.0.0', '1.0.1', '1.0.2', '1.1.0', '1.2.0',
...
然后为当前版本之后的每个版本运行 npm-remote-ls
并过滤相关依赖项,例如
> npm-remote-ls <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f88c9d8a8b9d8ad58f9d9a88999b93d588948d9f9196b8cbd6c8d6c8" rel="noreferrer noopener nofollow">[email protected]</a> | grep ' ssri@'
??? ?????? <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7c0f0f0e153c44524c524d" rel="noreferrer noopener nofollow">[email protected]</a>
??? ??? ??? ?????? <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="621111100b22544c524c50" rel="noreferrer noopener nofollow">[email protected]</a>
在本例中[email protected]是第一个只有固定版本的 ssri (8.0.1),5.1.0 似乎根本不包含 ssri,大概是因为 webpack 不再依赖 cacache。
注意问号似乎是由于 npm-remote-ls 用于显示树结构的字符编码所致。您还可以在 PowerShell 中使用 Select-String
,但这似乎会显示不同(不正确)的字符。
关于npm - 更新 NPM 中的依赖项以解决漏洞,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66884019/