Find source (in package.json) of vulnerability (in package-lock.json)

做~自己de王妃 提交于 2019-12-08 05:30:02

问题


GitHub sent me an email today warning me of a vulnerability in my package-lock.json file. However, as I understand it, this file is generated during npm install from package.json.

How can I find out which package (from package.json) is linked to the vulnerable one (in package-lock.json)?

Related questions:

  • How to update package-lock.json

回答1:


How can I find out which package (from package.json) is linked to the vulnerable one (in package-lock.json)?

(Answering my own question): The vulnerable package was named growl. So, the command npm ls growl shows the packages that depend on it:

$ npm ls growl
my-project@1.0.1 C:\some_project
`-- mocha@3.5.3
  `-- growl@1.9.2

Then it's a question of finding a newer version of those packages (in this case mocha) that use a more modern version. At the time of this answer, the vulnerability was fixed in growl@1.10.0 (according to GitHub's vulnerability analysis). So, go through the release notes for mocha to see which version updated to growl 1.10. I spotted:

4.0.1 / 2017-10-05

🐛 Fixes

  • #3051: Upgrade Growl to v1.10.3 to fix its peer dep problems (@dpogue)

Updating my package.json to show "mocha": ">=4.0.1", then re-running npm install followed by npm ls growl now shows a currently non-vulnerable version of growl:

my-project@1.0.1 C:\some_project
`-- mocha@5.2.0
  `-- growl@1.10.5


来源:https://stackoverflow.com/questions/50764225/find-source-in-package-json-of-vulnerability-in-package-lock-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!