snyk 1.1276.0 โ†’ 1.1277.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,323 +1,120 @@
1
- <p align="center">
2
- <img src="https://snyk.io/style/asset/logo/snyk-print.svg" />
3
- </p>
1
+ # Getting started with the Snyk CLI
4
2
 
5
- # Snyk CLI
3
+ ## Introduction to Snyk and the Snyk CLI
6
4
 
7
- [Snyk](https://snyk.io) scans and monitors your projects for security vulnerabilities.
5
+ [Snyk](https://snyk.io/) is a developer-first, cloud-native security tool to scan and monitor your software development projects for security vulnerabilities. Snyk scans multiple content types for security issues:
8
6
 
9
- ![Snyk CLI screenshot](help/snyk-cli-screenshot.png)
7
+ - [**Snyk Open Source**](https://docs.snyk.io/scan-using-snyk/snyk-open-source): Find and automatically fix open-source vulnerabilities
8
+ - [**Snyk Code**](https://docs.snyk.io/scan-using-snyk/snyk-code): Find and fix vulnerabilities in your application code in real time
9
+ - [**Snyk Container**](https://docs.snyk.io/scan-using-snyk/snyk-container): Find and fix vulnerabilities in container images and Kubernetes applications
10
+ - [**Snyk Infrastructure as Code**](https://docs.snyk.io/scan-using-snyk/scan-infrastructure): Find and fix insecure configurations in Terraform and Kubernetes code
10
11
 
11
- # What is [Snyk](https://snyk.io)?
12
+ [Learn more about what Snyk can do and sign up for a free account](https://snyk.io/).
12
13
 
13
- [Snyk](https://snyk.io) is a developer-first cloud-native security tool.
14
- It covers multiple areas of application security:
14
+ The **Snyk CLI brings the functionality of Snyk into your development workflow**. You can run the CLI locally from the command line or in an IDE. You can also run the CLI in your CI/CD pipeline. The following shows an example of Snyk CLI test command output.
15
15
 
16
- 1. [**Snyk Open Source**](https://snyk.io/product/open-source-security-management/): Find and automatically fix open source vulnerabilities
17
- 2. [**Snyk Code**](https://snyk.io/product/snyk-code/): Find and fix vulnerabilities in your application code in real time
18
- 3. [**Snyk Container**](https://snyk.io/product/container-vulnerability-management/): Find and fix vulnerabilities in container images and Kubernetes applications
19
- 4. [**Snyk Infrastructure as Code**](https://snyk.io/product/infrastructure-as-code-security/): Find and fix insecure configurations in Terraform and Kubernetes code
16
+ <figure><img src="https://github.com/snyk/user-docs/raw/HEAD/docs/.gitbook/assets/snyk-cli-screenshot.png" alt="Snyk CLI test command output example"><figcaption><p>Snyk CLI test command output</p></figcaption></figure>
20
17
 
21
- [Learn more about what Snyk can do and sign up for a free account ยป](https://snyk.io)
18
+ Snyk CLI scanning **supports many languages and tools.** For detailed information, see the [summary of supported environments](https://docs.snyk.io/getting-started/introducing-snyk#how-can-snyk-work-in-my-environment).
22
19
 
23
- # What is Snyk CLI?
20
+ This page explains how to install, authenticate, and start scanning using the CLI. Snyk also has an onboarding wizard to guide you through these steps. For a demonstration, view [Starting with Snyk: an overview of the CLI onboarding flow](https://www.youtube.com/watch?v=adj3VF82-v8).
24
21
 
25
- Snyk CLI brings the functionality of [Snyk](https://snyk.io) into your development workflow. It can be run locally or in your CI/CD pipeline to scan your projects for security issues.
22
+ ## Install the Snyk CLI and authenticate your machine
26
23
 
27
- ## Supported languages and tools
24
+ To use the CLI, you must install it and authenticate your machine. See [Install or update the Snyk CLI](https://docs.snyk.io/snyk-cli/install-the-snyk-cli) and [Authenticate the CLI with your account](https://docs.snyk.io/snyk-cli/authenticate-the-cli-with-your-account). You can refer to the [release notes](https://github.com/snyk/cli/releases) for a summary of changes in each release. Before scanning your code, review the [Code execution warning for Snyk CLI](https://docs.snyk.io/snyk-cli/code-execution-warning-for-snyk-cli).
28
25
 
29
- Snyk supports many languages and tools, including Java, .NET, JavaScript, Python, Golang, PHP, C/C++, Ruby, Scala and more. See our [Language Support documentation](https://support.snyk.io/hc/en-us/articles/360020352437-Language-support-summary).
26
+ **Note:** Before you can use the CLI for Open Source scanning, you must install your package manager. The needed third-party tools, such as Gradle or Maven, must be in the `PATH`.
30
27
 
31
- CLI also supports [Docker scanning](https://support.snyk.io/hc/en-us/articles/360003946897-Snyk-Container-security-overview) and [Terraform, k8s and other Infrastructure as Code files scanning](https://support.snyk.io/hc/en-us/categories/360001342678-Infrastructure-as-code).
28
+ You can use the CLI in your IDE or CI/CD environment. For details, see [Install as part of a Snyk integration](https://docs.snyk.io/snyk-cli/install-the-snyk-cli#install-as-a-part-of-a-snyk-integration).
32
29
 
33
- ---
30
+ ## Test your installation
34
31
 
35
- # Install Snyk CLI
32
+ After authenticating, you can **test your installation**. For a quick test, run `snyk --help`.
36
33
 
37
- Snyk CLI can be installed through multiple channels.
34
+ Alternatively, you can perform a **quick test** on a public npm package, for example `snyk test ionic`.
38
35
 
39
- ## Install with npm or Yarn
36
+ Look at the `test` command **report** in your terminal. The report shows the vulnerabilities Snyk found in the package. For each issue found, Snyk reports the severity of the issue, provides a link to a detailed description, reports the path through which the vulnerable module got into your system, and provides guidance on how to fix the problem.
40
37
 
41
- [Snyk CLI is available as an npm package](https://www.npmjs.com/package/snyk). If you have Node.js installed locally, you can install it by running:
38
+ ## Scan your development Project
42
39
 
43
- ```bash
44
- npm install snyk@latest -g
45
- ```
46
-
47
- or if you are using Yarn:
48
-
49
- ```bash
50
- yarn global add snyk
51
- ```
52
-
53
- ## More installation methods
54
-
55
- <details>
56
- <summary>Standalone executables (macOS, Linux, Windows)</summary>
57
-
58
- ### Standalone executables
59
-
60
- Use [GitHub Releases](https://github.com/snyk/snyk/releases) to download a standalone executable of Snyk CLI for your platform.
61
-
62
- We also provide these standalone executables on our official CDN. See [the `release.json` file](https://static.snyk.io/cli/latest/release.json) for the download links:
63
-
64
- ```text
65
- https://static.snyk.io/cli/latest/release.json
66
-
67
- # Or for specific version or platform
68
- https://static.snyk.io/cli/v1.666.0/release.json
69
- https://static.snyk.io/cli/latest/snyk-macos
70
- ```
71
-
72
- For example, to download and run the latest Snyk CLI on macOS, you could run:
73
-
74
- ```bash
75
- curl https://static.snyk.io/cli/latest/snyk-macos -o snyk
76
- chmod +x ./snyk
77
- mv ./snyk /usr/local/bin/
78
- ```
79
-
80
- You can also use these direct links to download the executables:
81
-
82
- - macOS: https://static.snyk.io/cli/latest/snyk-macos
83
- - Windows: https://static.snyk.io/cli/latest/snyk-win.exe
84
- - Linux: https://static.snyk.io/cli/latest/snyk-linux
85
- - Linux (arm64): https://static.snyk.io/cli/latest/snyk-linux-arm64
86
- - Alpine: https://static.snyk.io/cli/latest/snyk-alpine
87
-
88
- Drawback of this method is, that you will have to manually keep the Snyk CLI up to date.
89
-
90
- #### Verifying standalone binaries
91
-
92
- You can verify both shasum of downloaded binaries and their GPG signatures.
93
-
94
- Download location on `static.snyk.io` contains a file called `sha256sums.txt.asc`.
95
- You can download it directly `https://static.snyk.io/cli/latest/sha256sums.txt.asc` or for a specific version like `https://static.snyk.io/cli/v1.666.0/sha256sums.txt.asc`.
96
-
97
- To check that a downloaded file matches the checksum, use a `sha256sum` command like so:
98
-
99
- ```bash
100
- grep snyk-macos sha256sums.txt.asc | sha256sum -c -
101
- ```
102
-
103
- If you want to verify Snyk CLI standalone binaries against [Snyk CLI GPG key](help/_about-this-project/snyk-code-signing-public.pgp), you will need to import it first:
104
-
105
- ```bash
106
- # A22665FB96CAB0E0973604C83676C4B8289C296E is the key belonging to code-signing@snyk.io
107
- # Copy of this public key is also in this repository /help/_about-this-project/snyk-code-signing-public.pgp
108
- gpg --keyserver hkps://keys.openpgp.org --recv-keys A22665FB96CAB0E0973604C83676C4B8289C296E
109
- ```
110
-
111
- Then verify the file is signed with:
112
-
113
- ```bash
114
- gpg --verify sha256sums.txt.asc
115
- ```
116
-
117
- Command output should look like:
118
-
119
- ```plain
120
- gpg: Signature made So 8 Jan 14:11:44 2023 CET
121
- gpg: using EDDSA key A22665FB96CAB0E0973604C83676C4B8289C296E
122
- gpg: Good signature from "Snyk Limited <code-signing@snyk.io>" [unknown]
123
- gpg: WARNING: This key is not certified with a trusted signature!
124
- gpg: There is no indication that the signature belongs to the owner.
125
- Primary key fingerprint: A226 65FB 96CA B0E0 9736 04C8 3676 C4B8 289C 296E
126
- ```
127
-
128
- </details>
129
-
130
- <details>
131
- <summary>Install with Homebrew (macOS, Linux)</summary>
132
-
133
- ### Homebrew
134
-
135
- Install Snyk CLI from [Snyk tap](https://github.com/snyk/homebrew-tap) with [Homebrew](https://brew.sh) by running:
136
-
137
- ```bash
138
- brew tap snyk/tap
139
- brew install snyk
140
- ```
141
-
142
- </details>
143
-
144
- <details>
145
- <summary>Scoop (Windows)</summary>
146
-
147
- ### Scoop
40
+ **Note:** Before using the Snyk CLI to test your Open Source Project for vulnerabilities, with limited exceptions, you must **build your Project**. For details, see [Which Projects must be built before testing with CLI?](https://support.snyk.io/hc/en-us/articles/360015552617-Which-projects-must-be-built-before-testing-with-CLI-)
148
41
 
149
- Install Snyk CLI from our [Snyk bucket](https://github.com/snyk/scoop-snyk) with [Scoop](https://scoop.sh) on Windows:
42
+ In addition, depending on the language of your open-source Project, you may need to **set up your language environment** before using the Snyk CLI. For details, refer to [Supported languages, frameworks, and feature availability overview.](https://docs.snyk.io/scan-using-snyk/supported-languages-and-frameworks/supported-languages-frameworks-and-feature-availability-overview)
150
43
 
151
- ```
152
- scoop bucket add snyk https://github.com/snyk/scoop-snyk
153
- scoop install snyk
154
- ```
155
-
156
- </details>
157
-
158
- <details>
159
- <summary>Snyk CLI in a Docker image</summary>
160
-
161
- ### Snyk CLI in a Docker image
162
-
163
- Snyk CLI can also be run from a Docker image. Snyk offers multiple Docker tags under [`snyk/snyk`](https://hub.docker.com/r/snyk/snyk). These images wrap the Snyk CLI and depending on the Tag come with a relevant tooling for different projects. [See the snyk/images on GitHub for more details and examples](https://github.com/snyk/snyk-images).
164
-
165
- </details>
166
-
167
- ## Install as a part of a Snyk CLI integration
168
-
169
- Snyk also offers many integrations into developer tooling. These integrations will install and manage the Snyk CLI for you. For example:
170
-
171
- - [Snyk Jenkins plugin](https://github.com/jenkinsci/snyk-security-scanner-plugin)
172
- - [CircleCI Orb](https://github.com/snyk/snyk-orb)
173
- - [Azure Pipelines Task](https://github.com/snyk/snyk-azure-pipelines-task)
174
- - [GitHub Actions](https://github.com/snyk/actions)
175
- - [IntelliJ IDE Plugin](https://github.com/snyk/snyk-intellij-plugin)
176
- - [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=snyk-security.snyk-vulnerability-scanner)
177
- - [Eclipse IDE Extension](https://github.com/snyk/snyk-eclipse-plugin)
178
- - [Maven plugin](https://github.com/snyk/snyk-maven-plugin)
179
- - And many more. See [the Integrations documentation](https://support.snyk.io/hc/en-us/categories/360000598398-Integrations)
180
-
181
- <p align="center">
182
- <a href="https://support.snyk.io/hc/en-us/categories/360000598398-Integrations">
183
- <img src="help/ide.svg" alt="Snyk CLI IDE integration" width="50%" />
184
- </a>
185
- </p>
186
-
187
- ---
188
-
189
- # Getting started with Snyk CLI
190
-
191
- Once you installed the Snyk CLI, you can verify it's working by running:
192
-
193
- ```bash
194
- snyk --help
195
- ```
196
-
197
- See the [full Snyk CLI help](./help/cli-commands).
198
-
199
- ## Authenticating Snyk CLI
200
-
201
- Snyk CLI depends on [Snyk.io](https://snyk.io) APIs. Connect your Snyk CLI with [Snyk.io](https://snyk.io) by running:
202
-
203
- ```bash
204
- snyk auth
205
- ```
44
+ After you have installed the CLI and authenticated your machine, to **scan an open-source Project**, use `cd /my/project/` to change the current directory to`a`folder containing a supported package manifest file, such as `package.json`, `pom.xml`, or `composer.lock`. Then run `snyk test`. All vulnerabilities identified are listed, including their path and fix guidance.
206
45
 
207
- ## Setting up language support
46
+ To scan your **source code** run `snyk code test`.
208
47
 
209
- Depending on your project's language, you might need to setup your language environment before using Snyk.
48
+ You can **scan a Docker image** by its tag running, for example: `snyk container test ubuntu:18.04`.
210
49
 
211
- See our [Language Support documentation](https://support.snyk.io/hc/en-us/articles/360020352437-Language-support-summary).
50
+ To scan a **Kubernetes (K8s) file** run the following:\
51
+ `snyk iac test /path/to/kubernetes_file.yaml`
212
52
 
213
- ## Scanning your project
53
+ For details about using the Snyk CLI to scan each content type, see the following:
214
54
 
215
- If you are already in a folder with a supported project, start by running:
55
+ - [Snyk CLI for Snyk Open Source](https://docs.snyk.io/snyk-cli/scan-and-maintain-projects-using-the-cli/snyk-cli-for-open-source) and the CLI help for the [`test`](https://docs.snyk.io/snyk-cli/commands/test) and [`monitor`](https://docs.snyk.io/snyk-cli/commands/monitor) commands
56
+ - [Snyk CLI for Snyk Code](https://docs.snyk.io/snyk-cli/commands/code) and the [Snyk Code CLI help](https://docs.snyk.io/snyk-cli/scan-and-maintain-projects-using-the-cli/snyk-cli-for-snyk-code)
57
+ - [Snyk CLI for Snyk Container](https://docs.snyk.io/snyk-cli/commands/container), including Docker scanning, and the [Snyk Container CLI help](https://docs.snyk.io/snyk-cli/scan-and-maintain-projects-using-the-cli/snyk-cli-for-snyk-container)
58
+ - [Snyk CLI for Snyk IaC](https://docs.snyk.io/snyk-cli/scan-and-maintain-projects-using-the-cli/snyk-cli-for-iac), including Terraform and Kubernetes (K8s) Projects, and the [Snyk IAC CLI help](https://docs.snyk.io/snyk-cli/commands/iac)
216
59
 
217
- ```bash
218
- snyk test
219
- ```
220
-
221
- Or scan a Docker image by its tag with [Snyk Container](https://snyk.io/product/container-vulnerability-management/):
60
+ ## Monitor your Open Source or Container Project
222
61
 
223
- ```bash
224
- snyk container test ubuntu:18.04
225
- ```
62
+ Snyk can monitor your Open Source or Container integrated SCM Project periodically and alert you to new vulnerabilities. To set up your Project to be monitored, run `snyk monitor` or `snyk container monitor`.
226
63
 
227
- Or a k8s file:
228
-
229
- ```bash
230
- snyk iac test /path/to/kubernetes_file.yaml
231
- ```
232
-
233
- ## Monitoring your project
234
-
235
- Snyk can also monitor your project periodically and alert you for new vulnerabilities. The `snyk monitor` is similar to `snyk test` and can be used to create a project on the Snyk website that will be continuously monitored for new vulnerabilities.
236
-
237
- <p align="center">
238
- <a href="https://snyk.io">
239
- <img src="help/monitor.svg" alt="Snyk CLI monitor projects" width="70%" />
240
- </a>
241
- </p>
64
+ This creates a snapshot of your current dependencies so Snyk can regularly scan your code. Snyk can then alert you about newly disclosed vulnerabilities as they are introduced or when a previously unavailable patch or upgrade path is created. The following code shows an example of the output of the `snyk monitor` command.
242
65
 
243
66
  ```
244
67
  > snyk monitor
245
68
  Monitoring /project (project-name)...
246
69
 
247
- Explore this snapshot at https://app.snyk.io/org/my-org/project/29361c2c-9005-4692-8df4-88f1c040fa7c/history/e1c994b3-de5d-482b-9281-eab4236c851e
70
+ Explore this snapshot at
71
+ https://app.snyk.io/org/my-org/project/29361c2c-9005-4692
72
+ -8df4-88f1c040fa7c/history/e1c994b3-de5d-482b-9281-eab4236c851e
248
73
 
249
- Notifications about newly disclosed issues related to these dependencies will be emailed to you.
74
+ Notifications about newly disclosed issues related to these
75
+ dependencies will be emailed to you.
250
76
  ```
251
77
 
252
- ### Add Snyk to your CI/CD
253
-
254
- Snyk is really powerful when you are continuously scanning and monitoring your projects for vulnerabilities.
78
+ You can log in to your Snyk account and navigate to the [Projects page](https://app.snyk.io/projects) to find the latest snapshot and scan results:
255
79
 
256
- Use one of [our integrations](#install-as-a-part-of-a-snyk-cli-integration) to stay secure.
80
+ <figure><img src="https://github.com/snyk/user-docs/raw/HEAD/docs/.gitbook/assets/monitor (1).png" alt="Snyk monitor snapshot and scan results"><figcaption><p>Snyk monitor snapshot and scan results</p></figcaption></figure>
257
81
 
258
- You can authorize Snyk CLI in your CI/CD programatically:
82
+ For more information, see [Monitor your Projects at regular intervals](https://docs.snyk.io/snyk-cli/scan-and-maintain-projects-using-the-cli/monitor-your-projects-at-regular-intervals).
259
83
 
260
- ```bash
261
- # Using a SNYK_TOKEN envvar (preferred)
262
- SNYK_TOKEN=<SNYK_API_TOKEN> snyk test
263
-
264
- # Or using a Snyk auth command
265
- snyk auth <SNYK_API_TOKEN>
266
- snyk test
267
- ```
84
+ ## Running out of tests
268
85
 
269
- ## More flags and options to try
270
-
271
- Here are some flags that you might find useful:
272
-
273
- - `--severity-threshold=low|medium|high|critical`
274
-
275
- Only report vulnerabilities of provided level or higher.
276
-
277
- - `--json`
278
-
279
- Prints results in JSON format.
280
-
281
- - `--all-projects`
282
-
283
- Auto-detect all projects in working directory
284
-
285
- [See all the available commands and options](./help/cli-commands) by running `--help`:
286
-
287
- ```bash
288
- snyk --help
289
- # or get help for a specific command like
290
- snyk iac --help
291
- snyk code --help
292
- ```
86
+ Snyk allows unlimited tests for public repositories. If you are on the Free plan, you have a limited number of tests per month. Paid plans have unlimited tests on private and public repositories. If you are on the Free plan and notice that your test count is quickly being used, even with public repositories, you can remedy this by telling Snyk the public url of the repository that is being scanned by the Snyk CLI. This ensures that Snyk does not count a public repository towards the test limits.
293
87
 
294
- # Getting support
88
+ If you run out of tests on an open-source Project, follow these steps:
295
89
 
296
- If you need support using Snyk CLI, please [contact support](https://support.snyk.io).
90
+ - Run `snyk monitor`.
91
+ - Open the Snyk UI and navigate to the **settings** of the Project.
92
+ - Enter the URL of your open-source repository in **Git remote URL**.
297
93
 
298
- # Contributing
94
+ ## Additional information about the Snyk CLI
299
95
 
300
- If you are an external contributor, before working on any contributions, please first [contact support](https://support.snyk.io) to discuss the issue or feature request with us.
96
+ Run `snyk help` or see the [CLI commands and options summary](https://docs.snyk.io/snyk-cli/cli-commands-and-options-summary).
301
97
 
302
- If you are contributing to Snyk CLI, see [our contributing guidelines](CONTRIBUTING.md)
98
+ See the course [Introduction to the Snyk CLI](https://learn.snyk.io/lesson/snyk-cli/https://learn.snyk.io/lesson/snyk-cli/) for a quick video training session.
303
99
 
304
- For information on how Snyk CLI is implemented, see [our design decisions](help/_about-this-project/README.md).
100
+ Snyk also provides a [cheat sheet](https://res.cloudinary.com/snyk/image/upload/v1664236143/cheat-sheets/cheat-sheet-snyk-cli-v3.pdf) ([blog post](https://snyk.io/blog/snyk-cli-cheat-sheet/)) and a [video tutorial](https://www.youtube.com/watch?v=xp_LtchEkT8).
305
101
 
306
- This repository is a monorepo, also covering other projects and tools:
102
+ In particular, see the information about the following options that you may find useful:
307
103
 
308
- - [`@snyk/fix`](packages/snyk-fix): npm package for `snyk fix` libraries.
309
- - [`@snyk/protect`](packages/snyk-protect): npm package for [`snyk-protect`](https://www.npmjs.com/package/@snyk/protect) command.
104
+ - `--severity-threshold=low|medium|high|critical`: Report only vulnerabilities of the specified level or higher.
105
+ - `--json`: Print results in JSON format.
106
+ - `--all-projects`: Auto-detect all Projects in the working directory.
310
107
 
311
- # Security
108
+ For detailed information about the CLI, see the [CLI docs](https://docs.snyk.io/snyk-cli).
312
109
 
313
- For any security issues or concerns, please see [SECURITY.md](SECURITY.md) file in this repository.
110
+ ## Getting support for the Snyk CLI
314
111
 
315
- # Notices
112
+ [Submit a ticket](https://support.snyk.io/hc/en-us/requests/new) to Snyk support whenever you need help with the Snyk CLI or Snyk in general. Note that Snyk support does not actively monitor GitHub Issues on any [Snyk development project](https://github.com/snyk).
316
113
 
317
- ## Snyk API usage policy
114
+ ## Contributing to the Snyk CLI
318
115
 
319
- The use of Snyk's API, whether through the use of the 'snyk' npm package or otherwise, is subject to the [Terms & Conditions](https://snyk.co/ucT6N).
116
+ The Snyk CLI project is open-source, but Snyk does not encourage outside contributors.
320
117
 
321
- ---
118
+ ## Security
322
119
 
323
- Made with ๐Ÿ’œ by Snyk
120
+ For any security issues or concerns, see the [SECURITY.md](https://github.com/snyk/snyk/blob/master/SECURITY.md) file in the GitHub repository.
package/dist/cli/index.js CHANGED
@@ -40392,7 +40392,7 @@ function validateUnsupportedSarifCombinations(args) {
40392
40392
  async function saveResultsToFile(options, outputType, jsonResults, jsonPayload) {
40393
40393
  const flag = `${outputType}-file-output`;
40394
40394
  const outputFile = options[flag];
40395
- if (outputFile && (jsonResults || jsonPayload)) {
40395
+ if (outputFile && (jsonResults || !isEmpty(jsonPayload))) {
40396
40396
  const outputFileStr = outputFile;
40397
40397
  const fullOutputFilePath = getFullPath(outputFileStr);
40398
40398
  await saveJsonResultsToFile(stripAnsi(jsonResults), fullOutputFilePath, jsonPayload);