Steps to Snyk CLI Success

akira
2 min readAug 1, 2023

--

Step one: Download the CLI

MacOS

curl --compressed https://static.snyk.io/cli/latest/snyk-macos -o snyk
chmod +x ./snyk
mv ./snyk /usr/local/bin/

Or, install with homebrew:

brew tap snyk/tap
brew install snyk

To run Snyk CLI on an Apple M1 machine, you need to install Apple’s Rosetta 2 software. You can do so by running the following in a terminal:

softwareupdate --install-rosetta

For all other downloadable executables for other OS’ (Windows, Linux, etc) click here

Note: If you download a text editor integration, such as the VS Code integration, Snyk automatically installs the CLI as part of the package

Check that the Snyk CLI is installed by running

snyk --version

Step Two: Authenticate to Snyk

Authenticate to Snyk by running the following command:

snyk auth

This will open a separate browser window where you can connect to Snyk via Okta.

When complete, you should see something like this:

A terminal window displaying a redirect to the Snyk login page, and that the authentication process was successfully completed

Step Three: Scan Some Dependency Code!

Navigate to the root of your project folder, and run

snyk test

The output is the test results of all the packages in your package.json file.

Step Four: Scan Your Source Code!

To scan the source code of your application, run

snyk code test

This may take a while to complete. After it is done, you can see places in your code that may have issues, along with a description of the issue.

Bonus: Set up Monitoring for your Project

Snyk can monitor your Project periodically and alert you to new vulnerabilities. To set up your Project to be monitored, run:

snyk moniter

You will then see a terminal window with a URL of where to go to find a report.

--

--