[npm] Markdown を HTML へ変換するなら markdown-to-html ではなく Showdownjs を使おう
Node.js で Markdown を HTML へ変換する npm はいくつかありますが、markdown-to-html ではなく Showdownjs を使うことをおすすめします。
前提知識
markdown-to-html と Showdownjs のそれぞれのリンクです。
markdown-to-html
- GitHub cwjohan/markdown-to-html
- npm: markdown-to-html – npm
Showdownjs
markdown-to-html は脆弱性がある
Showdownjs をオススメする主な理由は markdown-to-html に脆弱性がある点です。
npm install で vulnerabilities
$ npm install audited 271 packages in 1.191s found 2 vulnerabilities (1 moderate, 1 critical) run `npm audit fix` to fix them, or `npm audit` for details |
npm audit security report
npm audit コマンドを実行すると、以下のような npm audit security report が出力されました。
$ npm audit === npm audit security report === ┌──────────────────────────────────────────────────────────────────────────────┐ │ Manual Review │ │ Some vulnerabilities require your attention to resolve │ │ │ │ Visit https://go.npm.me/audit-guide for additional guidance │ └──────────────────────────────────────────────────────────────────────────────┘ ┌───────────────┬──────────────────────────────────────────────────────────────┐ │ Critical │ Command Injection │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Package │ open │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Patched in │ >0.0.5 │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Dependency of │ markdown-to-html [dev] │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Path │ markdown-to-html > open │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ More info │ https://nodesecurity.io/advisories/663 │ └───────────────┴──────────────────────────────────────────────────────────────┘ ┌───────────────┬──────────────────────────────────────────────────────────────┐ │ Moderate │ Memory Exposure │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Package │ bl │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Patched in │ >=0.9.5 <1.0.0 || >=1.0.1 │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Dependency of │ markdown-to-html [dev] │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ Path │ markdown-to-html > pygmentize-bundled > bl │ ├───────────────┼──────────────────────────────────────────────────────────────┤ │ More info │ https://nodesecurity.io/advisories/596 │ └───────────────┴──────────────────────────────────────────────────────────────┘ found 2 vulnerabilities (1 moderate, 1 critical) in 271 scanned packages 2 vulnerabilities require manual review. See the full report for details. |
以上、脆弱性の無いライブラリを使っていきたい、現場からお送りしました。