將 Scout 與不同型別的工件一起使用
某些 Docker Scout CLI 命令支援字首,用於指定您要分析的工件的位置或型別。
預設情況下,使用 docker scout cves
命令進行映象分析會針對 Docker Engine 本地映象儲存中的映象。以下命令始終使用本地映象(如果存在)
$ docker scout cves <image>
如果映象在本地不存在,Docker 會在執行分析之前拉取映象。再次分析同一個映象預設會使用相同的本地版本,即使該標籤在登錄檔中已更改。
透過在映象引用中新增 registry://
字首,您可以強制 Docker Scout 分析映象的登錄檔版本
$ docker scout cves registry://<image>
支援的字首
支援的字首是
字首 | 描述 |
---|---|
image:// (預設) | 使用本地映象,或回退到登錄檔查詢 |
local:// | 使用本地映象儲存中的映象(不進行登錄檔查詢) |
registry:// | 使用登錄檔中的映象(不使用本地映象) |
oci-dir:// | 使用 OCI 佈局目錄 |
archive:// | 使用 tarball 歸檔檔案,如 docker save 建立的 |
fs:// | 使用本地目錄或檔案 |
您可以將字首與以下命令一起使用
docker scout compare
docker scout cves
docker scout quickview
docker scout recommendations
docker scout sbom
示例
本節包含一些示例,展示瞭如何使用字首為 docker scout
命令指定工件。
分析本地專案
fs://
字首允許您直接分析本地原始碼,而無需將其構建到容器映象中。以下 docker scout quickview
命令為您提供了當前工作目錄中原始碼的快速漏洞摘要
$ docker scout quickview fs://.
要檢視本地原始碼中發現的漏洞詳細資訊,您可以使用 docker scout cves --details fs://.
命令。將其與其他標誌結合使用,以將結果縮小到您感興趣的軟體包和漏洞。
$ docker scout cves --details --only-severity high fs://.
✓ File system read
✓ Indexed 323 packages
✗ Detected 1 vulnerable package with 1 vulnerability
## Overview
│ Analyzed path
────────────────────┼──────────────────────────────
Path │ /Users/david/demo/scoutfs
vulnerabilities │ 0C 1H 0M 0L
## Packages and Vulnerabilities
0C 1H 0M 0L fastify 3.29.0
pkg:npm/fastify@3.29.0
✗ HIGH CVE-2022-39288 [OWASP Top Ten 2017 Category A9 - Using Components with Known Vulnerabilities]
https://scout.docker.com/v/CVE-2022-39288
fastify is a fast and low overhead web framework, for Node.js. Affected versions of
fastify are subject to a denial of service via malicious use of the Content-Type
header. An attacker can send an invalid Content-Type header that can cause the
application to crash. This issue has been addressed in commit fbb07e8d and will be
included in release version 4.8.1. Users are advised to upgrade. Users unable to
upgrade may manually filter out http content with malicious Content-Type headers.
Affected range : <4.8.1
Fixed version : 4.8.1
CVSS Score : 7.5
CVSS Vector : CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
1 vulnerability found in 1 package
LOW 0
MEDIUM 0
HIGH 1
CRITICAL 0
將本地專案與映象進行比較
使用 docker scout compare
,您可以將本地檔案系統上的原始碼分析與容器映象分析進行比較。以下示例將本地原始碼 (fs://.
) 與登錄檔映象 registry://docker/scout-cli:latest
進行比較。在這種情況下,比較的基線和目標都使用字首。
$ docker scout compare fs://. --to registry://docker/scout-cli:latest --ignore-unchanged
WARN 'docker scout compare' is experimental and its behaviour might change in the future
✓ File system read
✓ Indexed 268 packages
✓ SBOM of image already cached, 234 packages indexed
## Overview
│ Analyzed File System │ Comparison Image
─────────────────────────┼────────────────────────────────────────────────┼─────────────────────────────────────────────
Path / Image reference │ /Users/david/src/docker/scout-cli-plugin │ docker/scout-cli:latest
│ │ bb0b01303584
platform │ │ linux/arm64
provenance │ https://github.com/dvdksn/scout-cli-plugin.git │ https://github.com/docker/scout-cli-plugin
│ 6ea3f7369dbdfec101ac7c0fa9d78ef05ffa6315 │ 67cb4ef78bd69545af0e223ba5fb577b27094505
vulnerabilities │ 0C 0H 1M 1L │ 0C 0H 1M 1L
│ │
size │ 7.4 MB (-14 MB) │ 21 MB
packages │ 268 (+34) │ 234
│ │
## Packages and Vulnerabilities
+ 55 packages added
- 21 packages removed
213 packages unchanged
為簡潔起見,上一個示例已截斷。
檢視映象 tarball 的 SBOM
以下示例展示瞭如何使用 archive://
字首獲取使用 docker save
建立的映象 tarball 的 SBOM。在這種情況下,映象為 docker/scout-cli:latest
,並且 SBOM 以 SPDX 格式匯出到檔案 sbom.spdx.json
。
$ docker pull docker/scout-cli:latest
latest: Pulling from docker/scout-cli
257973a141f5: Download complete
1f2083724dd1: Download complete
5c8125a73507: Download complete
Digest: sha256:13318bb059b0f8b0b87b35ac7050782462b5d0ac3f96f9f23d165d8ed68d0894
$ docker save docker/scout-cli:latest -o scout-cli.tar
$ docker scout sbom --format spdx -o sbom.spdx.json archive://scout-cli.tar
瞭解更多
閱讀 CLI 參考文件中的命令和支援的標誌