glob-parent:正则表达式拒绝服务

问题描述

我的构建被破坏了,因为 yarn audit 说我的依赖项中存在漏洞:

yarn audit
yarn audit v1.22.5
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │ Regular expression denial of service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ glob-parent                                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=5.1.2                                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ webpack-dev-server                                           │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ webpack-dev-server > chokidar > glob-parent                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://www.npmjs.com/advisories/1751                        │
└───────────────┴──────────────────────────────────────────────────────────────┘
1 vulnerabilities found - Packages audited: 819
Severity: 1 Moderate
Done in 0.67s.

Exited with code exit status 4

解决方法

在您的 package.json 中添加:

  "resolutions": {
    "glob-parent": "5.1.2"
  }

你可以忽略警告:

warning Resolution field "glob-parent@5.1.2" is incompatible with requested version "glob-parent@^3.1.0"