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.

Azure Pipelinesでyarn auditを実行

Last updated at Posted at 2023-08-15

yarn auditってつかってますか
yarn auditコマンドはpackageの脆弱性のチェックを出力してくれるコマンドですが、普段の開発では脆弱性を意識することは少ないと思います。
なのでpipelinesでやる

サンプルのymlファイル

やっていることとしては、
・nodeをインストールし
・audit結果をHTML化してくれるpackageをインストールし
・auditを実行しつつHTML化し
・publishしpipelineの結果としてHTMLで見れるようにする
です。

audit.yml
trigger: none

pool:
  vmImage: ubuntu-latest

steps:
  - task: NodeTool@0
    inputs:
      versionSource: 'spec'
      versionSpec: '18.x'
      checkLatest: true
    displayName: 'Install Node.js'

  - script: yarn global add yarn-audit-html
    displayName: 'yarn install yarn-audit-html'

  - script: yarn audit --json | yarn-audit-html
    displayName: 'audit'

  - task: PublishHtmlReport@1
    inputs:
      reportDir: './yarn-audit.html'

  - script: yarn audit --json | yarn-audit-html --fatal-exit-code
    displayName: 'audit fatal'

結果のHTML出力のイメージ

image.png

スケジュール実行は設定のTriggersからお好きに設定してください

image.png

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?