使用“npm install”的漏洞问题

ens*_*mel 4 security package node.js npm

我已经使用express coserver命令安装了一个快速服务器,然后我使用 .npm install' 命令来安装其他节点包/依赖项,但我得到了这个结果:

                       === npm audit security report ===


                                 Manual Review
             Some vulnerabilities require your attention to resolve

          Visit https://go.npm.me/audit-guide for additional guidance


  Low             Incorrect Handling of Non-Boolean Comparisons During
                  Minification

  Package         uglify-js

  Patched in      >= 2.4.24

  Dependency of   jade

  Path            jade > transformers > uglify-js

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


  Low             Regular Expression Denial of Service

  Package         uglify-js

  Patched in      >=2.6.0

  Dependency of   jade

  Path            jade > transformers > uglify-js

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


  Critical        Sandbox Bypass Leading to Arbitrary Code Execution

  Package         constantinople

  Patched in      >=3.1.1

  Dependency of   jade

  Path            jade > constantinople

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


  Low             Regular Expression Denial of Service

  Package         clean-css

  Patched in      >=4.1.11

  Dependency of   jade

  Path            jade > clean-css

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

found 4 vulnerabilities (3 low, 1 critical) in 194 scanned packages
  4 vulnerabilities require manual review. See the full report for details.
Run Code Online (Sandbox Code Playgroud)

node --versionv10.15.0express --version4.16.1,我使用的是Windows 10,如果把在这里,但让我知道,如果因此需要其他信息,我不知道。

小智 6

原因:Jade 已更名为 pug,请安装最新版本的 pug 而不是 jade

使固定:

  1. npm卸载玉
  2. npm 安装 pug


小智 5

问题发生时

您可能使用express 应用程序生成器创建了骨架网站。当应用程序创建时没有指定要使用哪个视图引擎,就会面临这个问题。express <appname>将下面的包安装为依赖项(在撰写本文时),问题出在“jade”包上。' jade ' 是express-generator工具的默认视图引擎,但'jade' 被重命名为 'pug'并且现在不推荐使用jade 。

"cookie-parser": "~1.4.4",
"debug": "~2.6.9",
"express": "~4.16.1",
"http-errors": "~1.6.3",
"jade": "~1.11.0",
"morgan": "~1.9.1"
Run Code Online (Sandbox Code Playgroud)

怎么修

  • 带视图引擎

使用 ' pug'(更名的 jade 版本)作为视图引擎

express myapp --view=pug
Run Code Online (Sandbox Code Playgroud)

如果“哈巴狗”具有低严重性漏洞,请尝试

npm audit fix
Run Code Online (Sandbox Code Playgroud)
  • 没有视图引擎

生成没有视图引擎的应用程序

exprees myapp --no-view
Run Code Online (Sandbox Code Playgroud)

有关“玉”包的更多信息:https : //www.npmjs.com/package/jade


小智 0

当我尝试使用命令安装 Express 时,我遇到了完全相同的错误npx express-generator myapp

为了解决此错误,采取了以下步骤:

  1. 删除了我的文件夹(myapp),我试图在其中安装express。

  2. 重新开始。

  3. 按照https://expressjs.com/en/starter/generator.html中给出的分步说明进行操作

  4. npm install抛出 1 个低严重性漏洞,后来由npm audit fix

  5. 您的 Express.js 应该已成功安装。