如何修复npm依赖项中的漏洞?

时间:2018-12-06 10:28:44

标签: node.js npm npm-request

通过给出npm audit得到了18个漏洞,然后我选择了一个被标记为“高”的漏洞。

这是它的详细信息,

  High            Denial-of-Service Memory Exhaustion                           

  Package         qs                                                            

  Patched in      >= 1.x                                                        

  Dependency of   google-search-scraper                                         

  Path            google-search-scraper > request > qs                          

  More info       https://nodesecurity.io/advisories/29 

似乎我们需要更新请求包,因此请>npm i request 我已经安装了它。

接下来,审计命令会再次给出相同的结果

请帮助,

谢谢

编辑

Moderate        Prototype pollution                                           

  Package         hoek                                                          

  Patched in      > 4.2.0 < 5.0.0 || >= 5.0.3                                   

  Dependency of   botkit                                                        

  Path            botkit > botbuilder > jsonwebtoken > joi > hoek               

  More info       https://nodesecurity.io/advisories/566  

1 个答案:

答案 0 :(得分:1)

如报告所述,qs漏洞已在1.x中修复。对于最新的request版本而言,这不是问题。 google-search-scraper具有request@~2.33.0依赖性,该依赖性取决于qs@~0.6.0。无论项目中安装了哪个request版本,google-search-scraper都将继续使用包含漏洞的2.33.x版本。

google-search-scraper应该是分叉的,而不是原始包,request依赖版本应该在fork中更新,例如到request@^2.33.0。此外,可以在软件包存储库中打开问题并添加PR。