About the 依存関係送信 API
REST API を使って、プロジェクトの依存関係を送信できます。 これにより、ソフトウェアのコンパイル時やビルド時に解決されるものなどの依存関係を GitHub の依存関係グラフ機能に追加し、プロジェクトのすべての依存関係をより完全に把握できます。
依存関係グラフには、リポジトリ内のマニフェストまたはロック ファイル (JavaScript プロジェクトの package-lock.json ファイルなど) から識別された依存関係に加えて、この API を使って送信したすべての依存関係が表示されます。 依存関係グラフの表示の詳細については、「Exploring the dependencies of a repository」を参照してください。
送信された依存関係は、既知の脆弱性に対する Dependabot alerts と Dependabot security updates を受け取ります。 GitHub Advisory Database のサポートされているエコシステムのいずれかからの依存関係に対する Dependabot alerts のみを受け取ります。 これらのエコシステムの詳細については、「GitHub Advisory Database について」を参照してください。 依存関係送信 API を介して送信された推移的な依存関係の場合、更新プログラムが利用可能な場合は、Dependabot が自動的に pull request を開き、親依存関係を更新します。
送信された依存関係は依存関係レビューに表示されますが、organization の依存関係の分析情報には表示 "されません"。__
メモ
依存関係レビュー API と 依存関係送信 API は連携して動作します。 これは、依存関係レビュー API には、依存関係送信 API を介して送信された依存関係が含まれます。
Dependencies are submitted to the 依存関係送信 API in the form of a snapshot. A snapshot is a set of dependencies associated with a commit SHA and other metadata, that reflects the current state of your repository for a commit. Snapshots can be generated from the dependencies detected at build time. For technical details on using the 依存関係送信 API over the network, see 依存関係送信用の REST API エンドポイント.
Submitting dependencies at build-time
You can use the 依存関係送信 API in a GitHub Actions workflow to submit dependencies for your project when your project is built.
Using pre-made actions
依存関係送信 API を使う最も簡単な方法は、依存関係のリストを収集して必要なスナップショット形式に変換したものを API に送信するアクションを事前に作成し、それをリポジトリに追加することです。
| エコシステム | アクション |
|---|---|
| Go | Go の依存関係送信 |
| Gradle | Gradle の依存関係送信 |
| Maven | Maven 依存関係ツリーの依存関係送信 |
| 製粉 | Mill の依存関係送信 |
| Mix (Elixir) | Mix の依存関係送信 |
| Scala | Sbt の依存関係送信 |
| NuGet とその他 | コンポーネント検出の依存関係の送信アクション |
メモ
コンポーネント検出依存関係の送信アクションの場合、サポートされているその他のエコシステムには、Vcpkg、Conan、Conda、Crates、NuGet などがあります。
たとえば、次の Go 依存関係送信ワークフローは、Go ビルド ターゲット (main 関数を含む Go ファイル) の依存関係を計算し、そのリストを 依存関係送信 API に送信します。
name: Go Dependency Submission
on:
push:
branches:
- main
# The API requires write permission on the repository to submit dependencies
permissions:
contents: write
# Environment variables to configure Go and Go modules. Customize as necessary
env:
GOPROXY: '' # A Go Proxy server to be used
GOPRIVATE: '' # A list of modules are considered private and not requested from GOPROXY
jobs:
go-action-detection:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v5
- uses: actions/setup-go@v5
with:
go-version: ">=1.18.0"
- name: Run snapshot action
uses: actions/go-dependency-submission@v2
with:
# Required: Define the repo path to the go.mod file used by the
# build target
go-mod-path: go-example/go.mod
#
# Optional. Define the repo path of a build target,
# a file with a `main()` function.
# If undefined, this action will collect all dependencies
# used by all build targets for the module. This may
# include Go dependencies used by tests and tooling.
go-build-target: go-example/cmd/octocat.go
For more information about these actions, see 依存関係グラフでパッケージ エコシステムをサポート.
Creating your own action
Alternatively, you can write your own action to submit dependencies for your project at build-time. Your workflow should:
- Generate a list of dependencies for your project.
- Translate the list of dependencies into the snapshot format accepted by the 依存関係送信 API. For more information about the format, see the body parameters for the "Create a repository snapshot" API endpoint in 依存関係送信用の REST API エンドポイント.
- Submit the formatted list of dependencies to the 依存関係送信 API.
GitHub maintains the Dependency Submission Toolkit, a TypeScript library to help you build your own GitHub Action for submitting dependencies to the 依存関係送信 API. For more information about writing an action, see 自動化の再利用.
Submitting SBOMs as snapshots
If you have external tools which create or manage Software Bills of Materials (SBOMs), you can also submit those SBOMs to the 依存関係送信 API. The snapshot data format is very similar to the standard SPDX and CycloneDX SBOM formats, and there are several tools which can generate or translate formats for use as snapshots.
ヒント
The SPDX Dependency Submission Action and the Anchore SBOM Action can be used to both generate a SBOM and submit it to the 依存関係送信 API.
For example, the following SPDX Dependency Submission Action workflow calculates the dependencies for a repository, generates an exportable SBOM in SPDX 2.2 format, and submits it to the 依存関係送信 API.
# このワークフローはGitHubによって認定されていないアクションを使用します。
# それらはサードパーティによって提供され、
# 別個の利用規約、プライバシーポリシー、
# ドキュメントを参照してください。
name: SBOM upload
on:
workflow_dispatch:
push:
branches: ["main"]
jobs:
SBOM-upload:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v5
- name: Generate SBOM
# generation command documentation: https://github.com/microsoft/sbom-tool#sbom-generation
run: |
curl -Lo $RUNNER_TEMP/sbom-tool https://github.com/microsoft/sbom-tool/releases/latest/download/sbom-tool-linux-x64
chmod +x $RUNNER_TEMP/sbom-tool
$RUNNER_TEMP/sbom-tool generate -b . -bc . -pn $ -pv 1.0.0 -ps OwnerName -nsb https://sbom.mycompany.com -V Verbose
- uses: actions/upload-artifact@v4
with:
name: sbom
path: _manifest/spdx_2.2
- name: SBOM upload
uses: advanced-security/spdx-dependency-submission-action@5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e
with:
filePath: "_manifest/spdx_2.2/"