💡Aha!

Yarn에서 npm audit fix 사용하기

npm audit은 npm 라이브러리에 대한 보안 취약점을 검사해주는 명령이다. GitHub을 사용하고 있다면 GitHub Advisory Database라는 이름으로 보안 취약점을 검사해주기는 하지만, 가끔씩 npm audit을 사용해야 할 때가 있다.

근데 최근에 Yarn PnP 기능을 사용 중인 레포지토리에서 이 명령어를 사용하려고 찾아봤더니, Yarn은 --fix 옵션을 제공하지 않고 있다. (참고 문서)

yarn-audit-fix 사용하기

yarn-audit-fix
The missing yarn audit fix yarn audit detects vulnerabilities, but cannot fix them. Authors suggest usingDepedabot or Snyk for security patches. Well, it is very inconvenient in some situations, to say the least of it. The discussion:yarn/issues/7075. yarn audit does not support custom (in-house, internal) registries.
yarn-audit-fix
https://www.npmjs.com/package/yarn-audit-fix
yarn-audit-fix

이러한 문제의 해결법을 찾은 한 유저가 이러한 툴킷을 제작해두었다.

툴킷이 도와주는 경로는 다름 아닌 npm을 이용한 것으로, 사실 이러한 절차를 통해 제공된다.

  1. yarn.lock 기반으로 package-lock.json 생성
  1. npm audit fix --package-lock-only 명령 실행
  1. npm audit fix가 반영된 package-lock.jsonyarn import 기능을 이용해 yarn.lock 에 반영
  1. yarn 명령을 통해 패키지 업데이트

툴킷이 없어도 조금 귀찮은 방법을 통해 충분히 진행할 수 있지만, 나는 귀찮은 것은 별로여서 툴킷을 통해 진행했다.

2024 Dohyun Jung.
Made with ☕️.