tweeeetyのぶろぐ的めも

アウトプットが少なかったダメな自分をアウトプット<br>\(^o^)/

【centos】CentOS@VirtualBoxで行うネットワーク設定のファイルについて

はじめに

VirtualBoxCentOS入れて使う場合、
たいてい最初に行うのがネットワークの設定ですよね。

いつもどのファイルだっけ?となるのでそんな自分のためのメモ

ネットワークに関する設定ファイル

以下のファイルがよく見るファイルです

  • /etc/sysconfig/network
  • /etc/sysconfig/network-scripts/ifcfg-eth0
  • /etc/hosts
  • /etc/resolv.conf

/etc/sysconfig/network

これはなに?

ネットワーク通信に必要とされる基本的な情報が記述されているファイル。

DHCPの設定例

NETWORKING=yes
HOSTNAME=hoge.local

参考

/etc/sysconfig/network-scripts/ifcfg-eth0

これはなに?

インターフェース設定ファイル。
システムの1番目のイーサネットのネットワークインターフェースカード または、NICを制御する。

NAT/DHCPとしてeth0を設定するときの例

DEVICE=eth0 
BOOTPROTO=dhcp 
ONBOOT=yes

ホストオンリーアダプタとしてeth1を設定するときの例

DEVICE=eth1
HWADDR=00:00:00:00:00:00
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.56.3
NETMASK=255.255.255.0

参考

/etc/hosts

これはなに?

IPアドレスとマシン名(ホスト名)を関連付ける設定ファイル

127.0.0.1 localhost.localdomain localhost
192.168.1.10 test1
192.168.1.20 test2

参考

/etc/resolve.conf

これはなに?

自分のマシンが利用するDNSサーバの情報(IPアドレス)を記述するファイル

search linux-beginner.com
nameserver 192.168.0.1
nameserver 192.168.0.2

参考

その他の参考

以下のサイトが全体的に説明してくれていてわかりやすかったです。

おわり

/etc/sysconfig/network-scripts/ifcfg-eth0の場所がほんとよくどこだっけなーとなる
\(^o^)/

【VirtualBox】CentOS@VirtualBoxのNAT設定での10.0.2.2

はじめに

CentOS@VirtualBoxでのネットワーク設定での話。

設定後にNATまわりを確認すると10.0.2.2が出てきます。

設定する過程で見かけた記憶がなかったのでどこで設定されているのか気になり調べてみたメモです。

f:id:tweeeety:20180622000002p:plain

結論

VirtualBoxの仕様らしい

VirtualBoxのNATネットワークアダプタに10.0.2.0/24が割り当てられ
ゲストOSから見えるホストOSのIPアドレスには10.0.2.2が設定される仕様  
ゲストOSから10.0.2.2に対してpingすると
ホストOSから応答がありますが、
ホストOSには10.0.2.0/24系のネットワークインタフェースが存在しないため、ゲストOSは見えません。  
* garbagetown - VirtualBox (3)

おわり

仕様ならまぁ、、、という感じで
物理的なファイルとしてどこで設定されてるかまでは諦めましたw
\(^o^)/

【linux】CentOSの/etc/sysconfig/network-scripts/ifcfg-eth0について - BOOTPROTOとか

はじめに

CentOSNIC周りの設定を触っていると
/etc/sysconfig/network-scripts/ifcfg-eth0
というファイルを見る or 設定することがあります。

その時に出てくるBOOTPROTOが気になったのでそのあたりの自分用メモ

f:id:tweeeety:20180621173752j:plain

/etc/sysconfig/network-scripts/ifcfg-eth0 とは

参考サイトからの引用です

最も一般的なインターフェースファイルの1つです。
これは、システムの一番目のイーサネット
ネットワークインターフェースカード または NIC を制御します。
 
* 参考: 9.2. インターフェース設定ファイル

BOOTPROTOとは

こちらも参考サイトから引用します。
他の項目についても説明がわかりやすいです。

DHCPの様に、IPアドレスを外部から設定情報を取得する場合のプロトコルを指定。
 
* 参考: Linux ネットワーク基本設定 其の三

設定できるの値は以下です。

説明
none インタフェース起動時にプロトコルを使用しない。( IPアドレスが固定などの場合に使用する )
staticと指定してもOK。
dhcp DHCP(Dynamic Host Configuration Protocol)を利用する場合に指定。
bootp BOOTP(BOOTstrap Protocol)を利用する場合に指定。

設定しないとどうなる?(コメントすると?)

