Skip to main content
REST API はバージョン管理になりました。 詳細については、「API のバージョン管理について」を参照してください。

依存関係送信用の REST API エンドポイント

REST API を使って、依存関係を送信します。

依存関係の送信について

: 依存関係の送信に REST API を使う機能は、現在パブリック ベータ版であり、変更される可能性があります。

REST API を使って、プロジェクトの依存関係を送信できます。 これにより、ソフトウェアのコンパイル時やビルド時に解決されるものなどの依存関係を GitHub の依存関係グラフ機能に追加し、プロジェクトのすべての依存関係をより完全に把握できます。

依存関係グラフには、リポジトリ内のマニフェストまたはロック ファイル (JavaScript プロジェクトの package-lock.json ファイルなど) から識別された依存関係に加えて、この API を使って送信したすべての依存関係が表示されます。 依存関係グラフの表示の詳細については、「リポジトリの依存関係を調べる」を参照してください。

送信された依存関係は、既知の脆弱性に対する Dependabot alerts と Dependabot security updates を受け取ります。 GitHub Advisory Database のサポートされているエコシステムのいずれかからの依存関係に対する Dependabot alerts のみを受け取ります。 サポートされているこれらのエコシステムについて詳しくは、「GitHub Advisory Database について」をご覧ください。 依存関係送信 API を介して送信された推移的な依存関係の場合、更新プログラムが利用可能な場合は、Dependabot が自動的に pull request を開き、親依存関係を更新します。

送信された依存関係は依存関係レビューに表示されますが、組織の依存関係の分析情報には_表示されません_。

注: 依存関係レビュー API と 依存関係送信 API は連携して動作します。 これは、依存関係レビュー API には、依存関係送信 API を介して送信された依存関係が含まれます。 この機能は現在パブリック ベータ版であり、変更されることがあります。

依存関係は、スナップショットの形式で送信できます。 スナップショットは、コミット SHA や他のメタデータに関連付けられている依存関係のセットであり、コミットのリポジトリの現在の状態を反映しています。 事前に作成されたアクションを使うか、独自のアクションを作成して、プロジェクトがビルドされるたびに必要な形式で依存関係を送信するかを選べます。 詳しくは、「Dependency Submission API を使用する」を参照してください。

依存関係グラフに含める複数の依存関係セットを送信できます。 REST API では、スナップショットの job.correlator プロパティと detector.name カテゴリを使って、各ワークフローの最新の送信が確実に表示されるようにします。 correlator プロパティ自体は、独立した送信を区別するために使用する主要なフィールドです。 correlator の例としては、アクションの実行で使用できる <GITHUB_WORKFLOW> <GITHUB_JOB> という 2 つの変数のシンプルな組み合わせがあります。

Create a snapshot of dependencies for a repository

Create a new snapshot of a repository's dependencies.

The authenticated user must have access to the repository.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

"Create a snapshot of dependencies for a repository" のきめ細かいアクセス トークン

このエンドポイントは、次のトークンの種類で動作します:

トークンには次のアクセス許可が設定されている必要があります:

  • contents:write

"Create a snapshot of dependencies for a repository" のパラメーター

ヘッダー
名前, Type, 説明
accept string

Setting to application/vnd.github+json is recommended.

パス パラメーター
名前, Type, 説明
owner string 必須

The account owner of the repository. The name is not case sensitive.

repo string 必須

The name of the repository without the .git extension. The name is not case sensitive.

本文のパラメーター
名前, Type, 説明
version integer 必須

The version of the repository snapshot submission.

job object 必須
名前, Type, 説明
id string 必須

The external ID of the job.

correlator string 必須

Correlator provides a key that is used to group snapshots submitted over time. Only the "latest" submitted snapshot for a given combination of job.correlator and detector.name will be considered when calculating a repository's current dependencies. Correlator should be as unique as it takes to distinguish all detection runs for a given "wave" of CI workflow you run. If you're using GitHub Actions, a good default value for this could be the environment variables GITHUB_WORKFLOW and GITHUB_JOB concatenated together. If you're using a build matrix, then you'll also need to add additional key(s) to distinguish between each submission inside a matrix variation.

html_url string

The url for the job.

sha string 必須

The commit SHA associated with this dependency snapshot. Maximum length: 40 characters.

ref string 必須

The repository branch that triggered this snapshot.

detector object 必須

A description of the detector used.

名前, Type, 説明
name string 必須

The name of the detector used.

version string 必須

The version of the detector used.

url string 必須

The url of the detector used.

metadata object

User-defined metadata to store domain-specific information limited to 8 keys with scalar values.

manifests object

A collection of package manifests, which are a collection of related dependencies declared in a file or representing a logical group of dependencies.

名前, Type, 説明
key object

A user-defined key to represent an item in manifests.

名前, Type, 説明
name string 必須

The name of the manifest.

file object
名前, Type, 説明
source_location string

The path of the manifest file relative to the root of the Git repository.

metadata object

User-defined metadata to store domain-specific information limited to 8 keys with scalar values.

resolved object

A collection of resolved package dependencies.

名前, Type, 説明
key object

A user-defined key to represent an item in resolved.

名前, Type, 説明
package_url string

Package-url (PURL) of dependency. See https://github.com/package-url/purl-spec for more details.

metadata object

User-defined metadata to store domain-specific information limited to 8 keys with scalar values.

relationship string

A notation of whether a dependency is requested directly by this manifest or is a dependency of another dependency.

次のいずれかにできます: direct, indirect

scope string

A notation of whether the dependency is required for the primary build artifact (runtime) or is only used for development. Future versions of this specification may allow for more granular scopes.

次のいずれかにできます: runtime, development

dependencies array of strings

Array of package-url (PURLs) of direct child dependencies.

scanned string 必須

The time at which the snapshot was scanned.

"Create a snapshot of dependencies for a repository" の HTTP 応答状態コード

状態コード説明
201

Created

"Create a snapshot of dependencies for a repository" のコード サンプル

要求の例

post/repos/{owner}/{repo}/dependency-graph/snapshots
curl -L \ -X POST \ -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/snapshots \ -d '{"version":0,"sha":"ce587453ced02b1526dfb4cb910479d431683101","ref":"refs/heads/main","job":{"correlator":"yourworkflowname_youractionname","id":"yourrunid"},"detector":{"name":"octo-detector","version":"0.0.1","url":"https://github.com/octo-org/octo-repo"},"scanned":"2022-06-14T20:25:00Z","manifests":{"package-lock.json":{"name":"package-lock.json","file":{"source_location":"src/package-lock.json"},"resolved":{"@actions/core":{"package_url":"pkg:/npm/%40actions/core@1.1.9","dependencies":["@actions/http-client"]},"@actions/http-client":{"package_url":"pkg:/npm/%40actions/http-client@1.0.7","dependencies":["tunnel"]},"tunnel":{"package_url":"pkg:/npm/tunnel@0.0.6"}}}}}'

Response

Status: 201
{ "id": 12345, "created_at": "2018-05-04T01:14:52Z", "message": "Dependency results for the repo have been successfully updated.", "result": "SUCCESS" }