2019.10.22
npm installしたとき下記のエラーが出ました。脆弱性に問題のあるパッケージが見つかったとのことです。
audited 771 packages in 3.511s
found 4 high severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
npm auditで詳細をみてみます。全てpm2に関連するものです。
=== npm audit security report ===
# Run npm update https-proxy-agent --depth 6 to resolve 4 vulnerabilities
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Machine-In-The-Middle │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ https-proxy-agent │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ pm2 [dev] │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ pm2 > @pm2/agent > proxy-agent > https-proxy-agent │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/1184 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Machine-In-The-Middle │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ https-proxy-agent │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ pm2 [dev] │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ pm2 > @pm2/io > @pm2/agent-node > proxy-agent > │
│ │ https-proxy-agent │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/1184 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Machine-In-The-Middle │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ https-proxy-agent │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ pm2 [dev] │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ pm2 > @pm2/agent > proxy-agent > pac-proxy-agent > │
│ │ https-proxy-agent │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/1184 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Machine-In-The-Middle │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ https-proxy-agent │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ pm2 [dev] │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ pm2 > @pm2/io > @pm2/agent-node > proxy-agent > │
│ │ pac-proxy-agent > https-proxy-agent │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/1184 │
└───────────────┴──────────────────────────────────────────────────────────────┘
found 4 high severity vulnerabilities in 771 scanned packages
run `npm audit fix` to fix 4 of them.
pm2とはnode.jsのプロセスマネージャです。
npm audit fixをやれば直ると書いてあるのでやってみました。
$ npm audit fix
updated 1 package in 3.234s
fixed 4 of 4 vulnerabilities in 771 scanned packages
もう一度npm auditをやってみると直っていました。
$ npm audit
=== npm audit security report ===
found 0 vulnerabilities
in 771 scanned packages
Docker内でもnpm installしているので同様のエラーが出てしまいイメージのビルドができません。かと言ってDocker内でnpm audit fixを実行するのも面倒です。
今回はhttps-proxy-agentというモジュールひとつだけの脆弱性なのでこのモジュールをpackage.jsonに追加してやります。
"https-proxy-agent": "^2.2.3",
これでDockerイメージのビルドができました。