Outputting the test results to a JSON or SARIF format in the terminal

You can output the CLI Code test results to a JSON or SARIF format in the terminal, instead of displaying the results in the standard CLI format.

Notes:

  • SARIF is an open standard for the output of static analysis tools. For more information on SARIT, see the official SARIF site.

  • The severity levels of the issues discovered in the Snyk Code test are displayed differently in the JSON and SARIF outputs. The severity levels in the JSON and SARIF results are as follows:

    • High = error

    • Medium = warning

    • Low = note/info

The designation Critical is not used in Snyk Code.

An example for the medium level, warning, follows:

Outputting the test results to a JSON format

To output the test results to a JSON format:

  • In the terminal, enter:

snyk code test <path/to/folder> --json

The test results appear in the terminal in a JSON format.

For example:

To output the test results of the snyk-goof-master folder in a JSON format in the terminal, we enter:

snyk code test /Users/username/Documents/Repositories/snyk-goof-master --json

The test results appear in the terminal in a JSON format:

Outputting the test results to a SARIF format

To output the test results to a SARIF format:

  • In the terminal, enter:

snyk code test <path/to/folder> --sarif

The test results appear in the terminal in a SARIF format.

For example:

To output the test results of the snyk-goof-master folder in a SARIF format, we enter:

snyk code test /Users/username/Documents/Repositories/snyk-goof-master --sarif

The test results appear in the terminal in a SARIF format:

Last updated

Was this helpful?

#4580: CLI: help, Ignore - support ticket 49463-add Iac examples

Change request updated