Skip to content

Commit

Permalink
Merge pull request #2513 from snyk/docs/revise-code-command-help
Browse files Browse the repository at this point in the history
docs: update code command help
  • Loading branch information
Avishagp authored Jan 12, 2022
2 parents f001903 + 83d5aa2 commit f76f946
Showing 1 changed file with 27 additions and 83 deletions.
110 changes: 27 additions & 83 deletions help/cli-commands/code.md
Original file line number Diff line number Diff line change
@@ -1,114 +1,58 @@
# snyk code -- Find security issues using Static code analysis
# snyk code -- find security issues using static code analysis

## Usage

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

## Description

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

[For more information see the CLI for Snyk Code help page](https://docs.snyk.io/snyk-code/cli-for-snyk-code)
For more information see [CLI for Snyk Code](https://docs.snyk.io/snyk-code/cli-for-snyk-code).

## Commands

### `test`
## Command: `test`

Test for any known issue.

## Options

### `--severity-threshold=low|medium|high|critical`

Only report configuration issues with the provided severity level or higher. Please note that the Snyk Code configuration issues do not currently use the `critical` severity level.

### `--json`

Prints results in JSON format.

### `--org=<ORG_NAME>`

Specify the <ORG_NAME> to run Snyk commands tied to a specific organization. This will influence private tests limits.
If you have multiple organizations, you can set a default from the CLI using:

`$ snyk config set org=<ORG_NAME>`

Setting a default will ensure all newly tested projects will be tested
under your default organization. If you need to override the default, you can use the `--org=<ORG_NAME>` argument.
Default: uses <ORG_NAME> that sets as default in your [Account settings](https://app.snyk.io/account)

### `--sarif`

Return results in SARIF format.

### Flags available accross all commands

#### `--insecure`

Ignore unknown certificate authorities.

#### `-d`

Output debug logs.

#### `--quiet`, `-q`

Silence all output.

#### `--version`, `-v`

Prints versions.

#### `--help [<COMMAND>]`, `[<COMMAND>] --help`, `-h`

Prints a help text. You may specify a `<COMMAND>` to get more details.

## Environment

You can set these environment variables to change CLI settings.

### `SNYK_TOKEN`

Snyk authorization token. Setting this envvar will override the token that may be available in your `snyk config` settings.
## Exit codes

[How to get your account token](https://snyk.co/ucT6J)<br />
[How to use Service Accounts](https://snyk.co/ucT6L)<br />
Possible exit codes and their meaning:

### `SNYK_CFG_KEY`
**0**: success, no vulnerabilities found<br />
**1**: action_needed, vulnerabilities found<br />
**2**: failure, try to re-run command<br />
**3**: failure, no supported projects detected<br />

Allows you to override any key that's also available as `snyk config` option.
## Configure the Snyk CLI

E.g. `SNYK_CFG_ORG=myorg` will override default org option in `config` with "myorg".
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](https://docs.snyk.io/features/snyk-cli/configure-the-snyk-cli).

### `SNYK_REGISTRY_USERNAME`
## Debug

Specify a username to use when connecting to a container registry. Note that using the `--username` flag will override this value. This will be ignored in favour of local Docker binary credentials when Docker is present.
Use the `-d` option to output the debug logs.

### `SNYK_REGISTRY_PASSWORD`
## Options

Specify a password to use when connecting to a container registry. Note that using the `--password` flag will override this value. This will be ignored in favour of local Docker binary credentials when Docker is present.
### `--org=<ORG_NAME>`

### Connecting to Snyk API
Specify the `<ORG_NAME>`to run Snyk commands tied to a specific organization. The `<ORG_NAME>` influences private test limits.

By default Snyk CLI will connect to `https://snyk.io/api/v1`.
If you have multiple organizations, you can set a default from the CLI using:

#### `SNYK_API`
`$ snyk config set org=<ORG_NAME>`

Sets API host to use for Snyk requests. Useful for on-premise instances and configuring proxies. If set with `http` protocol CLI will upgrade the requests to `https`. Unless `SNYK_HTTP_PROTOCOL_UPGRADE` is set to `0`.
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_NAME>` option.

#### `SNYK_HTTP_PROTOCOL_UPGRADE=0`
Default: `<ORG_NAME>` that is the current preferred organization in your [Account settings](https://app.snyk.io/account).

If set to the value of `0`, API requests aimed at `http` URLs will not be upgraded to `https`. If not set, the default behavior will be to upgrade these requests from `http` to `https`. Useful e.g., for reverse proxies.
### `--json`

#### `HTTPS_PROXY` and `HTTP_PROXY`
Print results in JSON format.

Allows you to specify a proxy to use for `https` and `http` calls. The `https` in the `HTTPS_PROXY` means that _requests using `https` protocol_ will use this proxy. The proxy itself doesn't need to use `https`.
### `--sarif`

## Exit codes
Return results in SARIF format.

Possible exit codes and their meaning:
### `--severity-threshold=low|medium|high|critical`

**0**: success, no vulns found<br />
**1**: action_needed, vulns found<br />
**2**: failure, try to re-run command<br />
**3**: failure, no supported projects detected<br />
Report only vulnerabilities at the specified level or higher. Note that the Snyk Code configuration issues do not currently use the `critical` severity level.

0 comments on commit f76f946

Please sign in to comment.