代码扫描
code scanning API 可让您从仓库检索和更新 code scanning 警报。
关于代码扫描 API
code scanning API 可让您从仓库检索和更新 code scanning 警报。 您可以使用端点为组织中的 code scanning 警报创建自动报告,或上传使用离线 code scanning 工具生成的分析结果。 有关详细信息,请参阅“查找代码中的安全漏洞和错误”。
code scanning 的自定义媒体类型
code scanning REST API 有一种支持的自定义媒体类型。
application/sarif+json
可以将此媒体类型用于发送到 /analyses/{analysis_id} 终结点的 GET 请求。 有关此操作的详细信息,请参阅“获取存储库的 code scanning 分析”。 将此媒体类型用于此操作时,响应包括为指定分析上传的实际数据的子集,而不是使用默认媒体类型时返回的分析摘要。 响应还包括其他数据,如 github/alertNumber 和 github/alertUrl 属性。 数据的格式为 SARIF 版本 2.1.0。
有关详细信息,请参阅“媒体类型”。
List code scanning alerts for an enterprise
Lists code scanning alerts for the default branch for all eligible repositories in an enterprise. Eligible repositories are repositories that are owned by organizations that you own or for which you are a security manager. For more information, see "Managing security managers in your organization."
To use this endpoint, you must be a member of the enterprise,
and you must use an access token with the repo scope or security_events scope.
参数
| Headers |
|---|
| Name, Type, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
enterprisestringRequiredThe slug version of the enterprise name. You can also substitute this value with the enterprise id. |
| Query parameters |
| Name, Type, Description |
tool_namestringThe name of a code scanning tool. Only results by this tool will be listed. You can specify the tool by using either |
tool_guidstringnullThe GUID of a code scanning tool. Only results by this tool will be listed. Note that some code scanning tools may not include a GUID in their analysis data. You can specify the tool by using either |
beforestringA cursor, as given in the Link header. If specified, the query only searches for results before this cursor. |
afterstringA cursor, as given in the Link header. If specified, the query only searches for results after this cursor. |
pageintegerPage number of the results to fetch. Default: |
per_pageintegerThe number of results per page (max 100). Default: |
directionstringThe direction to sort the results by. Default: Can be one of: |
statestringIf specified, only code scanning alerts with this state will be returned. Can be one of: |
sortstringThe property by which to sort the results. Default: Can be one of: |
HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
200 | OK |
404 | Resource not found |
503 | Service unavailable |
代码示例
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/enterprises/ENTERPRISE/code-scanning/alertsResponse
Status: 200[
{
"number": 4,
"