CLI commands and options summary
This page only summarizes the CLI commands and the options for each command. For details, use the links in this summary to open the help docs page for the command you are using. The help docs pages are the same as the help in the CLI.
Usage
snyk [COMMAND] [SUBCOMMAND] [OPTIONS] [PACKAGE] [CONTEXT-SPECIFIC-OPTIONS]
Description
The Snyk CLI is a build-time tool to find and fix known vulnerabilities in your projects. For a more detailed description of Snyk CLI and Snyk, see Snyk CLI. For an introduction on how to use the Snyk CLI, see Getting started with the CLI.
Available CLI commands
To learn more about each Snyk CLI command, use the --help
option, for example, snyk auth --help
or snyk container --help
. Each command in this list is linked to the corresponding help page in these docs.
Note: Lists of all the options for Snyk CLI commands are on this page. The options are explained in detail in the help for each command.
Authenticate Snyk CLI with a Snyk account.
Manage Snyk CLI configuration.
Use to set your environment for the region before you run the snyk auth
command.
Test a Project for open-source vulnerabilities and license issues.
Snapshot and continuously monitor a project for open-source vulnerabilities and license issues.
Print the name of the snyk code
command with its help option: snyk code test
Test source code for any known security issues (Static Application Security Testing).
Print a list of the snyk container
commands, snyk container monitor
and snyk container test
.
Capture the container image layers and dependencies and monitor for vulnerabilities on snyk.io.
Generate an SBOM for a container image
Test container images for any known vulnerabilities.
Print a list of the snyk iac
commands: snyk iac describe
, snyk iac update-exclude-policy
, and snyk iac test
.
Test for any known security issue.
Generate a mapping artifact that contains the minimum amount of information needed to generate resource mappings from code to Cloud from Terraform state files, such as resource IDs and names, and send the mapping artifact to Snyk.
Detect, track, and alert on infrastructure drift and unmanaged resources.
Initialize custom rules project structure, relation, rule, or spec
Run tests for all custom rules.
Bundle and upload custom rule bundles to Snyk Cloud API.
Generate exclude policy rules to be used by snyk iac describe
.
Modify the .snyk
policy to ignore stated issues.
Find Log4Shell vulnerability.
generates a mapping artifact that contains the minimum amount of information needed to generate, from Terraform state files, resource mappings from code to Cloud, such as resource IDs and names, and sends the mapping artifact to Snyk.Display the .snyk
policy for a package.
Generate an SBOM for a local software project in an ecosystem supported by Snyk.
Checks an SBOM for vulnerabilities in open-source packages.
New CLI commands
Apply the recommended updates for supported ecosystems automatically. For more information, see Automatic fixing with snyk fix
.
Create a Snyk App using the Snyk CLI. For more information, see Snyk Apps.
Subcommands of CLI commands
The following is a list of the sub-commands for Snyk CLI commands. Each sub-command is followed by the command(s) to which the sub-command applies. The commands are linked to their help docs. For details concerning each sub-command, see the help docs.
get <KEY>
: subcommand of config
set <KEY>=<VALUE>
: subcommand of config
unset <KEY>
: subcommand of config
clear
: subcommand of config
environment
: subcommand of config
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 -d
option to output the debug logs for any command.
Exit codes for CLI commands
Exit codes for the test
commands are all the same. See the exit codes in the following help docs:
Additional CLI commands have exit codes as listed in the following help docs:
Options for multiple commands
Lists of the options for Snyk CLI commands follow. Each option is followed by the command(s) to which the option applies. The commands are linked to their help docs. For details concerning each option, see the help docs.
--all-projects
: test
, monitor
,sbom
--detection-depth=<DEPTH>
: test
, monitor
, iac test
, sbom
--exclude=<NAME>[,<NAME>]...>
: test
, monitor
, sbom
--prune-repeated-subdependencies, -p
: test
, monitor
, sbom
--print-deps
: test
, monitor
, container test
--remote-repo-url=<URL>
: test
, monitor
, iac test
--org=<ORG_ID>
: test
, monitor
, code test
, container test
, container monitor, iac test
, iac describe
, iac capture
, sbom
, container sbom
--file=<FILE_PATH>
: container test, container monitor
, sbom test
--package-manager=<PACKAGE_MANAGER_NAME>
: test
, monitor
--unmanaged:
test,
monitor. See also Options for scanning using --unmanaged
and the sbom
command help for another use of this option.
--ignore-policy
: test
, monitor
, iac test
, iac describe
--trust-policies
test
, monitor
--show-vulnerable-paths=<none|some|all>
test
--project-name=<PROJECT_NAME>
: test
, monitor
, container test
, container monitor
--target-reference=<TARGET_REFERENCE>
: test
, monitor
, iac test
,
container monitor
--policy-path=<PATH_TO_POLICY_FILE>
: test
, monitor
, container test
, container monitor
, iac test
, iac describe
, ignore
--json
: test
, monitor
, code test
, container test
, container monitor
, iac test
, iac describe
, sbom test
--json-file-output=<OUTPUT_FILE_PATH>
: test
, code test
, container test
, iac test
,sbom
--sarif
: test
, code test
, container test
, iac test
--sarif-file-output=<OUTPUT_FILE_PATH>
: test
, code test
, container test
, iac test
--severity-threshold=<low|medium|high|critical>
: test
, code test
, container test
, iac test
--fail-on=<all|upgradable|patchable>
: container test
, test
--project-environment=<ENVIRONMENT>[,<ENVIRONMENT>]...>
: monitor
, container monitor
, iac test
--project-lifecycle=<LIFECYCLE>[,<LIFECYCLE>]...>
: monitor
, container monitor
, iac test
--project-business-criticality=<BUSINESS_CRITICALITY>[,<BUSINESS_CRITICALITY>]...>
: monitor
, container monitor
, iac test