在 Yarn 2 (berry) 中审计依赖关系的最佳方式?

Best way to audit dependencies in Yarn 2 (berry)?

我正在寻找一种方法来审计 Yarn 2 中漏洞的依赖关系。在 Yarn 1.x 中,可能与 npm 中的情况相同,通过 运行ning yarn audit 而不是 npm audit。但是 Yarn 2 没有这样的命令。根据 this issue 在 berry github 上的说法,它不会被实现(项目维护者更喜欢它是通过插件完成的)。

我已经尝试 运行ning npm install --package-lock-only && npm audit 但是我的一些本地包(我在 package.json 中使用 link: url类型)。

构建它不会是一个复杂的插件,我很乐意这样做,但它不会像只安装一些东西然后开始我的一天那么有趣。我环顾四周,但总是以相同的几个 vapourware / abandonware 回购结束。

但我仍然猜想我只是没有找到它们。或者有一个未记录的技巧可以使它变得简单。因此我的问题:)

PS,是的,我可以暂时使用 link: 删除本地包,而我 运行 上面的 npm installnpm audit 命令,但事实并非如此正是我想为 CI.

尝试自动化的事情

我会尝试 https://snyk.io/ 对于庞大的团队商业用途来说不是免费的,但它可以让你开始日常运行等。

(我与 Snyk.io 没有任何关系)

更新(2020 年 10 月 28 日):
Yarn 2 刚合并long-awaited yarn npm audit enhancement.

PR - https://github.com/yarnpkg/berry/pull/1892
文档 - https://yarnpkg.com/cli/npm/audit


我最近在试验 Yarn 2,我看到你可以使用 @efrem/auditdeps 实用程序来做到这一点:

yarn dlx @efrem/auditdeps [--level=(low|moderate|high|critical)] [--production]

输出不如 npm audit 漂亮,但您可以在 JSON 格式中获得更多详细信息,您可以将其通过管道传输到其他工具或任何自定义重新格式化脚本以准确获取您想要的内容想要。