CLI and build-time tool to find & fix known vulnerabilities in open-source dependencies.
Installation
Install the Snyk CLI using either npm, Homebrew, Scoop, or by downloading a specific binary from GitHub.
npm
$ npm install -g snyk
Brew
$ brew tap snyk/tap && brew install snyk
Scoop
$ scoop bucket add snyk https://github.com/snyk/scoop-snyk $ scoop install snyk
Manual
Manual installer available on Snyk’s GitHub page.
Authenticate
|
Authenticate via browser Will use organization that is set as default in your Account settings. |
|
Authenticate in your CI Set environment variable |
Test
|
Test a project in current folder for known vulnerabilities Scan your project for vulnerabilities locally by running |
Monitor
|
Monitor project Monitor your application for vulnerabilities by sending a snapshot of the dependencies to your Snyk dashboard. |
|
Monitor project tied to a specific organization Specify the |
Ignore Vulnerabilities
|
Ignore a specific vulnerability for 30 days Add a custom expiration date and reason by using the the flags: --expiry=2020-11-11 --reason='Not currently exploitable' |
Common CLI Options
|
Specify a manifest file you want to test |
|
Specify GitHub manifest file and ecosystem |
|
Test all manifest in folder and subfolder |
|
Include devDependencies in the scan |
|
Run command for a specific organization |
|
Test a github repository (npm only) |
|
Test the latest version of a package |
|
Test a specific version of a package |
|
Output full test results as json |
|
Store test result as json file |
|
Set severity level that will be visibl |
Container Scanning
|
Scan and monitor Docker images Add a Dockerfile for base-image remediation advice using:
Scan Docker and OCI container images as seen below: $ snyk container test docker-archive:container.tar $ snyk container test oci-archive:container.tar |
Infrastructure as Code (IAC)
|
Scan Kubernetes and Terraform files for security issues |
Troubleshooting
|
Help section and options explained |
|
Debug output for your command |
Unexpected results? Build your project and download all dependencies first, for example: $ npm install $ mvn install $ dotnet restore $ dep ensure |
|
Running out of tests on an OS project?
|
Notes
This cheat sheet is mostly based on the official Snyk Cheatsheet. It has been converted and extended with content from the Snyk CLI help where deemed appropriate by Patrik Affentranger.
Author of the original Snyk CLI Cheatsheet is Brian Vermeer (@BrianVerm) a Developer Advocate at Snyk.