Node.jsのプロジェクトをGitHubで開いたら脆弱性があると言われたとき
投稿日 : | 0 日前
文字数(だいたい) : 1578
Node.js
npm
どうもこんばんわ、自分用メモ。
本題
Node.jsなプロジェクトをGitHubで開いたらなんか警告が出ていたので消してみる。
We found potential security vulnerabilities in your dependencies.
Only the owner of this repository can see this message.

直し方
とりあえず package.json があるフォルダ内でターミナル(PowerShellとか)を開き、 npm audit を叩きます。
そしたらこんなふうなメッセージが。
npm audit
=== npm audit security report ===
# Run npm update minimist --depth 2 to resolve 1 vulnerability
Critical Prototype Pollution in minimist
Package minimist
Dependency of next-sitemap [dev]
Path next-sitemap > minimist
More info https://github.com/advisories/GHSA-xvch-5gv4-984h
found 1 critical severity vulnerability in 607 scanned packages
run `npm audit fix` to fix 1 of them.
Pathの部分を見ると、next-sitemap > minimistと書かれてますね。
next-sitemapの中で使っているminimistってライブラリ(モジュール)に対して脆弱性があるみたいですね。
なんかnpm audit fixで直せるらしいですが、今回はnpm i next-sitemapを叩いて大本のライブラリを更新する方針で行きます。
大本のライブラリを更新する
はい。
各自大本のライブラリを更新するようにしてください。
npm i next-sitemap
インストール出来たので、再度確認します。
npm audit
=== npm audit security report ===
found 0 vulnerabilities
in 605 scanned packages
消えていました。
以上です。
GitHubへPush
GitHubへPushし、数十秒後にちゃんと消えていました。よかった

おわりに
よく知らんけどpackage-lock.json基本いじったら駄目だよね?