Snyk CLI Cheat Sheet
Installation (read docs)

01$ npm install snyk -g$ brew tap snyk/tap && brew
install snyk

$ scoop bucket add snyk

https://github.com/snyk/scoop-snyk$ scoop install snyk

02

You need to authenticate with your Snyk
account in one of the following ways:$ snyk auth (authenticate using the browser)$ snyk auth <token>

06(read docs)

Specify a manifest file to test

$ snyk [command] --file=package.json

Specify a GitHub manifest file and ecosystem$ snyk test --file=req.txt -package-manager=pip

03

Test all manifests in a folder and its subfolder$ snyk test --all-projects

Include dev dependencies in a scan

$ snyk test --dev

Run a command for a specific organization$ snyk [command] --org=<org_id>

Scan your project for vulnerabilities by runningthe following from the root of your project:$ snyk test

Test a public GitHub repository$ snyk test https://github.com/snyklabs/nodejs-goof

Vulnerabilities and remediation are shown inyour terminal.

Monitor (read docs)05

Add a custom expiration date and reason withthese options:--expiry=2020-11-11--reason='Not currently exploitable'

CLI common options  

Use the SNYK_TOKEN environment variable
in a CI/CD environment.

Scan your project(read docs)

Ignore vulnerabilities  (read docs)

Ignore a specific vulnerability for 30 days by using
snyk ignore:$ snyk ignore --id=npm:toughcookie:20160722

Additional methods are explained in the docs.

Authenticate (read docs)

ast update: April 2022

L

Test the latest version of an npm package$ snyk test lodash

04

Monitor your application for vulnerabilities bysending a snapshot of the dependencies to yourSnyk dashboard using:$ snyk monitor

The results are shown on your Snyk dashboard.

Test a specific version of a package$ snyk test ionic@1.6.5

Output full test results as JSON$ snyk test --json

Store test result as a JSON file$ snyk test --json-fileoutput=vuln.json

Set the minimum severity level that will be
included in the scan

$ snyk [command] --severitythreshold=<low|medium|high|critical>

07

Snyk Code (read docs)

roubleshooting (read docs)

T10

Test the current folder

Display Snyk CLI help using the --help option or
the snyk help command: 

Test another context$ snyk auth --help $ snyk container --help $ snyk help <command>$ snyk code test

$ snyk code test <folder>Container scanning08(read docs)

Scan and monitor Docker images$ snyk container test <image>$ snyk container monitor <image>

Option to get more information includingbase image remediation--file=path/to/Dockerfile

Scan Docker and OCI container images$ snyk container test dockerarchive:container.tar$ snyk container test ociarchive:container.tar

Debug output for your command$ snyk [command] -dUnexpected results? 

Build your project and download all dependencies
first, for example:$ npm install$ mvn install$ dotnet restore$ go build

Running out of tests on an open source project
Run snyk monito
Open the Snyk UI and go to the settings of theprojec
nter the URL of your OS repo in Git remote URI

E

Infrastructure as Code  (read docs)

09
ead the Snyk CLI
documentation

R

Scan Kubernetes and Terraform files forsecurity issues$ snyk iac test /path/to/
Kubernetes_file.yaml$ snyk iac test /path/to/terraform_file.tf

Detect, track, and alert on infrastructure drift
and unmanaged resources$ snyk iac describe <OPTIONS>

AuthorBrian Vermeer

Sr. Developer Advocate

Snyk

To learn about the capabilities of the Snyk CLI,
see the Snyk CLI documentation.

11