查看授權和依附元件

本文說明如何查看及篩選構件分析透過自動掃描偵測到的依附元件中繼資料。

啟用掃描 API 找出容器映像檔中的安全漏洞時,Artifact Analysis 也會收集映像檔中使用的依附元件和授權資訊。

您可以利用這項中繼資料瞭解容器映像檔的元件,並修正安全性問題。

Artifact Analysis 可偵測以 Docker 格式儲存在 Artifact Registry 存放區的容器映像檔中,OS 套件和支援語言套件的依附元件和授權。詳情請參閱容器掃描總覽

與安全漏洞資訊一樣,每次將映像檔推送至 Artifact Registry 時,系統都會產生授權和依附元件中繼資料,然後儲存在 Artifact Analysis 中。

Artifact Analysis 只會更新過去 30 天內推送或提取的映像檔中繼資料。30 天後,中繼資料將不再更新,結果也會過時。此外,Artifact Analysis 會封存過時逾 90 天的中繼資料,且這些中繼資料不會顯示在 Google Cloud 控制台、gcloud 或 API 中。如要重新掃描中繼資料已過時或已封存的映像檔,請提取該映像檔。 重新整理中繼資料最多可能需要 24 小時才能完成。

事前準備

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Container Analysis, Artifact Registry APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  5. Install the Google Cloud CLI.

  6. 如果您使用外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI

  7. 如要初始化 gcloud CLI,請執行下列指令:

    gcloud init
  8. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  9. Verify that billing is enabled for your Google Cloud project.

  10. Enable the Container Analysis, Artifact Registry APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  11. Install the Google Cloud CLI.

  12. 如果您使用外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI

  13. 如要初始化 gcloud CLI,請執行下列指令:

    gcloud init
  14. 在 Artifact Registry 中建立 Docker 存放區。請參閱產生 SBOM 的操作說明。
  15. 必要的角色

    如要取得查看 SBOM 資料和篩選結果所需的權限,請要求管理員為您授予專案的下列 IAM 角色:

    如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。

    您或許還可透過自訂角色或其他預先定義的角色取得必要權限。

    在 Google Cloud 控制台中查看授權和依附元件

    1. 開啟 Artifact Registry 的「Repositories」(存放區) 頁面。

      開啟「Repositories」(存放區) 頁面

      這個頁面會顯示存放區清單。

    2. 在存放區清單中,按一下存放區名稱。

      「Repository details」(存放區詳細資料) 頁面隨即開啟,並顯示映像檔清單。

    3. 在圖片清單中,按一下圖片名稱。

      這個頁面會顯示圖片摘要清單。

    4. 在映像檔摘要清單中,按一下摘要名稱。

      頁面會顯示一列分頁,其中「總覽」分頁已開啟,並顯示格式、位置、存放區、虛擬大小和標記等詳細資料。

    5. 在分頁列中,按一下「Dependencies」分頁。

      「依附元件」分頁隨即開啟,並顯示下列資訊:

      • SBOM 專區
      • 「授權」專區
      • 可篩選的依附元件清單

    SBOM

    如果您使用 Artifact Analysis 產生或上傳軟體物料清單 (SBOM),系統會在這個部分顯示 SBOM 詳細資料。SBOM 不會像授權和依附元件資訊一樣自動產生。如要瞭解如何新增 SBOM,請參閱 SBOM 總覽

    授權

    「授權」摘要部分會顯示名為「最常見的授權」的長條圖。這代表依附元件資訊中最常出現的授權類型。將指標懸停在圖表中的長條上,控制台就會顯示該授權類型執行個體的確切數量。

    依附元件

    依附元件清單會顯示映像檔摘要的內容,包括:

    • 套件名稱
    • 套件版本
    • 套件類型
    • 授權類型

    您可以依據上述任一類別篩選依附元件清單。

    在 Cloud Build 中查看授權和依附元件

    如果您使用 Cloud Build,可以在 Google Cloud 控制台的「安全性洞察」側邊面板中查看映像檔中繼資料。

    「安全性深入分析」側邊面板會顯示儲存在 Artifact Registry 中的構件,以及建構安全資訊的整體概況。如要進一步瞭解側邊面板,以及如何使用 Cloud Build 協助保護軟體供應鏈,請參閱「查看建構作業安全洞察資訊」。

    限制

    只有自動掃描功能會提供授權和依附元件的相關資訊。隨選掃描不支援這項功能。

    後續步驟