以 html 格式显示 npm 审计漏洞

Display npm audit vulnerabilities in html format

有没有办法将 npm 审计报告显示为 html 页面?

目前我只能看到以json格式输出报告的选项,使用这个命令:

npm audit --json

在 Linux 我在 bash 脚本中使用 ccat:

#!/bin/sh

echo "<!DOCTYPE html><head><meta charset=\"UTF-8\"/></head><body>"
npm audit|ccat --html
echo "</body></html>"

用法:./audit.sh > vulnerabilities.html

但我也对其他解决方案感兴趣,也许那些也适用于 Windows。

我写了一个 NPM package 来为你做这件事。

您可以通过运行以下方式使用它:

// first install it
npm i -g npm-audit-html

// then pipe npm audit to it
npm audit --json | npm-audit-html

npm-audit-html 是个不错的包,刚用过。

npm install -g npm-audit-html
npm audit --json | npm-audit-html --output report.html

如果您在通过 powershell 或 VS Code 终端 运行 时收到 "No Input" 响应,只需 运行 使用命令提示符

根据之前的回答...
从 NPM v7 开始,您将需要 npm-audit-html.

的测试版
npm install -g npm-audit-html@beta
npm audit --json | npm-audit-html --output report.html

更多详情:https://github.com/eventOneHQ/npm-audit-html/issues/43#issuecomment-940159989

P.S。使用 NPM v8.3.0 测试。