查看许可和依赖项

本文档介绍了如何查看和过滤 Artifact Analysis 通过自动扫描检测到的依赖项元数据。

当您启用扫描 API 以识别容器映像中的漏洞时,Artifact Analysis 还会收集有关映像中使用的依赖项和许可的信息。

您可以使用此元数据来了解容器映像的组件并修复安全问题。

对于以 Docker 格式存储在 Artifact Registry 制品库中的容器映像,Artifact Analysis 可提供操作系统软件包和受支持的语言软件包的依赖项和许可检测功能。如需了解详情,请参阅容器扫描概览。

与漏洞信息一样,每次将映像推送到 Artifact Registry 时,系统都会生成许可和依赖项元数据,然后将其存储在 Artifact Analysis 中。

只要映像和软件包在过去 30 天内被拉取过,Artifact Analysis 就会继续对其进行扫描。30 天后,扫描过的映像和软件包的元数据将不再更新,并且结果将过时。

Artifact Analysis 会归档过时超过 90 天的元数据。只有使用 API 才能评估此归档的元数据。 您可以拉取包含过时或归档元数据的映像,以重新扫描该映像。 刷新元数据最多可能需要 24 小时。无法重新扫描包含过时或已归档元数据的软件包。

准备工作

  1. 登录您的 Google 账号。

    如果您还没有 Google 账号,请注册新账号。

  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 role (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, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  5. Install the Google Cloud CLI.

  6. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  7. To initialize the gcloud CLI, run the following command:

    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 role (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, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  11. Install the Google Cloud CLI.

  12. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  13. To initialize the gcloud CLI, run the following command:

    gcloud init
  14. 在 Artifact Registry 中有一个 Docker 代码库。请参阅有关生成 SBOM 的说明。

所需的角色

如需获得查看 SBOM 数据和过滤结果所需的权限,请让管理员向您授予项目的以下 IAM 角色:

如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。

您也可以通过自定义角色或其他预定义角色来获取所需的权限。

在 Google Cloud 控制台中查看许可和依赖项

  1. 打开 Artifact Registry 代码库页面。

    打开“代码库”页面

    此页面会显示您的代码库列表。

  2. 在代码库列表中,点击一个代码库名称。

    代码库详情页面会打开,并显示您的映像列表。

  3. 在映像列表中,点击一个映像名称。

    此页面会显示您的映像摘要列表。

  4. 在映像摘要列表中,点击摘要名称。

    该页面会显示一行标签页,其中概览标签页处于打开状态,显示格式、位置、代码库、虚拟大小和标记等详细信息。

  5. 在标签页行中,点击依赖项标签页。

    系统会打开“依赖项”标签页,并显示以下信息:

    • SBOM 部分
    • “许可”部分
    • 可过滤的依赖项列表

SBOM

如果您使用 Artifact Analysis 生成或上传软件物料清单 (SBOM),系统会在此部分中显示您的 SBOM 详细信息。SBOM 不会像许可和依赖项信息那样自动生成。如需了解如何添加 SBOM,请参阅 SBOM 概览。

许可

许可摘要部分会显示一个名为最常见的许可的条形图。这表示在依赖项信息中出现频率最高的许可类型。将指针悬停在图表中的某个柱形上时,控制台会显示相应许可类型的确切数量。

依赖项

依赖项列表会显示映像摘要的内容,包括:

  • 软件包名称
  • 软件包版本
  • 软件包类型
  • 许可类型

您可以按任意这些类别过滤依赖项列表。

在 Cloud Build 中查看许可和依赖项

如果您使用的是 Cloud Build,则可以在 Google Cloud 控制台的安全数据分析侧边栏中查看映像元数据。

安全性数据分析侧边栏简要概述了存储在 Artifact Registry 中的制品的构建安全信息。如需详细了解侧边栏以及如何使用 Cloud Build 帮助保护软件供应链,请参阅查看构建安全数据分析。

限制

只有自动扫描功能才能提供有关许可和依赖项的信息。按需扫描不支持此功能。

后续步骤