code.md 1.96 KB

Code

Usage

snyk code [<COMMAND>] [<OPTIONS>] [<PATH>]

Description

The snyk code command finds security issues using Static Code Analysis.

For more information see CLI for Snyk Code.

Command: test

Test for any known issue.

Exit codes

Possible exit codes and their meaning:

0: success, no vulnerabilities found\ 1: action_needed, vulnerabilities found\ 2: failure, try to re-run command\ 3: failure, no supported projects detected

Configure the Snyk CLI

You can use environment variables to configure the Snyk CLI and also set variables to configure the Snyk CLI to connect with the Snyk API. See Configure the Snyk CLI.

Debug

Use the -d option to output the debug logs.

Options

--org=<ORG_ID>

Specify the <ORG_ID>to run Snyk commands tied to a specific organization. The <ORG_ID> influences private test limits.

If you have multiple organizations, you can set a default from the CLI using:

$ snyk config set org=<ORG_ID>

Set a default to ensure all newly tested projects are tested under your default organization. If you need to override the default, use the --org=<ORG_ID> option.

Default: <ORG_ID> that is the current preferred organization in your Account settings.

Example: $ snyk code test --org=my-team

For more information see the article How to select the organization to use in the CLI.

--json

Print results in JSON format.

Example: $ snyk code test --json-file-output=vuln.json

--sarif

Return results in SARIF format.

--severity-threshold=<low|medium|high|critical>

Report only vulnerabilities at the specified level or higher. Note that the Snyk Code configuration issues do not currently use the critical severity level.