0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

npm audit fixで修正されない時の対処法

Posted at

概要

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.jsondependencies を書き換えていけばOK

本当は…

これって大元のリポジトリにPRとか投げた方がいいんだろうな…とか思いつつどうなんですかね。
メンテナンスされてないってことにもなる気がするので、forkして自分のところで修正してしまう方が良いのか正直迷うところ

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?