0. Github Alert Email

Vue.js를 연습하는 도중 간단한 webpack-simple 프로젝트를 npm으로 다운로드받아서 테스트 후 업로드를 해보았는데...

git에 push하고 집에 가려는데 갑자기 email 폭탄이 날아오더니, 특정 파일의 취약한 버전이 발견되어 이를 수정하기를 권고하는 내용이었다.

package-lock.json에 작성된 js-yaml 버전이 낮으니 패치하길 권고
package-lock.json에 작성된 minimist 버전이 낮으니 패치하길 권고

이렇게 업데이트 메시지가 나오는 이유에 대해서는 두말 할 것 없이, 당연 취약해서다.

취약한 버전이거나, 버그가 있거나 하여 이를 fix한 버전으로 업데이트하라는 말이다.

그런데 npm install을 수행할 때 package-lock.json에 기재된 버전 정보가 낮을 경우 Security Alert를 Mail로 Bot이 자동으로 보내주는 형태인 것 같다.

이를 해결하기 위해 많은 삽질을 하던 중 다음과 같은 결과가 나와 업데이트를 수행할 수 있었다.

 

1. NPM Warning Message

npm에서는 자체적으로 audit 기능을 제공한다.

이 명령어를 이용하면 일반적으로 서브 버전의 차이일 경우 해결이 가능하다.

그러나 이 기능을 활용하여 fix 명령어를 입력해보았지만, 크게 변화가 없었다.

이에 대한 명령어와 결과는 다음과 같이 나타났다.

npm audit command

$ npm audit fix

after audit fix command...

 ⚡ root@ubuntu  .../study/study021   master ●  npm audit fix
npm WARN webpack-dev-middleware@1.12.2 requires a peer of webpack@^1.0.0 || ^2.0.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-server@2.11.5 requires a peer of webpack@^2.2.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.

up to date in 4.103s

24 packages are looking for funding
  run `npm fund` for details

fixed 0 of 13 vulnerabilities in 10538 scanned packages
  13 vulnerabilities required manual review and could not be updated

체크해볼 수 있는 취약한 버전으로 webpack-dev-server를 중심으로 고쳐보려 노력했다.

여기서 볼 수 있는 건, 현재 설치된 webpack-dev-server의 버전이 2.x 버전이기 때문에 3.x가 설치되지 않아 직접 dependency를 해결하라는 경고 메시지가 보인다.

정말 아쉽게도 이를 해결하기 위해서는 기존의 npm update webpack-dev-server와 같은 명령어로는 어림도 없었다.

 

2. Conclusion

위와 같은 버전 차이는 새로 설치해야 하는 문제이기 때문에, reinstall 과정을 수행해야 한다.

reinstall 과정은 다음과 같은 명령어로 수행하면 된다.

reinstall command

$ npm uninstall webpack-dev-server --save-dev
$ npm install webpack-dev-server --save-dev

reinstall result

 ⚡ root@ubuntu  .../study/study021   master ●  npm install webpack-dev-server -save-devev
+ webpack-dev-server@3.10.3
added 219 packages from 168 contributors and audited 10479 packages in 11.716s

22 packages are looking for funding
  run `npm fund` for details

found 14 moderate severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details
check the version of 'webpack-dev-server'
    "webpack-dev-server": {
      "version": "3.10.3",
      "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-3.10.3.tgz",
      "integrity": "sha512-e4nWev8YzEVNdOMcNzNeCN947sWJNd43E5XvsJzbAL08kGc2frm1tQ32hTJslRS+H65LCb/AaUCYU7fjHCpDeQ==",
      "dev": true,
      "requires": {
        "ansi-html": "0.0.7",

+ Recent posts