依存関係の確認について
依存関係レビューを使うと、すべてのPull Reqeustにおける以下の変更による依存関係の変化とセキュリティについての影響を理解しやすくなります。pull request の [Files Changed](変更されたファイル) タブ上のリッチ diff で依存関係の変更をわかりやすく視覚化できます。 依存関係レビューは、以下のことを知らせます:
- リリース日と合わせて、追加、削除、更新された依存関係。
- これらのコンポーネントを使うプロジェクトの数。
- これらの依存関係に関する脆弱性のデータ。
詳細については、「依存関係の確認について」および「プルリクエスト内の依存関係の変更をレビューする」を参照してください。
依存関係レビューの構成について
依存関係レビューは、すべての製品のすべてのパブリック リポジトリで使用できます。また、無効にすることはできません。 依存関係レビューは、GitHub Enterprise Cloud を使い、GitHub Advanced Security のライセンスを持つ組織が所有するプライベート リポジトリで利用できます。 詳細については、GitHub Enterprise Cloud ドキュメントを参照してください。
依存関係レビュー アクション の構成について
依存関係レビュー アクション は、依存関係の変更について pull request をスキャンし、新しい依存関係に既知の脆弱性がある場合はエラーを発生させます。 アクションは、2 つのリビジョン間の依存関係を比較し、相違点を報告する API エンドポイントによってサポートされています。
アクションと API エンドポイントについて詳しくは、dependency-review-action
ドキュメントと、と API ドキュメントの 「依存関係の確認」を参照してください。
次の構成オプションを使用できます。
オプション | 必須 | 使用法 |
---|---|---|
fail-on-severity | 重大度レベル (low 、moderate 、high 、critical ) のしきい値を定義します。アクションは、指定した重大度レベル以上の脆弱性を引き起こす pull request で失敗します。 | |
allow-licenses | 許可されているライセンスのリストが含まれています。 このパラメーターに使用できる値は、API ドキュメントの「ライセンス」のページで確認できます。 このアクションは、リストと一致しないライセンスを持つ依存関係を導入する pull request で失敗します。 | |
deny-licenses | 禁止されているライセンスのリストが含まれています。 このパラメーターに使用できる値は、API ドキュメントの「ライセンス」のページで確認できます。 アクションは、リストに一致するライセンスを持つ依存関係を導入する pull request で失敗します。 | |
allow-ghsas | 検出中にスキップできる GitHub Advisory Database ID のリストを含めます。 このパラメーターに指定できる値は、GitHub Advisory Database で見つけることができます。 | |
config-file | 構成ファイルへのパスを指定します。 構成ファイルは、リポジトリに対してローカルにすることも、外部リポジトリにあるファイルにすることもできます。 |
ヒント: オプション allow-licenses
と deny-licenses
は同時に指定できません。
依存関係レビュー アクション の構成について
依存関係レビュー アクション を構成する方法は 2 つあります。
- ワークフロー ファイル内に構成オプションをインライン化する。
- ワークフロー ファイル内で構成オプションを参照する。
すべての例で、アクションに対して、semver リリース番号 (v3.0.8
など) ではなく、短いバージョン番号 (v3
) が使われています。 これにより、アクションの最新のマイナー バージョンを使うことができます。
インライン構成を使って 依存関係レビュー アクション を設定する
-
.github/workflows
フォルダーに新しい YAML ワークフローを追加します。YAML name: 'Dependency Review' on: [pull_request] permissions: contents: read jobs: dependency-review: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' uses: actions/checkout@v4 - name: Dependency Review uses: actions/dependency-review-action@v3
name: 'Dependency Review' on: [pull_request] permissions: contents: read jobs: dependency-review: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' uses: actions/checkout@v4 - name: Dependency Review uses: actions/dependency-review-action@v3
-
必要に応じて設定を変更します。
この 依存関係レビュー アクション サンプル ファイルは、利用可能な構成オプションの使用方法を示しています。
YAML name: 'Dependency Review' on: [pull_request] permissions: contents: read jobs: dependency-review: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' uses: actions/checkout@v4 - name: Dependency Review uses: actions/dependency-review-action@v3 with: # Possible values: "critical", "high", "moderate", "low" fail-on-severity: critical # You can only include one of these two options: `allow-licenses` and `deny-licenses` # ([String]). Only allow these licenses (optional) # Possible values: Any `spdx_id` value(s) from https://docs.github.com/en/rest/licenses allow-licenses: GPL-3.0, BSD-3-Clause, MIT # ([String]). Block the pull request on these licenses (optional) # Possible values: Any `spdx_id` value(s) from https://docs.github.com/en/rest/licenses deny-licenses: LGPL-2.0, BSD-2-Clause # ([String]). Skip these GitHub Advisory Database IDs during detection (optional) # Possible values: Any valid GitHub Advisory Database ID from https://github.com/advisories allow-ghsas: GHSA-abcd-1234-5679, GHSA-efgh-1234-5679 # ([String]). Block pull requests that introduce vulnerabilities in the scopes that match this list (optional) # Possible values: "development", "runtime", "unknown" fail-on-scopes: development, runtime
name: 'Dependency Review' on: [pull_request] permissions: contents: read jobs: dependency-review: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' uses: actions/checkout@v4 - name: Dependency Review uses: actions/dependency-review-action@v3 with: # Possible values: "critical", "high", "moderate", "low" fail-on-severity: critical # You can only include one of these two options: `allow-licenses` and `deny-licenses` # ([String]). Only allow these licenses (optional) # Possible values: Any `spdx_id` value(s) from https://docs.github.com/en/rest/licenses allow-licenses: GPL-3.0, BSD-3-Clause, MIT # ([String]). Block the pull request on these licenses (optional) # Possible values: Any `spdx_id` value(s) from https://docs.github.com/en/rest/licenses deny-licenses: LGPL-2.0, BSD-2-Clause # ([String]). Skip these GitHub Advisory Database IDs during detection (optional) # Possible values: Any valid GitHub Advisory Database ID from https://github.com/advisories allow-ghsas: GHSA-abcd-1234-5679, GHSA-efgh-1234-5679 # ([String]). Block pull requests that introduce vulnerabilities in the scopes that match this list (optional) # Possible values: "development", "runtime", "unknown" fail-on-scopes: development, runtime
構成ファイルを使って 依存関係レビュー アクション を設定する
-
.github/workflows
フォルダーに新しい YAML ワークフローを追加し、config-file
を使って構成ファイルを使用していることを指定します。YAML name: 'Dependency Review' on: [pull_request] permissions: contents: read jobs: dependency-review: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' uses: actions/checkout@v4 - name: Dependency Review uses: actions/dependency-review-action@v3 with: # ([String]). Representing a path to a configuration file local to the repository or in an external repository. # Possible values: An absolute path to a local file or an external file. config-file: './.github/dependency-review-config.yml' # Syntax for an external file: OWNER/REPOSITORY/FILENAME@BRANCH config-file: 'github/octorepo/dependency-review-config.yml@main' # ([Token]) Use if your configuration file resides in a private external repository. # Possible values: Any GitHub token with read access to the private external repository. external-repo-token: 'ghp_123456789abcde'
name: 'Dependency Review' on: [pull_request] permissions: contents: read jobs: dependency-review: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' uses: actions/checkout@v4 - name: Dependency Review uses: actions/dependency-review-action@v3 with: # ([String]). Representing a path to a configuration file local to the repository or in an external repository. # Possible values: An absolute path to a local file or an external file. config-file: './.github/dependency-review-config.yml' # Syntax for an external file: OWNER/REPOSITORY/FILENAME@BRANCH config-file: 'github/octorepo/dependency-review-config.yml@main' # ([Token]) Use if your configuration file resides in a private external repository. # Possible values: Any GitHub token with read access to the private external repository. external-repo-token: 'ghp_123456789abcde'
-
指定したパスに構成ファイルを作成します。
この YAML ファイルの例は、利用可能な構成オプションの使用方法を示しています。
YAML # Possible values: "critical", "high", "moderate", "low" fail-on-severity: critical # You can only include one of these two options: `allow-licenses` and `deny-licenses` # ([String]). Only allow these licenses (optional) # Possible values: Any `spdx_id` value(s) from https://docs.github.com/en/rest/licenses allow-licenses: - GPL-3.0 - BSD-3-Clause - MIT # ([String]). Block the pull request on these licenses (optional) # Possible values: Any `spdx_id` value(s) from https://docs.github.com/en/rest/licenses deny-licenses: - LGPL-2.0 - BSD-2-Clause # ([String]). Skip these GitHub Advisory Database IDs during detection (optional) # Possible values: Any valid GitHub Advisory Database ID from https://github.com/advisories allow-ghsas: - GHSA-abcd-1234-5679 - GHSA-efgh-1234-5679 # ([String]). Block pull requests that introduce vulnerabilities in the scopes that match this list (optional) # Possible values: "development", "runtime", "unknown" fail-on-scopes: - development - runtime
# Possible values: "critical", "high", "moderate", "low" fail-on-severity: critical # You can only include one of these two options: `allow-licenses` and `deny-licenses` # ([String]). Only allow these licenses (optional) # Possible values: Any `spdx_id` value(s) from https://docs.github.com/en/rest/licenses allow-licenses: - GPL-3.0 - BSD-3-Clause - MIT # ([String]). Block the pull request on these licenses (optional) # Possible values: Any `spdx_id` value(s) from https://docs.github.com/en/rest/licenses deny-licenses: - LGPL-2.0 - BSD-2-Clause # ([String]). Skip these GitHub Advisory Database IDs during detection (optional) # Possible values: Any valid GitHub Advisory Database ID from https://github.com/advisories allow-ghsas: - GHSA-abcd-1234-5679 - GHSA-efgh-1234-5679 # ([String]). Block pull requests that introduce vulnerabilities in the scopes that match this list (optional) # Possible values: "development", "runtime", "unknown" fail-on-scopes: - development - runtime
構成オプションの詳細については、「dependency-review-action
」を参照してください。