はじめに
先日開催されたCNSC2022やHashiTalks:Japanで紹介されたSnykが気になったので、触ってみました。
本記事ではDockerイメージのスキャンを試していますが、こちらの記事では、Snykでドリフト検出(実リソースとtfstateの差異を検出)を試しています。
- Snyk(スニーク)とは
- Snykはセキュリティプラットフォームです。コードやオープンソースとその依存関係、コンテナやIaCにおける脆弱性を見つけるだけでなく、優先順位をつけて修正するためのツールです。Gitや統合開発環境(IDE)、CI/CDパイプラインに直接組み込めます。
- Snyk User Documentation - Snyk User Docs
- 【無料トライアル】セキュリティの「めんどくさい」を解決したい!デベロッパーファーストのSnyk入門編 - Qiita
環境
Snykのアカウント登録
SnykのWebサイトを開き、アカウントを登録します。
なお、無料アカウントは以下の制限があります。
- Plans and Pricing | Free plan | Snyk
- Limited Tests
- 200 Open Source tests/month
- 100 Container tests/month
- 300 IaC tests/month
- 100 Code tests/month
Snyk CLIのインストール
手順に沿って、Snyk CLIをインストールします。
Install or update the Snyk CLI - Snyk User Docs
$ curl https://static.snyk.io/cli/latest/snyk-linux -o snyk $ chmod +x ./snyk $ sudo mv ./snyk /usr/local/bin/
Snykのアカウント認証
Authenticate the CLI with your account - Snyk User Docs
$ snyk auth APIトークン Your account has been authenticated. Snyk is now ready to be used.
Snyk CLIでDockerイメージをスキャンする
hello-worldをスキャンしてみます。
$ snyk container test hello-world Testing hello-world... Organization: mito-201 Package manager: linux Project name: docker-image|hello-world Docker image: hello-world Platform: linux/amd64 Licenses: enabled ✔ Tested hello-world for known issues, no vulnerable paths found. Note that we do not currently have vulnerability data for your image.
Snyk CLIのヘルプを表示
色々できそうですね。
$ snyk --help CLI commands help Snyk CLI scans and monitors your projects for security vulnerabilities and license issues. For more information visit the Snyk website https://snyk.io For details see the CLI documentation https://docs.snyk.io/features/snyk-cli How to get started 1. Authenticate by running snyk auth 2. Test your local project with snyk test 3. Get alerted for new vulnerabilities with snyk monitor Available commands To learn more about each Snyk CLI command, use the --help option, for example, snyk auth --help or snyk container --help snyk auth Authenticate Snyk CLI with a Snyk account. snyk test Test a project for open source vulnerabilities and license issues. Note: Use snyk test --unmanaged to scan all files for known open source dependencies (C/C++ only). snyk monitor Snapshot and continuously monitor a project for open source vulnerabilities and license issues. snyk container Test container images for vulnerabilities. snyk iac Commands to find and manage security issues in Infrastructure as Code files. snyk code Find security issues using static code analysis. snyk log4shell Find Log4Shell vulnerability. snyk config Manage Snyk CLI configuration. snyk policy Display the .snyk policy for a package. snyk ignore Modify the .snyk policy to ignore stated issues. Debug Use -d option to output the debug logs. Configure the Snyk CLI You can use environment variables to configure the Snyk CLI and also set variables to configure the Snyk CLI to connect with the Snyk API. See Configure the Snyk CLI https://docs.snyk.io/features/snyk-cli/configure-the-snyk-cli
参考
[snyk-docs] Snyk CLI のインストールとアップデート (Install or update the Snyk CLI) - Qiita