設定値としてはbootpdhcpしかないようなので
noneでも設定しないでも好きな文字でも良いようですが、
慣習的にnoneと明示するようです。

# cat /etc/sysconfig/network-scripts/ifup | grep BOOTPROTO -A3 -B3 -n
141-
142-# Old BOOTP variable
143-if [ "${BOOTP}" = "yes" ]; then
144:    BOOTPROTO=bootp
145-fi
146-
147:if [ "${BOOTPROTO}" = "bootp" -o "${BOOTPROTO}" = "dhcp" ]; then
148-    DYNCONFIG=true
149-fi
150-

おわり

ネットワークまわりは何度やってもむずい\(^o^)/

【Mac】treeコマンドで文字化けするときのメモ

はじめに

日本語を含むdir/fileをtreeすると文字化けするときの自分用メモ

$ tree .
.
├── a
│   ├── a�\201��\201��\201\214�\203\225�\202��\202��\203�.txt
│   ├── a�\201��\201��\201\222�\203\225�\202��\202��\203�.txt
│   └── b�\201��\201��\201\214�\203\225�\202��\202��\203�.txt
├── b
└── c

tree -N

tree -N で文字化けせずに表示できます

$ tree -N .
.
├── a
│   ├── aのふがファイル.txt
│   ├── aのほげファイル.txt
│   └── bのふがファイル.txt
├── b
└── c

helpから抜粋

$ tree --help | grep "\-N"
  -N            Print non-printable characters as is.

参考

おわり

自分のサイト内を文字化けで検索したら出てきてくれさえすれば良いメモ
\(^o^)/

【gulp】gulp@4.0.0にしたら`The following tasks did not complete:`、`Did you forget to signal async completion?`と怒られる

はじめに

とあることで、gulpを3.x.x.から^4.0.0にあげる必要がありました。
f:id:tweeeety:20180618044056p:plain

あげてからgulpタスクを実行すると
以下のようなエラーが出たのでその対応方法をメモ

# defaultタスクを実行するとこんなエラーが...
$ ./node_modules/gulp/bin/gulp.js
[05:35:32] Using gulpfile ~/gulp-task-gulp4.0.0-sample2/gulpfile.js
[05:35:32] Starting 'default'...
[05:35:32] Starting 'hoge'...
i am hoge!!
[05:35:32] The following tasks did not complete: default, hoge
[05:35:32] Did you forget to signal async completion?

なぜ起こったか

The following tasks did not complete  
上記の実行時のログより

処理が終わってないよと言われてます。

4.x.xではgulpタスクで以下のことを行う必要があります

  • 明示的にtaskを終了する
    • callbackを呼び出す
    • streamを返却する
    • 単にreturnをつける

どうすればいいか

すでに書いてしまってますが、
明示的にtaskを終了をする必要があります。

gulp.task@3.x.x -> gulp.task@^4.x.x
に書き換える変える一例をあげます。

gulp.task@3.x.x

gulp.task('sass', function(){
  gulp.src('./sass/*.scss')
    .pipe(sass({outputStyle: 'expanded'}))
    .pipe(gulp.dest('./css/'));
});

gulp.task@^4.x.x

gulp.task('sass', function(){
  // streamをreturnする
  return gulp.src('./sass/*.scss')
    .pipe(sass({outputStyle: 'expanded'}))
    .pipe(gulp.dest('./css/'));
});

3.9.1^4.x.xを実際に動かして見比べてみる

そのまま試せる形でgithubに載せてみました。

https://github.com/tweeeety/gulp-task-gulp4.0.0-sample2

  • gulp@3.x.xの書き方
  • gulp@^4.x.xの書き方

をそれぞれ記載しています。

こちらも

こちらも合わせてご覧ください

参考

おわり

gulpを3.x.x->4.x.xからあげる場合は
書き直しになる場合が多いかもしれないので要注意
\(^o^)/

【gulp】gulp@4.0.0にしたら`AssertionError [ERR_ASSERTION]: Task function must be specified`と怒られる

はじめに

とあることで、gulpを3.x.x.から^4.0.0にあげる必要がありました。
f:id:tweeeety:20180618044056p:plain

あげてからgulpタスクを実行すると
以下のようなエラーが出たのでその対応方法をメモ

