【发布时间】:2022-03-04 00:29:47
【问题描述】:
我正在尝试修复 npm audit 识别的 3 个漏洞,但似乎无法使用 npm audit fix 自动解决这些漏洞。
❯ npm audit fix
npm WARN audit fix ansi-regex@5.0.0 node_modules/npm/node_modules/cli-table3/node_modules/ansi-regex
npm WARN audit fix ansi-regex@5.0.0 is a bundled dependency of
npm WARN audit fix ansi-regex@5.0.0 npm@8.5.0 at node_modules/npm
npm WARN audit fix ansi-regex@5.0.0 It cannot be fixed automatically.
npm WARN audit fix ansi-regex@5.0.0 Check for updates to the npm package.
npm WARN audit fix ansi-regex@3.0.0 node_modules/npm/node_modules/string-width/node_modules/ansi-regex
npm WARN audit fix ansi-regex@3.0.0 is a bundled dependency of
npm WARN audit fix ansi-regex@3.0.0 npm@8.5.0 at node_modules/npm
npm WARN audit fix ansi-regex@3.0.0 It cannot be fixed automatically.
npm WARN audit fix ansi-regex@3.0.0 Check for updates to the npm package.
npm WARN audit fix strip-ansi@4.0.0 node_modules/npm/node_modules/string-width/node_modules/strip-ansi
npm WARN audit fix strip-ansi@4.0.0 is a bundled dependency of
npm WARN audit fix strip-ansi@4.0.0 npm@8.5.0 at node_modules/npm
npm WARN audit fix strip-ansi@4.0.0 It cannot be fixed automatically.
npm WARN audit fix strip-ansi@4.0.0 Check for updates to the npm package.
npm WARN audit fix string-width@2.1.1 node_modules/npm/node_modules/string-width
npm WARN audit fix string-width@2.1.1 is a bundled dependency of
npm WARN audit fix string-width@2.1.1 npm@8.5.0 at node_modules/npm
npm WARN audit fix string-width@2.1.1 It cannot be fixed automatically.
npm WARN audit fix string-width@2.1.1 Check for updates to the npm package.
up to date, audited 1898 packages in 3s
185 packages are looking for funding
run `npm fund` for details
# npm audit report
ansi-regex >2.1.1 <5.0.1
Severity: moderate
Inefficient Regular Expression Complexity in chalk/ansi-regex - https://github.com/advisories/GHSA-93q8-gq69-wqmw
fix available via `npm audit fix`
node_modules/npm/node_modules/cli-table3/node_modules/ansi-regex
node_modules/npm/node_modules/string-width/node_modules/ansi-regex
strip-ansi 4.0.0 - 5.2.0
Depends on vulnerable versions of ansi-regex
node_modules/npm/node_modules/string-width/node_modules/strip-ansi
string-width 2.1.0 - 4.1.0
Depends on vulnerable versions of strip-ansi
node_modules/npm/node_modules/string-width
3 moderate severity vulnerabilities
To address all issues, run:
npm audit fix
我不确定这是否与 existing bug 有关,因为 WARN 消息明确指出它无法自动修复。
我该如何解决这些问题?
我已尝试查看this similar SO post 中的答案,但这并不能解决任何问题。我已经尝试安装最新的ansi-regex,但帽子没有任何区别。
我有什么方法可以识别我明确引入的依赖项(即在我的依赖项或 package.json 中的 devDependencies 中)隐含地引入了这个易受攻击的依赖项?我的 package.json 中不存在消息中提到的包。
ansi-regex 在我的 package-lock.json 中被提及 49 次 - 我是否需要筛选所有这些并手动调整版本(听起来很危险)。
对于这样一个笼统(但非常具体)的问题,我们深表歉意。任何帮助将不胜感激!
【问题讨论】:
-
你有没有安装@semantic-release/npm?
-
@LuisPais 不,没有安装
-
我提到的包也有同样的问题,它有 npm 作为依赖项。尝试检查你的包锁是否有“npm”,它会告诉你哪个包有问题。至于修复,我还没有找到。