Code Scanning
この REST API を使い、リポジトリから code scanning アラートを取得して更新します。
コード スキャンについて
リポジトリから code scanning アラートを取得して更新できます。 このエンドポイントを使って、Organization内でcode scanningアラートの自動化されたレポートを作成したり、オフラインのcode scanningツールを使って生成された分析結果をアップロードしたりできます。 詳しくは、「コード スキャンを使用したコード内のセキュリティ脆弱性とエラーの発見」を参照してください。
code scanningのためのカスタムメディアタイプ
code scanning エンドポイント用にサポートされているカスタム メディア タイプが 1 つあります。
application/sarif+json
これは、/analyses/{analysis_id} エンドポイントに送信される GET リクエストで使用できます。 この操作の詳細については、「リポジトリの code scanning 分析を取得する」を参照してください。 この操作でこのメディアの種類を使用する場合、応答には、既定のメディアの種類を使用したときに返される分析の概要ではなく、指定された分析に対してアップロードされた実際のデータのサブセットが含まれます。 この応答には、github/alertNumber や github/alertUrl のプロパティなどの追加データも含まれます。 データは、SARIF バージョン 2.1.0 として書式設定されます。
詳しくは、「メディアの種類」を参照してください。
List code scanning alerts for an organization
Lists code scanning alerts for the default branch for all eligible repositories in an organization. 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 an owner or security manager for the organization, and you must use an access token with the repo scope or security_events scope.
For public repositories, you may instead use the public_repo scope.
GitHub Apps must have the security_events read permission to use this endpoint.
"List code scanning alerts for an organization" のパラメーター
| ヘッダー |
|---|
| 名前, Type, 説明 |
accept string Setting to |
| パス パラメーター |
| 名前, Type, 説明 |
org string 必須The organization name. The name is not case sensitive. |
| クエリ パラメーター |
| 名前, Type, 説明 |
tool_name string The name of a code scanning tool. Only results by this tool will be listed. You can specify the tool by using either |
tool_guid string or null The 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 |
before string A cursor, as given in the Link header. If specified, the query only searches for results before this cursor. |
after string A cursor, as given in the Link header. If specified, the query only searches for results after this cursor. |
page integer Page number of the results to fetch. Default: |
per_page integer The number of results per page (max 100). Default: |
direction string The direction to sort the results by. Default: 次のいずれかにできます: |
state string If specified, only code scanning alerts with this state will be returned. 次のいずれかにできます: |
sort string The property by which to sort the results. Default: 次のいずれかにできます: |
severity string If specified, only code scanning alerts with this severity will be returned. 次のいずれかにできます: |
"List code scanning alerts for an organization" の HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
200 | OK |
404 | Resource not found |
503 | Service unavailable |
"List code scanning alerts for an organization" のコード サンプル
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/code-scanning/alertsResponse
Status: 200[
{
"number": 4,
"created_at": "2020-02-13T12:29:18Z",
"url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/4",
"html_url": "https://github.com/octocat/hello-world/code-scanning/4",
"state": "open",
"dismissed_by": null,
"dismissed_at": null,
"dismissed_reason": null,
"dismissed_comment": null,
"rule": {
"id": "js/zipslip",
"severity": "error",
"tags": [
"security",
"external/cwe/cwe-022"
],
"description": "Arbitrary file write during zip extraction",
"name": "js/zipslip"
},
"tool": {
"name": "CodeQL",
"guid": null,
"version": "2.4.0"
},
"most_recent_instance": {
"ref": "refs/heads/main",
"analysis_key": ".github/wo