# defaultタスクを実行するとこんなエラーが...
$ ./node_modules/gulp/bin/gulp.js
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: Task function must be specified
    at Gulp.set [as _setTask] (/Users/tweeeety/gulp-task-gulp4.0.0-sample1/node_modules/undertaker/lib/set-task.js:10:3)
    at Gulp.task (/Users/tweeeety/gulp-task-gulp4.0.0-sample1/node_modules/undertaker/lib/task.js:13:8)
    at Object.<anonymous> (/Users/tweeeety/gulp-task-gulp4.0.0-sample1/gulpfile.js:5:6)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)

なぜ起こったか

removed 3 argument syntax for gulp.task  
gulp changelog

github/gulpのchangelogから抜粋ですが、
3.x.xのときのgulp.taskは引数が3つでしたが、
^4.0.0ではgulp.taskの引数が2つになりました。

これによるエラーのようです。

どうすればいいか

gulp.task@3.x.x -> gulp.task@^4.x.x
に書き換える変える一例をあげます。

gulp.task@3.x.x

gulp.task('hoge', 'fuga', function() {
  console.log('callbackの関数');
});

gulp.task@^4.x.x

// 引数は2つに
gulp.task('hoge', gulp.series('fuga', function(callback) {
  console.log('callbackの関数');
  // callback or streamを返さなければならない
  callback();
}));

補足

例はgulp.seriesで書きましたが

直列にしたいか、並列にしたいかで

  • gulp.series
    • 直列にしたいタスクを定義
  • gulp.parallel
    • 並列にしたいタスクを定義

を適宜読み替えてください。

参考サイトを載せておきます。

3.9.1^4.x.xを実際に動かして見比べてみる

そのまま試せる形でgithubに載せてみました。

https://github.com/tweeeety/gulp-task-gulp4.0.0-sample1

  • gulp@3.x.xの書き方
  • gulp@^4.x.xの書き方

をそれぞれ記載しています。

補足

上記のコード例を実行すると
微妙にtaskの呼び出しに変化があります。

Starting 'default'Starting 'task2'あたりの順番が違います。

今回の例でいうと
両者は実質タスク名なだけで中身は何もしてないので影響はないですが
念のため注意が必要そうです。

