我安装了一个名为 bbfy@0.1.0
的 npm 包,在 npm 的部分输出中说:
found 1 high severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
所以我运行 npm audit fix
但它说它无法修复它:
fixed 0 of 1 vulnerability in 202 scanned packages
1 vulnerability required manual review and could not be updated
所以我运行 npm audit 并收到此消息:
$ npm audit
=== npm audit security report ===
Manual Review
Some vulnerabilities require your attention to resolve
Visit https://go.npm.me/audit-guide for additional guidance
High Arbitrary Code Execution
Package underscore
Patched in >=1.12.1
Dependency of bbfy
Path bbfy > underscore
More info https://npmjs.com/advisories/1674
found 1 high severity vulnerability in 202 scanned packages
1 vulnerability requires manual review. See the full report for details.
所以我转到引用的网页,它告诉我将 underscore
升级到“版本 1.12.1 或 1.13.0-2 或更高版本”,所以我运行此命令:
$ npm i underscore@1.13.0-2
[snip]
+ underscore@1.13.0-2
updated 1 package and audited 202 packages in 2.726s
[snip]
found 1 high severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
但仍在提示 1 个漏洞。我检查了 npm audit
及其相同的下划线漏洞。那么我是否解决了问题?如果我没有,是哪里出了问题?
最佳答案
NPM 将安装一个包的多个副本,以满足依赖它的包(包括您自己的顶层项目)中的冲突版本要求。
因为 bbfy
包依赖于那个旧版本,所以安装了一个旧的、易受攻击的 underscore
版本。您的 npm i
命令所做的是在您请求的更高版本中安装另一个单独的 underscore
副本。 (你可以删除那个,除非你将在你的项目中直接使用 underscore
。)
因为 bbfy
已经五年没有更新了,解决这个问题的唯一方法是用 npm shrinkwrap
覆盖依赖关系。 . (这可能会产生损坏的代码,但我怀疑 underscore
从 1.8 到 1.12 是否以任何有问题的方式发生了变化。)
关于node.js - npm audit 在我升级包后提示漏洞,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67757672/