質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Vue.js

Vue.jsは、Webアプリケーションのインターフェースを構築するためのオープンソースJavaScriptフレームワークです。

npm

npmは、Node Packaged Modulesの略。Node.jsのライブラリ・パッケージを管理できるツールです。様々なモジュールを簡単にインストールでき、自分でモジュールを作成し公開する際にも使用できます。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

React.js

Reactは、アプリケーションのインターフェースを構築するためのオープンソースJavaScriptライブラリです。

Q&A

解決済

1回答

5676閲覧

npm依存関係・脆弱性の解消

75ks

総合スコア4

Vue.js

Vue.jsは、Webアプリケーションのインターフェースを構築するためのオープンソースJavaScriptフレームワークです。

npm

npmは、Node Packaged Modulesの略。Node.jsのライブラリ・パッケージを管理できるツールです。様々なモジュールを簡単にインストールでき、自分でモジュールを作成し公開する際にも使用できます。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

React.js

Reactは、アプリケーションのインターフェースを構築するためのオープンソースJavaScriptライブラリです。

1グッド

0クリップ

投稿2021/11/11 16:02

###質問内容
Vue3を使用して開発中で、npm installを実行したのですが、セキュリティ問題が発生しているようです。
問題を解消したいのですが、ご教授いただけると幸いです。

###環境
Node.js(node -v)
v16.13.0

###現在の状態
npm installをすると下記が出力されます。

% npm install up to date, audited 1633 packages in 2s 107 packages are looking for funding run `npm fund` for details 46 vulnerabilities (20 moderate, 26 high) To address issues that do not require attention, run: npm audit fix To address all issues possible (including breaking changes), run: npm audit fix --force Some issues need review, and may require choosing a different dependency. Run `npm audit` for details.

上記にあるようにnpm auditを実行したところ、下記が表示されます。

% npm audit # npm audit report glob-parent <5.1.2 Severity: high Regular expression denial of service - https://github.com/advisories/GHSA-ww39-953v-wcq6 No fix available node_modules/@vue/cli-plugin-eslint/node_modules/glob-parent node_modules/@vue/cli-plugin-typescript/node_modules/glob-parent node_modules/@vue/cli-service/node_modules/glob-parent node_modules/copy-webpack-plugin/node_modules/glob-parent node_modules/watchpack-chokidar2/node_modules/glob-parent node_modules/webpack-dev-server/node_modules/glob-parent chokidar 1.0.0-rc1 - 2.1.8 Depends on vulnerable versions of braces Depends on vulnerable versions of glob-parent Depends on vulnerable versions of readdirp node_modules/watchpack-chokidar2/node_modules/chokidar node_modules/webpack-dev-server/node_modules/chokidar watchpack-chokidar2 * Depends on vulnerable versions of chokidar node_modules/watchpack-chokidar2 watchpack 1.7.2 - 1.7.5 Depends on vulnerable versions of watchpack-chokidar2 node_modules/watchpack webpack 4.0.0-alpha.0 - 5.0.0-rc.6 Depends on vulnerable versions of micromatch Depends on vulnerable versions of watchpack node_modules/webpack -------------------------- 省略 -------------------------- set-value <4.0.1 Severity: high Prototype Pollution in set-value - https://github.com/advisories/GHSA-4jqc-8m5r-9rpr fix available via `npm audit fix --force` Will install @vue/cli-service@3.12.1, which is a breaking change node_modules/set-value cache-base >=0.7.0 Depends on vulnerable versions of set-value Depends on vulnerable versions of union-value node_modules/cache-base base 0.7.0 - 2.0.2 Depends on vulnerable versions of cache-base node_modules/base snapdragon 0.6.0 - 0.10.1 Depends on vulnerable versions of base node_modules/snapdragon braces 2.0.0 - 2.3.2 Depends on vulnerable versions of snapdragon node_modules/@vue/cli-plugin-eslint/node_modules/braces node_modules/@vue/cli-plugin-typescript/node_modules/braces node_modules/@vue/cli-service/node_modules/braces node_modules/fork-ts-checker-webpack-plugin/node_modules/braces node_modules/watchpack-chokidar2/node_modules/braces node_modules/webpack-dev-server/node_modules/braces node_modules/webpack/node_modules/braces -------------------------- 省略 -------------------------- 46 vulnerabilities (20 moderate, 26 high) To address issues that do not require attention, run: npm audit fix To address all issues possible (including breaking changes), run: npm audit fix --force Some issues need review, and may require choosing a different dependency.

次にnpm audit fixを実行すると下記になります。