3.9.1の例
$ ./node_modules/gulp/bin/gulp.js
[00:26:33] Using gulpfile ~/gitrepos/hatena/gulp-task-gulp4.0.0-sample1/gulpfile.js
[00:26:33] Starting 'task1'...
i am task1!!
[00:26:33] Finished 'task1' after 138 μs
[00:26:33] Starting 'task2-1'...
i am task2-1!!
[00:26:33] Finished 'task2-1' after 65 μs
[00:26:33] Starting 'task2-2'...
i am task2-2!!
[00:26:33] Finished 'task2-2' after 82 μs
[00:26:33] Starting 'task2'...
i am task2!!
[00:26:33] Finished 'task2' after 77 μs
[00:26:33] Starting 'task3'...
i am task3!!
[00:26:33] Finished 'task3' after 75 μs
[00:26:33] Starting 'default'...
[00:26:33] Finished 'default' after 19 μs
[~/gitrepos/hatena/gulp-task-gulp4.0.0-sample1 00:26:3
^4.x.xの例
$ ./node_modules/gulp/bin/gulp.js
[00:31:37] Using gulpfile ~/gitrepos/hatena/gulp-task-gulp4.0.0-sample1/gulpfile.js
[00:31:37] Starting 'default'...
[00:31:37] Starting 'task1'...
i am task1!!
[00:31:37] Finished 'task1' after 878 μs
[00:31:37] Starting 'task2'...
[00:31:37] Starting 'task2-1'...
[00:31:37] Starting '<anonymous>'...
i am task2-1!!
[00:31:37] Finished '<anonymous>' after 247 μs
[00:31:37] Finished 'task2-1' after 481 μs
[00:31:37] Starting 'task2-2'...
i am task2-2!!
[00:31:37] Finished 'task2-2' after 240 μs
[00:31:37] Starting '<anonymous>'...
i am task2!!
[00:31:37] Finished '<anonymous>' after 219 μs
[00:31:37] Finished 'task2' after 1.4 ms
[00:31:37] Starting 'task3'...
i am task3!!
[00:31:37] Finished 'task3' after 174 μs
[00:31:37] Finished 'default' after 5.27 ms

こちらも

こちらも合わせてご覧ください

おわり

gulpを3.x.x->4.x.xからあげる場合は
書き直しになる場合が多いかもしれないので要注意
\(^o^)/

【node.js】npm@6にしたらnpm auditでpackageの脆弱性をチェックできるようになったメモ

はじめに

npmコマンドを叩いた際に、@6.x.xにあげてねと言われました。

言われれるがままにあげてみたら
npm auditも行えと言われてなんだこれ..と思って調べた自分用メモです。

f:id:tweeeety:20180615185946j:plain

画像元

アジェンダ

  1. npm auditとは
  2. "npm auditしてね"までの流れ
  3. npm auditの見方と対応の流れ
  4. npm auditの使い方

1. npm auditとは

npm auditは、
npm install/node_modules配下にインストールしたpackageの脆弱性をチェックしてくれるものです。

以下、参考サイトからの引用です。

liftsecurity.ioという企業が持っていた
セキュリティノウハウをnpm側が取得したことにより
packageの脆弱性のチェックができるようになった  

2. "npm auditしてね"までの流れ

npm runスクリプト
# npm runスクリプトを走らせると
# @6.x.xにあげてねと言われる
$ npm run hoge

> hoge@1.0.0 hoge /Users/tweeeety/Hoge
> gulp

[14:52:35] Using gulpfile ~/Hoge/gulpfile.js
(node:9422) [DEP0016] DeprecationWarning: 'root' is deprecated, use 'global'
~ 省略 ~ 
[14:52:35] Finished 'svg' after 119 ms


   ╭─────────────────────────────────────╮
   │                                     │
   │   Update available 5.6.0 → 6.1.0    │
   │     Run npm i -g npm to update      │
   │                                     │
   ╰─────────────────────────────────────╯
素直にあげる
# 一応version確認
$ npm -v
5.6.0

# あげる
$ npm i -g npm
/Users/tweeeety/.nodebrew/node/v8.11.0/bin/npm -> /Users/tweeeety/.nodebrew/node/v8.11.0/lib/node_modules/npm/bin/npm-cli.js
/Users/tweeeety/.nodebrew/node/v8.11.0/bin/npx -> /Users/tweeeety/.nodebrew/node/v8.11.0/lib/node_modules/npm/bin/npx-cli.js
+ npm@6.1.0
added 247 packages, removed 41 packages and updated 129 packages in 15.683s
npm installすると"npm auditしてみ"と言われる
# npmのversionあげたので念のためnpm install
$ npm install
audited 3268 packages in 5.548s
found 6 vulnerabilities (2 low, 4 high)
  run `npm audit fix` to fix them, or `npm audit` for details
  # `npm auditしてね`と言われる

3. npm auditの見方と対応の流れ

npm auditの使い方はいくつかあるようですが、
npm auditとだけうつとチェックと結果のレポートを表示してくれます。

まずは見て見る

$ npm audit

                       === npm audit security report ===

# Run  npm install --save-dev gulp@4.0.0  to resolve 5 vulnerabilities
SEMVER WARNING: Recommended action is a potentially breaking change
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High          │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ minimatch                                                    │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ gulp [dev]                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ gulp > vinyl-fs > glob-stream > glob > minimatch             │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/118                       │
└───────────────┴──────────────────────────────────────────────────────────────┘


┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High          │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ minimatch                                                    │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ gulp [dev]                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ gulp > vinyl-fs > glob-stream > minimatch                    │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/118                       │
└───────────────┴──────────────────────────────────────────────────────────────┘


┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High          │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ minimatch                                                    │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ gulp [dev]                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ gulp > vinyl-fs > glob-watcher > gaze > globule > glob >     │
│               │ minimatch                                                    │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/118                       │
└───────────────┴──────────────────────────────────────────────────────────────┘


┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High          │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ minimatch                                                    │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ gulp [dev]                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ gulp > vinyl-fs > glob-watcher > gaze > globule > minimatch  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/118                       │
└───────────────┴──────────────────────────────────────────────────────────────┘


┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low           │ Prototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ lodash                                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ gulp [dev]                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ gulp > vinyl-fs > glob-watcher > gaze > globule > lodash     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/577                       │
└───────────────┴──────────────────────────────────────────────────────────────┘


┌──────────────────────────────────────────────────────────────────────────────┐
│                                Manual Review                                 │
│            Some vulnerabilities require your attention to resolve            │
│                                                                              │
│         Visit https://go.npm.me/audit-guide for additional guidance          │
└──────────────────────────────────────────────────────────────────────────────┘
  2   "name": "hoge",
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low           │ Prototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ lodash                                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=4.17.5                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ diff-json [dev]                                              │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ diff-json > lodash                                           │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/577                       │
└───────────────┴──────────────────────────────────────────────────────────────┘
found 6 vulnerabilities (2 low, 4 high) in 3268 scanned packages
  5 vulnerabilities require semver-major dependency updates.
  1 vulnerability requires manual review. See the full report for details.

最初にみるべきは一番下のこれです。

found 6 vulnerabilities (2 low, 4 high) in 3268 scanned packages 5 vulnerabilities require semver-major dependency updates. 1 vulnerability requires manual review. See the full report for details.

6個の脆弱性がみつかって、
2個は低レベル、4つは高レベルの脆弱性だよ、と。

やべーじゃん...

対応してみる

各レポートの上にこんな記載があれば、
それを打つことで解決できそうだよと教えてくれています。

# Run npm install --save-dev gulp@4.0.0 to resolve 5 vulnerabiliti SEMVER WARNING: Recommended action is a potentially breaking change

ということで試して見ます。

# 言われるがままに対応してみる
$ npm install --save-dev gulp@4.0.0
+ gulp@4.0.0
added 97 packages from 80 contributors, removed 29 packages, updated 59 packages and audited 6754 packages in 14.622s
found 1 low severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details


# 再度脆弱性チェックを行う
# 1つに減っている!
$ 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          │
└──────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low           │ Prototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ lodash                                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=4.17.5                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ diff-json [dev]                                              │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ diff-json > lodash                                           │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/577                       │
└───────────────┴──────────────────────────────────────────────────────────────┘
found 1 low severity vulnerability in 6754 scanned packages
  1 vulnerability requires manual review. See the full report for details.

4. npm auditの使い方

いくつかだけ例をあげます

npm aduit
$ npm audit

# レポートが表示される
npm audit --json

--jsonオプションをつけることで、
レポートをjson形式で表示してくれます。

先ほどの例で--jsonをつけた場合のレポート表示です。

$ npm audit --json
{
  "actions": [
    {
      "action": "install",
      "module": "gulp",
      "target": "4.0.0",
      "isMajor": true,
      "resolves": [
        {
          "id": 118,
          "path": "gulp>vinyl-fs>glob-stream>glob>minimatch",
          "dev": true,
          "optional": false,
          "bundled": false
        },
        {
          "id": 118,
          "path": "gulp>vinyl-fs>glob-stream>minimatch",
          "dev": true,
          "optional": false,
          "bundled": false
        },
        {
          "id": 118,
          "path": "gulp>vinyl-fs>glob-watcher>gaze>globule>glob>minimatch",
          "dev": true,
          "optional": false,
          "bundled": false
        },
        {
          "id": 118,
          "path": "gulp>vinyl-fs>glob-watcher>gaze>globule>minimatch",
          "dev": true,
          "optional": false,
          "bundled": false
        },
        {
          "id": 577,
          "path": "gulp>vinyl-fs>glob-watcher>gaze>globule>lodash",
          "dev": true,
          "optional": false,
          "bundled": false
        }
      ]
    },
    {
      "action": "review",
      "module": "lodash",
      "resolves": [
        {
          "id": 577,
          "path": "diff-json>lodash",
          "dev": true,
          "optional": false,
          "bundled": false
        }
      ]
    }
  ],
  "advisories": {
    "118": {
      "findings": [
        {
          "version": "2.0.10",
          "paths": [
            "gulp>vinyl-fs>glob-stream>glob>minimatch",
            "gulp>vinyl-fs>glob-stream>minimatch"
          ],
          "dev": true,
          "optional": false,
          "bundled": false
        },
        {
          "version": "0.2.14",
          "paths": [
            "gulp>vinyl-fs>glob-watcher>gaze>globule>glob>minimatch",
            "gulp>vinyl-fs>glob-watcher>gaze>globule>minimatch"
          ],
          "dev": true,
          "optional": false,
          "bundled": false
        }
      ],
      "id": 118,
      "created": "2016-05-25T16:37:20.000Z",
      "updated": "2018-03-01T21:58:01.072Z",
      "deleted": null,
      "title": "Regular Expression Denial of Service",
      "found_by": {
        "name": "Nick Starke"
      },
      "reported_by": {
        "name": "Nick Starke"
      },
      "module_name": "minimatch",
      "cves": [
        "CVE-2016-10540"
      ],
      "vulnerable_versions": "<=3.0.1",
      "patched_versions": ">=3.0.2",
      "overview": "Affected versions of `minimatch` are vulnerable to regular expression denial of service attacks when user input is passed into the `pattern` argument of `minimatch(path, pattern)`.\n\n\n## Proof of Concept\n```\nvar minimatch = require(“minimatch”);\n\n// utility function for generating long strings\nvar genstr = function (len, chr) {\n  var result = “”;\n  for (i=0; i<=len; i++) {\n    result = result + chr;\n  }\n  return result;\n}\n\nvar exploit = “[!” + genstr(1000000, “\\\\”) + “A”;\n\n// minimatch exploit.\nconsole.log(“starting minimatch”);\nminimatch(“foo”, exploit);\nconsole.log(“finishing minimatch”);\n```",
      "recommendation": "Update to version 3.0.2 or later.",
      "references": "",
      "access": "public",
      "severity": "high",
      "cwe": "CWE-400",
      "metadata": {
        "module_type": "Multi.Library",
        "exploitability": 4,
        "affected_components": "Internal::Code::Function::minimatch({type:'args', key:0, vector:{type:'string'}})"
      },
      "url": "https://nodesecurity.io/advisories/118"
    },
    "577": {
      "findings": [
        {
          "version": "2.4.2",
          "paths": [
            "diff-json>lodash"
          ],
          "dev": true,
          "optional": false,
          "bundled": false
        },
        {
          "version": "1.0.2",
          "paths": [
            "gulp>vinyl-fs>glob-watcher>gaze>globule>lodash"
          ],
          "dev": true,
          "optional": false,
          "bundled": false
        }
      ],
      "id": 577,
      "created": "2018-04-24T14:27:02.796Z",
      "updated": "2018-04-24T14:27:13.049Z",
      "deleted": null,
      "title": "Prototype Pollution",
      "found_by": {
        "name": "Olivier Arteau (HoLyVieR)"
      },
      "reported_by": {
        "name": "Olivier Arteau (HoLyVieR)"
      },
      "module_name": "lodash",
      "cves": [
        "CVE-2018-3721"
      ],
      "vulnerable_versions": "<4.17.5",
      "patched_versions": ">=4.17.5",
      "overview": "Versions of `lodash` before 4.17.5 are vulnerable to prototype pollution. \n\nThe vulnerable functions are 'defaultsDeep', 'merge', and 'mergeWith' which allow a malicious user to modify the prototype of `Object` via `__proto__` causing the addition or modification of an existing property that will exist on all objects.\n\n",
      "recommendation": "Update to version 4.17.5 or later.",
      "references": "- [HackerOne Report](https://hackerone.com/reports/310443)",
      "access": "public",
      "severity": "low",
      "cwe": "CWE-471",
      "metadata": {
        "module_type": "",
        "exploitability": 1,
        "affected_components": ""
      },
      "url": "https://nodesecurity.io/advisories/577"
    }
  },
  "muted": [],
  "metadata": {
    "vulnerabilities": {
      "info": 0,
      "low": 2,
      "moderate": 0,
      "high": 4,
      "critical": 0
    },
    "dependencies": 0,
    "devDependencies": 3268,
    "optionalDependencies": 196,
    "totalDependencies": 3268
  },
  "runId": "91d63b40-7d49-494e-a020-48ac0af8ffcc"
}
npm audit fix

これはやってみるとわかりますが、
示唆してくれた改善案があればそれを実行してくれるものです。

先ほどの例でいうと
npm audit fix
を打つと
npm install --save-dev gulp@4.0.0
を行なってくれます。

# 例にあげた最初の状態
$ npm audit

~ 省略 ~ 

found 6 vulnerabilities (2 low, 4 high) in 3268 scanned packages
  5 vulnerabilities require semver-major dependency updates.
  1 vulnerability requires manual review. See the full report for details.

# 打って見る
$ npm audit fix
up to date in 2.72s
fixed 0 of 6 vulnerabilities in 3268 scanned packages
  1 vulnerability required manual review and could not be updated
  1 package update for 5 vulns involved breaking changes
  (use `npm audit fix --force` to install breaking changes; or do it by hand)

# 再度チェック
# 結果は1つに減っている
$ npm audit

~ 省略 ~ 

found 1 low severity vulnerability in 6754 scanned packages
  1 vulnerability requires manual review. See the full report for details.
その他

そのほかは公式をご参照あれ。
https://docs.npmjs.com/cli/audit

また、以下の動画でも詳しく解説されていました。
https://www.youtube.com/watch?v=QflNpG3VuGY

おわり

packageの脆弱性のチェックだけじゃなくて
対応コマンドまで表示してくれるのは嬉しいですね!!
\(^o^)/