Snyk Code enables you to test the source code of your repositories using the Snyk CLI.
When testing your repository code via the CLI, you can:
When you test a folder, all its sub-folders and files are also tested.
To exclude certain directories or files from the Snyk Code CLI test, you can use the following means:
snyk ignore --file-pathcommand. See Excluding directories and files from the Snyk Code test.
Manually creating a
.snykfile in the tested folder. See Excluding directories and files from the import process.
Testing a repository from its root folder
To test the current repository folder, in the terminal, enter the following:
snyk code test
No additional options are required for using the
snyk code test command to test a repository from its root folder.
Snyk Code tests the current folder and displays the test results in the terminal.
For example, to test the
snyk-goof repository from its root folder, first change the directory to the root folder of the repository. Then enter:
snyk code test
Snyk Code tests the
snyk-goof repository, and displays the vulnerability issues that were discovered:
Testing a repository from a different location
To test a repository from another folder, in the terminal, enter the following:
snyk code test <path/to/folder>
path/to/folder is the full path of the repository you want to test using Snyk Code via the CLI.
For example, to test the snyk-goof repository from another directory, enter:
snyk code test /Users/username/Documents/Repositories/snyk-goof
To explore the test results, see View Snyk Code CLI results.
To work with the test results, see Displaying the CLI results in an HTML format using the Snyk-to-HTML feature.