snyk
Version:
snyk library and cli utility
462 lines (327 loc) • 20.4 kB
Plain Text
[1mNAME[0m
[1msnyk [22m- CLI and build-time tool to find & fix known vulnerabilities in
open-source dependencies
[1mSYNOPSIS[0m
[1msnyk [22m[[4mCOMMAND[24m] [[4mSUBCOMMAND[24m] [[4mOPTIONS[24m] [[4mPACKAGE[24m] [-- [4mCOMPILER_OPTIONS[24m]
[1mDESCRIPTION[0m
Snyk helps you find, fix and monitor known vulnerabilities in open
source dependencies.
For more information see https://snyk.io
[1mNot sure where to start?[0m
1. authenticate with [1m$ snyk auth[0m
2. test your local project with [1m$ snyk test[0m
3. get alerted for new vulnerabilities with [1m$ snyk monitor[0m
[1mCOMMANDS[0m
To see command-specific flags and usage, see [1mhelp [22mcommand, e.g. [1msnyk[0m
[1mcontainer --help[22m. Available top-level CLI commands:
[1mauth [22m[[4mAPI_TOKEN[24m]
Authenticate Snyk CLI with a Snyk account.
[1mtest [22mTest local project for vulnerabilities.
[1mmonitor[0m
Snapshot and continuously monitor your project.
[1mcontainer[0m
Test container images for vulnerabilities. See [1msnyk container[0m
[1m--help [22mfor full instructions.
[1miac [22mFind security issues in your Infrastructure as Code files. See
[1msnyk iac --help [22mfor full instructions.
[1mcode [22mFind security issues using static code analysis. See [1msnyk code[0m
[1m--help [22mfor full instructions.
[1mconfig [22mManage Snyk CLI configuration.
[1mprotect[0m
Applies the patches specified in your .snyk file to the local
file system.
[1mpolicy [22mDisplay the .snyk policy for a package.
[1mignore [22mModifies the .snyk policy to ignore stated issues.
[1mwizard [22mConfigure your policy file to update, auto patch and ignore vul-
nerabilities. Snyk wizard updates your .snyk file.
[1mOPTIONS[0m
To see command-specific flags and usage, see [1mhelp [22mcommand, e.g. [1msnyk[0m
[1mcontainer --help[22m. For advanced usage, we offer language and context
specific flags, listed further down this document.
[1m--all-projects[0m
(only in [1mtest [22mand [1mmonitor [22mcommands) Auto-detect all projects in
working directory
[1m--detection-depth[22m=[4mDEPTH[0m
(only in [1mtest [22mand [1mmonitor [22mcommands) Use with --all-projects or
--yarn-workspaces to indicate how many sub-directories to
search. [1mDEPTH [22mmust be a number.
Default: 4 (the current working directory and 3 sub-directories)
[1m--exclude[22m=[4mDIRECTORY[24m[,[4mDIRECTORY[24m]...>
(only in [1mtest [22mand [1mmonitor [22mcommands) Can be used with
--all-projects and --yarn-workspaces to indicate sub-directories
and files to exclude. Must be comma separated.
If using with [1m--detection-depth [22mexclude ignores directories at
any level deep.
[1m--prune-repeated-subdependencies[22m, [1m-p[0m
(only in [1mtest [22mand [1mmonitor [22mcommands) Prune dependency trees, re-
moving duplicate sub-dependencies. Will still find all vulnera-
bilities, but potentially not all of the vulnerable paths.
[1m--print-deps[0m
(only in [1mtest [22mand [1mmonitor [22mcommands) Print the dependency tree
before sending it for analysis.
[1m--remote-repo-url[22m=[4mURL[0m
Set or override the remote URL for the repository that you would
like to monitor.
[1m--dev [22mInclude development-only dependencies. Applicable only for some
package managers. E.g. [4mdevDependencies[24m in npm or [4m:development[0m
dependencies in Gemfile.
Default: scan only production dependencies
[1m--org[22m=[4mORG_NAME[0m
Specify the [4mORG_NAME[24m to run Snyk commands tied to a specific or-
ganization. This will influence where will new projects be cre-
ated after running [1mmonitor [22mcommand, some features availability
and private tests limits. If you have multiple organizations,
you can set a default from the CLI using:
[1m$ snyk config set org[22m=[4mORG_NAME[0m
Setting a default will ensure all newly monitored projects will
be created under your default organization. If you need to over-
ride the default, you can use the [1m--org[22m=[4mORG_NAME[24m argument.
Default: uses [4mORG_NAME[24m that sets as default in your Account set-
tings [4mhttps://app.snyk.io/account[0m
[1m--file[22m=[4mFILE[0m
Sets a package file.
When testing locally or monitoring a project, you can specify
the file that Snyk should inspect for package information. When
ommitted Snyk will try to detect the appropriate file for your
project.
[1m--ignore-policy[0m
Ignores all set policies. The current policy in [1m.snyk [22mfile, Org
level ignores and the project policy on snyk.io.
[1m--trust-policies[0m
Applies and uses ignore rules from your dependencies' Snyk poli-
cies, otherwise ignore policies are only shown as a suggestion.
[1m--show-vulnerable-paths[22m=none|some|all
Display the dependency paths from the top level dependencies,
down to the vulnerable packages. Doesn't affect output when us-
ing JSON [1m--json [22moutput.
Default: [4msome[24m (a few example paths shown) [4mfalse[24m is an alias for
[4mnone[24m.
[1m--project-name[22m=[4mPROJECT_NAME[0m
Specify a custom Snyk project name.
[1m--target-reference[22m=[4mTARGET_REFERENCE[0m
A reference to separate this project from other scans of the
same project. For example, a branch name or version. Projects
using the same reference can be used for grouping. More informa-
tion [4mhttps://snyk.info/3B0vTPs[24m.
[1m--project-environment[22m=[4mENVIRONMENT[24m[,[4mENVIRONMENT[24m]...>
(only in [1mmonitor [22mcommand) Set the project environment to one or
more values (comma-separated). Allowed values: frontend, back-
end, internal, external, mobile, saas, onprem, hosted, distrib-
uted
[1m--project-lifecycle[22m=[4mLIFECYCLE[24m[,[4mLIFECYCLE[24m]...>
(only in [1mmonitor [22mcommand) Set the project lifecycle to one or
more values (comma-separated). Allowed values: production, de-
velopment, sandbox
[1m--project-business-criticality[22m=[4mBUSINESS_CRITICALITY[24m[,[4mBUSINESS_CRITICAL-[0m
[4mITY[24m]...>
(only in [1mmonitor [22mcommand) Set the project business criticality
to one or more values (comma-separated). Allowed values: criti-
cal, high, medium, low
[1m--project-tags[22m=[4mTAG[24m[,[4mTAG[24m]...>
(only in [1mmonitor [22mcommand) Set the project tags to one or more
values (comma-separated key value pairs with an "=" separator).
e.g. --project-tags=department=finance,team=alpha
[1m--policy-path[22m=[4mPATH_TO_POLICY_FILE[24m`
Manually pass a path to a snyk policy file.
[1m--json [22mPrints results in JSON format.
[1m--json-file-output[22m=[4mOUTPUT_FILE_PATH[0m
(only in [1mtest [22mcommand) Save test output in JSON format directly
to the specified file, regardless of whether or not you use the
[1m--json [22moption. This is especially useful if you want to display
the human-readable test output via stdout and at the same time
save the JSON format output to a file.
[1m--sarif[0m
Return results in SARIF format.
[1m--sarif-file-output[22m=[4mOUTPUT_FILE_PATH[0m
(only in [1mtest [22mcommand) Save test output in SARIF format directly
to the [4mOUTPUT_FILE_PATH[24m file, regardless of whether or not you
use the [1m--sarif [22moption. This is especially useful if you want to
display the human-readable test output via stdout and at the
same time save the SARIF format output to a file.
[1m--severity-threshold[22m=low|medium|high|critical
Only report vulnerabilities of provided level or higher.
[1m--fail-on[22m=all|upgradable|patchable
Only fail when there are vulnerabilities that can be fixed.
[4mall[24m fails when there is at least one vulnerability that can be
either upgraded or patched. [4mupgradable[24m fails when there is at
least one vulnerability that can be upgraded. [4mpatchable[24m fails
when there is at least one vulnerability that can be patched.
If vulnerabilities do not have a fix and this option is being
used, tests will pass.
[1m--dry-run[0m
(only in [1mprotect [22mcommand) Don't apply updates or patches during
[1mprotect [22mcommand run.
[1m-- [22m[[4mCOMPILER_OPTIONS[24m]
Pass extra arguments directly to Gradle or Maven. E.g. [1msnyk test[0m
[1m-- --build-cache[0m
Below are flags that are influencing CLI behavior for specific
projects, languages and contexts:
[1mMaven options[0m
[1m--scan-all-unmanaged[0m
Auto detects maven jars, aars, and wars in given directory. In-
dividual testing can be done with [1m--file[22m=[4mJAR_FILE_NAME[0m
[1m--reachable[0m
(only in [1mtest [22mand [1mmonitor [22mcommands) Analyze your source code to
find which vulnerable functions and packages are called.
[1m--reachable-timeout[22m=[4mTIMEOUT[0m
The amount of time (in seconds) to wait for Snyk to gather
reachability data. If it takes longer than [4mTIMEOUT[24m, Reachable
Vulnerabilities are not reported. This does not affect regular
test or monitor output.
Default: 300 (5 minutes).
[1mGradle options[0m
More information about Gradle CLI options [4mhttps://snyk.co/ucT6P[0m
O [1m--sub-project[22m=[4mNAME[24m, [1m--gradle-sub-project[22m=[4mNAME[24m: For Gradle "multi
project" configurations, test a specific sub-project.
O [1m--all-sub-projects[22m: For "multi project" configurations, test all
sub-projects.
O [1m--configuration-matching[22m=[4mCONFIGURATION_REGEX[24m: Resolve dependencies
using only configuration(s) that match the provided Java regular
expression, e.g. [1m^releaseRuntimeClasspath$[22m.
O [1m--configuration-attributes[22m=[4mATTRIBUTE[24m[,[4mATTRIBUTE[24m]...: Select certain
values of configuration attributes to resolve the dependencies.
E.g. [1mbuildtype:release,usage:java-runtime[0m
O [1m--reachable[22m: (only in [1mtest [22mand [1mmonitor [22mcommands) Analyze your
source code to find which vulnerable functions and packages are
called.
O [1m--reachable-timeout[22m=[4mTIMEOUT[24m: The amount of time (in seconds) to
wait for Snyk to gather reachability data. If it takes longer than
[4mTIMEOUT[24m, Reachable Vulnerabilities are not reported. This does not
affect regular test or monitor output.
Default: 300 (5 minutes).
O [1m--init-script[22m=[4mFILE[24m For projects that contain a gradle initializa-
tion script.
[1m.Net & NuGet options[0m
[1m--assets-project-name[0m
When monitoring a .NET project using NuGet [1mPackageReference [22muse
the project name in project.assets.json, if found.
[1m--packages-folder[0m
Custom path to packages folder
[1m--project-name-prefix[22m=[4mPREFIX_STRING[0m
When monitoring a .NET project, use this flag to add a custom
prefix to the name of files inside a project along with any de-
sired separators, e.g. [1msnyk monitor --file=my-project.sln[0m
[1m--project-name-prefix=my-group/[22m. This is useful when you have
multiple projects with the same name in other sln files.
[1mnpm options[0m
[1m--strict-out-of-sync[22m=true|false
Control testing out of sync lockfiles.
Default: true
[1mYarn options[0m
[1m--strict-out-of-sync[22m=true|false
Control testing out of sync lockfiles.
Default: true
[1m--yarn-workspaces[0m
(only in [1mtest [22mand [1mmonitor [22mcommands) Detect and scan yarn
workspaces. You can specify how many sub-directories to search
using [1m--detection-depth [22mand exclude directories and files using
[1m--exclude[22m.
[1mCocoaPods options[0m
[1m--strict-out-of-sync[22m=true|false
Control testing out of sync lockfiles.
Default: false
[1mPython options[0m
[1m--command[22m=[4mCOMMAND[0m
Indicate which specific Python commands to use based on Python
version. The default is [1mpython [22mwhich executes your systems de-
fault python version. Run 'python -V' to find out what version
is it. If you are using multiple Python versions, use this pa-
rameter to specify the correct Python command for execution.
Default: [1mpython [22mExample: [1m--command=python3[0m
[1m--skip-unresolved[22m=true|false
Allow skipping packages that are not found in the environment.
[1mFlags available accross all commands[0m
[1m--insecure[0m
Ignore unknown certificate authorities.
[1m-d [22mOutput debug logs.
[1m--quiet[22m, [1m-q[0m
Silence all output.
[1m--version[22m, [1m-v[0m
Prints versions.
[[4mCOMMAND[24m] [1m--help[22m, [1m--help [22m[[4mCOMMAND[24m], [1m-h[0m
Prints a help text. You may specify a [4mCOMMAND[24m to get more de-
tails.
[1mEXAMPLES[0m
[1mAuthenticate in your CI without user interaction[0m
$ snyk auth MY_API_TOKEN
[1mTest a project in current folder for known vulnerabilities[0m
$ snyk test
[1mTest a specific dependency for vulnerabilities[0m
$ snyk test ionic@1.6.5
More examples:
$ snyk test --show-vulnerable-paths=false
$ snyk monitor --org=my-team
$ snyk monitor --project-name=my-project
[1mContainer scanning[0m
See [1msnyk container --help [22mfor more details and examples:
$ snyk container test ubuntu:18.04 --org=my-team
$ snyk container test app:latest --file=Dockerfile --policy-path=path/to/.snyk
[1mInfrastructure as Code (IAC) scanning[0m
See [1msnyk iac --help [22mfor more details and examples:
$ snyk iac test /path/to/cloudformation_file.yaml
$ snyk iac test /path/to/kubernetes_file.yaml
$ snyk iac test /path/to/terraform_file.tf
$ snyk iac test /path/to/tf-plan.json
$ snyk iac test /path/to/arm_file.json
To use your own custom rules to scan IaC configuration files, download
the [1msnyk-iac-rules [22mSDK from https://github.com/snyk/snyk-iac-rules.
Follow the instructions there to write, build, and push a custom rules
bundle and then either use the Snyk UI to configure your custom rules
settings or configure a remote OCI registry locally by running the fol-
lowing commands:
$ snyk config set oci-registry-url=https://registry-1.docker.io/username/repo:tag
$ snyk config set oci-registry-username=username
$ snyk config set oci-registry-password=password
[1mStatic code analysis (SAST) scanning[0m
See [1msnyk code --help [22mfor more details and examples:
$ snyk code test /path/to/project
[1mEXIT CODES[0m
Possible exit codes and their meaning:
[1m0[22m: success, no vulns found
[1m1[22m: action_needed, vulns found
[1m2[22m: failure, try to re-run command
[1m3[22m: failure, no supported projects detected
[1mENVIRONMENT[0m
You can set these environment variables to change CLI run settings.
[1mSNYK_TOKEN[0m
Snyk authorization token. Setting this envvar will override the
token that may be available in your [1msnyk config [22msettings.
How to get your account token [4mhttps://snyk.co/ucT6J[0m
How to use Service Accounts [4mhttps://snyk.co/ucT6L[0m
[1mSNYK_CFG_KEY[0m
Allows you to override any key that's also available as [1msnyk[0m
[1mconfig [22moption.
E.g. [1mSNYK_CFG_ORG[22m=myorg will override default org option in [1mcon-[0m
[1mfig [22mwith "myorg".
[1mSNYK_REGISTRY_USERNAME[0m
Specify a username to use when connecting to a container reg-
istry. Note that using the [1m--username [22mflag will override this
value. This will be ignored in favour of local Docker binary
credentials when Docker is present.
[1mSNYK_REGISTRY_PASSWORD[0m
Specify a password to use when connecting to a container reg-
istry. Note that using the [1m--password [22mflag will override this
value. This will be ignored in favour of local Docker binary
credentials when Docker is present.
[1mConnecting to Snyk API[0m
By default Snyk CLI will connect to [1mhttps://snyk.io/api/v1[22m.
[1mSNYK_API[0m
Sets API host to use for Snyk requests. Useful for on-premise
instances and configuring proxies. If set with [1mhttp [22mprotocol CLI
will upgrade the requests to [1mhttps[22m. Unless [1mSNYK_HTTP_PROTO-[0m
[1mCOL_UPGRADE [22mis set to [1m0[22m.
[1mSNYK_HTTP_PROTOCOL_UPGRADE[22m=0
If set to the value of [1m0[22m, API requests aimed at [1mhttp [22mURLs will
not be upgraded to [1mhttps[22m. If not set, the default behavior will
be to upgrade these requests from [1mhttp [22mto [1mhttps[22m. Useful e.g.,
for reverse proxies.
[1mHTTPS_PROXY [22mand [1mHTTP_PROXY[0m
Allows you to specify a proxy to use for [1mhttps [22mand [1mhttp [22mcalls.
The [1mhttps [22min the [1mHTTPS_PROXY [22mmeans that [4mrequests[24m [4musing[24m [1mhttps[0m
protocol will use this proxy. The proxy itself doesn't need to
use [1mhttps[22m.
[1mNOTICES[0m
[1mSnyk API usage policy[0m
The use of Snyk's API, whether through the use of the 'snyk' npm pack-
age or otherwise, is subject to the terms & conditions
[4mhttps://snyk.co/ucT6N[0m