查看许可和依赖项

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

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

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

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

与漏洞信息类似,每次将映像推送到 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 的代码库页面。

      打开“代码库”页面

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

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

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

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

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

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

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

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

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

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

    SBOM

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

    许可

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

    依赖项

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

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

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

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

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

    安全性数据洞见侧边栏可提供存储在 Artifact Registry 中的工件的 build 安全信息的高级概览。如需详细了解侧边栏以及如何使用 Cloud Build 帮助保护软件供应链,请参阅查看 build 安全数据分析

    限制

    只有在进行自动扫描时,才能获取有关许可和依赖项的信息。按需扫描不支持此功能。

    后续步骤