ソフトウェア部品表 (SBOM) 用の REST API エンドポイント
REST API を使って、リポジトリのソフトウェア部品表 (SBOM) をエクスポートします。
少なくともリポジトリへの読み取りアクセス権がある場合は、GitHub UI または GitHub REST API を使って、リポジトリの依存関係グラフを SPDX 互換のソフトウェア部品表 (SBOM) としてエクスポートできます。 詳しくは、「リポジトリのソフトウェア部品表のエクスポート」をご覧ください。
この記事では、REST API エンドポイントの詳細について説明します。
Export a software bill of materials (SBOM) for a repository.
Exports the software bill of materials (SBOM) for a repository in SPDX JSON format.
"Export a software bill of materials (SBOM) for a repository." のきめ細かいアクセス トークン
このエンドポイントは、次の粒度の細かいトークンの種類で動作します:
粒度の細かいトークンには次のアクセス許可セットが設定されている必要があります:
- "Contents" repository permissions (read)
このエンドポイントは、パブリック リソースのみが要求される場合は、認証または前述メンションアクセス許可なしで使用できます。
"Export a software bill of materials (SBOM) for a repository." のパラメーター
| 名前, Type, 説明 | 
|---|
| acceptstringSetting to  | 
| 名前, Type, 説明 | 
|---|
| ownerstring 必須The account owner of the repository. The name is not case sensitive. | 
| repostring 必須The name of the repository without the  | 
"Export a software bill of materials (SBOM) for a repository." の HTTP 応答状態コード
| 状態コード | 説明 | 
|---|---|
| 200 | OK | 
| 403 | Forbidden | 
| 404 | Resource not found | 
"Export a software bill of materials (SBOM) for a repository." のコード サンプル
GHE.com で GitHub にアクセスする場合は、api.github.com を api.SUBDOMAIN.ghe.com にあるエンタープライズの専用サブドメインに置き換えます。
要求の例
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/repos/OWNER/REPO/dependency-graph/sbomResponse
Status: 200{
  "sbom": {
    "SPDXID": "SPDXRef-DOCUMENT",
    "spdxVersion": "SPDX-2.3",
    "creationInfo": {
      "created": "2021-09-01T00:00:00Z",
      "creators": [
        "Tool: GitHub.com-Dependency-Graph"
      ]
    },
    "name": "github/example",
    "dataLicense": "CC0-1.0",
    "documentNamespace": "https://spdx.org/spdxdocs/protobom/15e41dd2-f961-4f4d-b8dc-f8f57ad70d57",
    "packages": [
      {
        "name": "rails",
        "SPDXID": "SPDXRef-Package",
        "versionInfo": "1.0.0",
        "downloadLocation": "NOASSERTION",
        "filesAnalyzed": false,
        "licenseConcluded": "MIT",
        "licenseDeclared": "MIT",
        "copyrightText": "Copyright (c) 1985 GitHub.com",
        "externalRefs": [
          {
            "referenceCategory": "PACKAGE-MANAGER",
            "referenceType": "purl",
            "referenceLocator": "pkg:gem/rails@1.0.0"
          }
        ]
      },
      {
        "name": "github/example",
        "SPDXID": "SPDXRef-Repository",
        "versionInfo": "main",
        "downloadLocation": "NOASSERTION",
        "filesAnalyzed": false,
        "externalRefs": [
          {
            "referenceCategory": "PACKAGE-MANAGER",
            "referenceType": "purl",
            "referenceLocator": "pkg:github/example@main"
          }
        ]
      }
    ],
    "relationships": [
      {
        "relationshipType": "DEPENDS_ON",
        "spdxElementId": "SPDXRef-Repository",
        "relatedSpdxElement": "SPDXRef-Package"
      },
      {
        "relationshipType": "DESCRIBES",
        "spdxElementId": "SPDXRef-DOCUMENT",
        "relatedSpdxElement": "SPDXRef-Repository"
      }
    ]
  }
}