Dependabot 警报 REST API 现已包含依赖项版本信息
英文标题:Dependabot alerts REST API now includes dependency versions
GitHub 宣布在 Dependabot 警报的 REST API 响应中直接加入有漏洞依赖项的具体版本信息,每个警报的 dependency 对象中均新增了 version_requirement 字段。此前 API 仅返回安全通告的漏洞版本范围,用户若要获取仓库内的实际版本往往需要解析 lockfile 或额外发起 GraphQL 请求。这项改进支持通过锁定文件、清单文件及依赖提交 API 获取对应版本,已在 GitHub.com 和 GitHub Enterprise Cloud 上线,显著简化了开发者将警报同步至第三方安全工具的工作流。
209.1 KB
中文
现在,你可以直接从 REST API 中的 Dependabot 警报响应里获取存在漏洞的依赖项版本。每个警报的 dependency 对象都包含一个新的 version_requirement 字段,记录了 Dependabot 最近为该警报捕获的版本或版本约束。
警报响应此前已经包含了安全通告(advisory)中存在漏洞的版本范围,但并不包含你仓库中实际使用的版本。如果你需要将警报同步到其他安全工具,现在无需再解析 lockfile(锁定文件),也不需要为了获取该版本而单独发起查询 vulnerableRequirements 的 GraphQL 请求。
该字段的具体值取决于 Dependabot 是如何检测到该依赖项的:
- Lockfile(锁定文件): 解析出的具体版本。
- 没有 Lockfile 的清单文件(Manifest): 清单文件中声明的版本或版本约束。
- 依赖项提交 API(Dependency submission API): 由你的构建工具提交的已解析版本。
当没有可用值时,该字段为 null。如果一个警报涵盖了某个依赖项的多个受影响版本,该字段将保存一个已记录的值,可能无法代表所有受影响版本。此外,过长的版本约束也可能会被截断。
你可以在单条警报响应、代码仓库/组织/企业级的警报列表,以及 dependabot_alert Webhook 的有效载荷(payload)中找到 version_requirement 字段。
该字段目前已在 github.com 和支持数据驻留的 GitHub Enterprise Cloud 上提供,并将在 GitHub Enterprise Server 3.24 中推出。
了解更多详情,请参阅 Dependabot 警报 REST API 端点文档 以及 dependabot_alert Webhook 事件说明。
English / 原文
You can now get the version of a vulnerable dependency directly from Dependabot alert responses in the REST API. Each alert’s dependency object includes a new version_requirement field with the version or version constraint that Dependabot last recorded for the alert.
Alert responses already included the advisory’s vulnerable version range, but not the version in your repository. If you sync alerts to other security tools, you no longer need to parse lockfiles or make a separate GraphQL request for vulnerableRequirements to get that version.
The value depends on how Dependabot detected the dependency:
- Lockfiles: The resolved version.
- Manifests without a lockfile: The version or version constraint declared in the manifest.
- Dependency submission API: The resolved version submitted by your build tooling.
The field is null when no value is available. If an alert covers more than one vulnerable version of a dependency, the field holds one recorded value and may not represent all of them. Long version constraints may also be truncated.
You’ll find version_requirement in responses for individual alerts, in repository, organization, and enterprise alert lists, and in dependabot_alert webhook payloads.
This field is available now on github.com and GitHub Enterprise Cloud with data residency, and will be included in GitHub Enterprise Server 3.24.
Learn more about the REST API endpoints for Dependabot alerts and the dependabot_alert webhook event.