Trivy でコンテナの脆弱性スキャンをする
Docker コンテナから直接実行, go get する方法, CentOS, Ubuntu へのインストール方法など、詳細は Github リポジトリ を参照のこと
今回は Mac にインストールして使ってみる
読みは「とりびぃ」らしい
Trivy (tri pronounced like trigger, vy pronounced like envy)
インストールと実行
インストールする
brew install knqyf263/trivy/trivy # tap してから install でも可 # brew tap knqyf263/trivy # brew install trivy
実行する
trivy [image name] 形式で実行する
trivy python:3.4-alpine

依存関係について
イメージ名を指定すれば勝手にレジストリから取得するので手元にイメージがある必要はなく、それもDockerコマンドに依存せず実装してあるので実はDockerのインストールも不要です
出力フォーマット
JSON でも結果を出力できる
# 確認時点では必ず 脆弱性データベースの更新処理メッセージが混入する # 最初の数行を `tail` で無視して `jq` に渡す trivy -f json --skip-update python:3.4-alpine \ | tail -n +3 \ | jq .[0].Vulnerabilities[0].Title # => "openssl: ChaCha20-Poly1305 with long nonces"
Links
- knqyf263/trivy: A Simple and Comprehensive Vulnerability Scanner for Containers, Suitable for CI - GitHub
- CIで使えるコンテナの脆弱性スキャナ - Qiita
- フロントエンドでもTrivyを使って脆弱性対策したい! - Qiita
- Man page of TAIL
- jq - jq is a lightweight and flexible command-line JSON processor.
- CVE-2019-1543 : ChaCha20-Poly1305 is an AEAD cipher, and requires a unique nonce input for every encryption operation. RFC 7539 specifie