概要
npm install
をしたときに npm audit fix
をしてバージョンを上げようとしても
うまく上がらなかったので対処する方法の確認
とりあえずどんな感じになっていたのか
$ npm install
up to date, audited 610 packages in 651ms
118 packages are looking for funding
run `npm fund` for details
14 vulnerabilities (7 moderate, 7 high)
To address all issues, run:
npm audit fix
Run `npm audit` for details.
このように脆弱性がある状態のようなので修正する
npm audit fix
をしてみる
$ npm audit fix
up to date, audited 610 packages in 3s
118 packages are looking for funding
run `npm fund` for details
# npm audit report
axios <=0.21.1
Severity: high
axios Inefficient Regular Expression Complexity vulnerability - https://github.com/advisories/GHSA-cph5-m8f7-6c5x
Axios vulnerable to Server-Side Request Forgery - https://github.com/advisories/GHSA-4w2v-q235-vp99
Depends on vulnerable versions of follow-redirects
fix available via `npm audit fix`
node_modules/axios
gulp-reporter >=1.5.0
Depends on vulnerable versions of axios
Depends on vulnerable versions of emphasize
Depends on vulnerable versions of in-gfw
node_modules/gulp-reporter
こんな感じでエラーレポートが出るだけでnpm audit fix
でも修正されない
package-lock.json を手動編集する
パージョン固定をしているこちらのファイルを編集する
例えば
package-lock.json
"node_modules/gulp-reporter": {
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/gulp-reporter/-/gulp-reporter-2.10.0.tgz",
"integrity": "sha512-HeruxN7TL/enOB+pJfFmeekVsXsZzQvVGpL7vOLdUe7y7VdqHUvMQRRW5qMIvVSKqRs3EtQiR/kURu3WWfXq6w==",
"dependencies": {
"ansi-escapes": "^3.1.0",
"axios": "^0.18.0",
"buffered-spawn": "^3.3.2",
このaxios
についてちょっと見てみる
https://www.npmjs.com/package/axios?activeTab=versions
さすがにメジャーバージョンを変えるのは怖いので^0.27
にしてみる
node_modulesフォルダを一度削除して、再度npm install
をしてみると
$ npm install
npm WARN deprecated sorted-array@2.0.4: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm WARN deprecated date-format@0.0.2: 0.x is no longer supported. Please upgrade to 4.x or higher.
npm WARN deprecated highlight.js@9.12.0: Version no longer supported. Upgrade to @latest
added 612 packages, and audited 613 packages in 7s
119 packages are looking for funding
run `npm fund` for details
12 vulnerabilities (8 moderate, 4 high)
To address all issues, run:
npm audit fix
Run `npm audit` for details.
こんな感じで警告が減っている。
この調子で、package-lock.json
の dependencies
を書き換えていけばOK
本当は…
これって大元のリポジトリにPRとか投げた方がいいんだろうな…とか思いつつどうなんですかね。
メンテナンスされてないってことにもなる気がするので、forkして自分のところで修正してしまう方が良いのか正直迷うところ
参考