メモ
The rule to require secret scanning alerts to be resolved before merging is in パブリック プレビュー and subject to change.
The Require secret scanning alerts are resolved rule is available for rulesets that target branches in repositories. You can use the rule to block a pull request from merging when either of these conditions applies:
- A secret scanning scan has not completed for the head commit of the pull request.
- A commit in the pull request introduced an open secret scanning alert that matches a secret type selected in the ruleset.
The rule supports provider, custom, and generic patterns. It does not support AI-detected secrets.
Prerequisites
The repositories that you want to protect must have:
- Either GitHub Secret Protection or GitHub Advanced Security enabled
- Secret scanning enabled. See リポジトリのシークレット スキャンの有効化.
Creating a merge protection ruleset for a repository
-
GitHub で、リポジトリのメイン ページに移動します。
-
リポジトリ名の下にある [Settings] をクリックします。 [設定] タブが表示されない場合は、 [] ドロップダウン メニューを選び、 [設定] をクリックします。
![タブを示すリポジトリ ヘッダーのスクリーンショット。 [設定] タブが濃いオレンジ色の枠線で強調表示されています。](/assets/cb-28260/images/help/repository/repo-actions-settings.png)
-
左側のサイドバーの [コードと自動化] で、[ ルールセット] をクリックし、[ ルールセット] をクリックします。
-
Click New ruleset.
-
Click New branch ruleset.
-
[ルールセット名] に、ルールセットの名前を入力します。
-
必要に応じて、既定の適用状態を変更するには、 [Disabled] をクリックして、新しい適用状態を選びます。 ブランチまたはタグをターゲットにするには、[ターゲット ブランチ] または [ターゲット タグ] セクションで、[ターゲットの追加] を選び、ブランチまたはタグを含めるまたは除外する方法を選びます。
fnmatch構文を使って、パターンに基づいてブランチまたはタグを含めたり除外したりできます。 詳細については、「fnmatch構文の使用」を参照してください。
複数のターゲット条件を同じルールセットに追加できます。 たとえば、既定のブランチを含め、*feature* のパターンに一致するブランチを含めてから、not-a-feature のパターンに一致する特定のブランチを除外することができます。
- Under "Branch protections", select Require secret scanning alerts are resolved.
- Under "Secret types", select one or more types of secrets that should block merging:
- Provider patterns
- Custom patterns
- Generic patterns ルールセットの作成を完了するには、[作成] をクリックします。 ルールセットの適用ステータスが "アクティブ" に設定されている場合、ルールセットはすぐに有効になります。
For information about configuring bypass permissions and other ruleset settings, see リポジトリのルールセットの作成.
Creating a merge protection ruleset for repositories in an organization
-
GitHub の右上隅にあるプロフィール画像をクリックしてから、[ Your organizations] をクリックします。
-
組織をクリックして選択します。
-
Organization 名の下で、[ Settings] をクリックします。 [設定] タブが表示されない場合は、 [] ドロップダウン メニューを選び、 [設定] をクリックします。
![組織のプロファイルのタブのスクリーンショット。 [設定] タブが濃いオレンジ色の枠線で囲まれています。](/assets/cb-49309/images/help/discussions/org-settings-global-nav-update.png)
-
サイドバーの [Code, planning, and automation](コード、計画、自動化) の下で、[リポジトリ クリックし、[ルールセット] をクリックします。
-
Click New ruleset.
-
Click New branch ruleset.
-
[ルールセット名] に、ルールセットの名前を入力します。
-
必要に応じて、既定の適用状態を変更するには、 [Disabled] をクリックして、新しい適用状態を選びます。
-
Under "Target repositories", choose the repositories that the ruleset will apply to. ブランチまたはタグをターゲットにするには、[ターゲット ブランチ] または [ターゲット タグ] セクションで、[ターゲットの追加] を選び、ブランチまたはタグを含めるまたは除外する方法を選びます。
fnmatch構文を使って、パターンに基づいてブランチまたはタグを含めたり除外したりできます。 詳細については、「fnmatch構文の使用」を参照してください。
複数のターゲット条件を同じルールセットに追加できます。 たとえば、既定のブランチを含め、*feature* のパターンに一致するブランチを含めてから、not-a-feature のパターンに一致する特定のブランチを除外することができます。
- Under "Branch protections", select Require secret scanning alerts are resolved.
- Under "Secret types", select one or more types of secrets that should block merging:
- Provider patterns
- Custom patterns
- Generic patterns ルールセットの作成を完了するには、[作成] をクリックします。 ルールセットの適用ステータスが "アクティブ" に設定されている場合、ルールセットはすぐに有効になります。
For information about configuring bypass permissions and other ruleset settings, see 組織内のリポジトリのルールセットを作成する.
Unblocking a pull request
When this rule blocks a pull request because of open alerts, you must resolve each alert that matches the secret types selected in the ruleset. See シークレット スキャンからのアラートの解決.