% npm audit fix npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: @typescript-eslint/eslint-plugin@4.33.0 npm ERR! Found: eslint@6.8.0 npm ERR! node_modules/eslint npm ERR! dev eslint@"^6.8.0" from the root project npm ERR! peer eslint@"^5.0.0 || ^6.0.0 || ^7.0.0" from @typescript-eslint/eslint-plugin@4.33.0 npm ERR! node_modules/@typescript-eslint/eslint-plugin npm ERR! dev @typescript-eslint/eslint-plugin@"^4.33.0" from the root project npm ERR! peer @typescript-eslint/eslint-plugin@"^4.4.0" from @vue/eslint-config-typescript@7.0.0 npm ERR! node_modules/@vue/eslint-config-typescript npm ERR! dev @vue/eslint-config-typescript@"^7.0.0" from the root project npm ERR! 9 more (@typescript-eslint/experimental-utils, eslint-utils, ...) npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer eslint@"^5.0.0 || ^6.0.0 || ^7.0.0" from @typescript-eslint/eslint-plugin@4.33.0 npm ERR! node_modules/@typescript-eslint/eslint-plugin npm ERR! dev @typescript-eslint/eslint-plugin@"^4.33.0" from the root project npm ERR! peer @typescript-eslint/eslint-plugin@"^4.4.0" from @vue/eslint-config-typescript@7.0.0 npm ERR! node_modules/@vue/eslint-config-typescript npm ERR! dev @vue/eslint-config-typescript@"^7.0.0" from the root project npm ERR! npm ERR! Conflicting peer dependency: eslint@7.32.0 npm ERR! node_modules/eslint npm ERR! peer eslint@"^5.0.0 || ^6.0.0 || ^7.0.0" from @typescript-eslint/eslint-plugin@4.33.0 npm ERR! node_modules/@typescript-eslint/eslint-plugin npm ERR! dev @typescript-eslint/eslint-plugin@"^4.33.0" from the root project npm ERR! peer @typescript-eslint/eslint-plugin@"^4.4.0" from @vue/eslint-config-typescript@7.0.0 npm ERR! node_modules/@vue/eslint-config-typescript npm ERR! dev @vue/eslint-config-typescript@"^7.0.0" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force, or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! See /Users/ユーザー名/.npm/eresolve-report.txt for a full report. npm ERR! A complete log of this run can be found in: npm ERR! /Users/ユーザー名/.npm/_logs/2021-11-11T15_36_37_574Z-debug.log

上記のようにnpm audit fixもできない状態です。
eslintが関係ありそうだったので、npm ls eslintを実行したところ、下記が出力されました。

% npm ls eslint vue3-app@0.1.0 /Users/ユーザー名/practice/vue3-app ├─┬ @typescript-eslint/eslint-plugin@4.33.0 │ ├─┬ @typescript-eslint/experimental-utils@4.33.0 │ │ ├─┬ eslint-utils@3.0.0 │ │ │ └── eslint@6.8.0 deduped │ │ └── eslint@6.8.0 deduped │ └── eslint@6.8.0 deduped ├─┬ @typescript-eslint/parser@4.33.0 │ └── eslint@6.8.0 deduped ├─┬ @vue/cli-plugin-eslint@4.5.15 │ ├─┬ eslint-loader@2.2.1 │ │ └── eslint@6.8.0 deduped │ └── eslint@6.8.0 deduped ├─┬ @vue/eslint-config-typescript@7.0.0 │ ├── eslint@6.8.0 deduped │ └─┬ vue-eslint-parser@7.11.0 │ └── eslint@6.8.0 deduped ├─┬ eslint-plugin-vue@7.20.0 │ ├── eslint@6.8.0 deduped │ └─┬ vue-eslint-parser@7.11.0 │ └── eslint@6.8.0 deduped └── eslint@6.8.0

下記はpackage.jsonの内容になります。

{ "name": "vue3-app", "version": "0.1.0", "private": true, "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint" }, "dependencies": { "@tailwindcss/postcss7-compat": "^2.2.17", "autoprefixer": "^9.8.8", "core-js": "^3.6.5", "postcss": "^7.0.39", "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.17", "vue": "^3.0.0", "vue-router": "^4.0.0-0", "vuex": "^4.0.0-0" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/parser": "^4.33.0", "@vue/cli-plugin-babel": "~4.5.0", "@vue/cli-plugin-eslint": "~4.5.0", "@vue/cli-plugin-router": "~4.5.0", "@vue/cli-plugin-typescript": "~4.5.0", "@vue/cli-plugin-vuex": "~4.5.0", "@vue/cli-service": "~4.5.0", "@vue/compiler-sfc": "^3.0.0", "@vue/eslint-config-typescript": "^7.0.0", "eslint": "^6.8.0", "eslint-plugin-vue": "^7.0.0", "typescript": "~4.1.5" } }
退会済みユーザー👍を押しています

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

npmでインストールできるライブラリは、そのライブラリ自体も別のライブラリに依存しています。

例えば、質問欄のnpm audit reportの出力の一番上にglob-parentというライブラリが表示されていますが、

plain

1glob-parent <5.1.2 2Severity: high 3Regular expression denial of service

今回の場合、以下のライブラリがglob-parentの別のバージョンに依存しています。
package.jsonから直接依存していなくても、依存先の依存先、というように依存しています)

plain

1@tailwindcss/postcss7-compat: "glob-parent": "^6.0.1" 2fast-glob: "glob-parent": "^3.1.0" 3chokidar: "glob-parent": "~5.1.2" 4copy-webpack-plugin: "glob-parent": "^3.1.0" 5eslint: "glob-parent": "^5.0.0" 6tailwindcss: "glob-parent": "^6.0.1" 7postcss7-compat: "glob-parent": "^6.0.1"

この中で<5.1.2に該当するバージョンに依存しているのはfast-glob, copy-webpack-plugin, eslintになります。

ローカル環境でglob-parentを強制的に置き換えることもできますが、それぞれのライブラリがglob-parentのバージョン5.1.2でも動作するかは不明で、動かなくなる場合も考えられます。

npm auditでリストされる全てのライブラリの依存関係について全てテストするのはあまり現実的ではないので、auditに引っかかる原因の部分(以下のような部分)

plain

1Regular expression denial of service - https://github.com/advisories/GHSA-ww39-953v-wcq6

にざっと目を通した上で、無視できるものは無視し、無視できないものは依存関係を調査した上で別のライブラリの使用を検討すると良いと思います。

投稿2021/11/12 02:08

KAOsaka

総合スコア531

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

75ks

2021/11/12 17:14

ありがとうございます。 依存関係は簡単に解決できる問題ではないんですね。。。 一旦すぐに影響はなさそうなので、この状態で進めてみます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問