# シークレット スキャンのカスタム パターンの定義

正規表現を使用してカスタム パターンを定義することで、一意のシークレットの種類を保護します。

## を使用してカスタム パターンを定義する Copilot

AI を使用すると、検出する必要がある文字列の例 (省略可能) など、検出するパターンの種類のテキスト記述に基づいて正規表現を生成できます。 「[AI を使用したカスタム パターンの正規表現の生成](/ja/code-security/how-tos/secure-your-secrets/customize-leak-detection/generating-regular-expressions-for-custom-patterns-with-ai)」を参照してください。

## リポジトリのカスタムパターンの定義

カスタム パターンを定義する前に、リポジトリで Secret Protection が有効になっていることを確認する必要があります。 詳細については、「[リポジトリのシークレット スキャンの有効化](/ja/code-security/how-tos/secure-your-secrets/detect-secret-leaks/enable-secret-scanning)」を参照してください。

1. GitHub で、リポジトリのメイン ページに移動します。

2. リポジトリ名の下にある **<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-gear" aria-label="gear" role="img"><path d="M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.103-.303c.644-.176 1.392.021 1.82.63.27.385.506.792.704 1.218.315.675.111 1.422-.364 1.891l-.814.806c-.049.048-.098.147-.088.294.016.257.016.515 0 .772-.01.147.038.246.088.294l.814.806c.475.469.679 1.216.364 1.891a7.977 7.977 0 0 1-.704 1.217c-.428.61-1.176.807-1.82.63l-1.102-.302c-.067-.019-.177-.011-.3.071a5.909 5.909 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.106c-.168.646-.715 1.196-1.458 1.26a8.006 8.006 0 0 1-1.402 0c-.743-.064-1.289-.614-1.458-1.26l-.289-1.106c-.018-.066-.079-.158-.212-.224a5.738 5.738 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.103.303c-.644.176-1.392-.021-1.82-.63a8.12 8.12 0 0 1-.704-1.218c-.315-.675-.111-1.422.363-1.891l.815-.806c.05-.048.098-.147.088-.294a6.214 6.214 0 0 1 0-.772c.01-.147-.038-.246-.088-.294l-.815-.806C.635 6.045.431 5.298.746 4.623a7.92 7.92 0 0 1 .704-1.217c.428-.61 1.176-.807 1.82-.63l1.102.302c.067.019.177.011.3-.071.214-.143.437-.272.668-.386.133-.066.194-.158.211-.224l.29-1.106C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm-.571 1.525c-.036.003-.108.036-.137.146l-.289 1.105c-.147.561-.549.967-.998 1.189-.173.086-.34.183-.5.29-.417.278-.97.423-1.529.27l-1.103-.303c-.109-.03-.175.016-.195.045-.22.312-.412.644-.573.99-.014.031-.021.11.059.19l.815.806c.411.406.562.957.53 1.456a4.709 4.709 0 0 0 0 .582c.032.499-.119 1.05-.53 1.456l-.815.806c-.081.08-.073.159-.059.19.162.346.353.677.573.989.02.03.085.076.195.046l1.102-.303c.56-.153 1.113-.008 1.53.27.161.107.328.204.501.29.447.222.85.629.997 1.189l.289 1.105c.029.109.101.143.137.146a6.6 6.6 0 0 0 1.142 0c.036-.003.108-.036.137-.146l.289-1.105c.147-.561.549-.967.998-1.189.173-.086.34-.183.5-.29.417-.278.97-.423 1.529-.27l1.103.303c.109.029.175-.016.195-.045.22-.313.411-.644.573-.99.014-.031.021-.11-.059-.19l-.815-.806c-.411-.406-.562-.957-.53-1.456a4.709 4.709 0 0 0 0-.582c-.032-.499.119-1.05.53-1.456l.815-.806c.081-.08.073-.159.059-.19a6.464 6.464 0 0 0-.573-.989c-.02-.03-.085-.076-.195-.046l-1.102.303c-.56.153-1.113.008-1.53-.27a4.44 4.44 0 0 0-.501-.29c-.447-.222-.85-.629-.997-1.189l-.289-1.105c-.029-.11-.101-.143-.137-.146a6.6 6.6 0 0 0-1.142 0ZM11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM9.5 8a1.5 1.5 0 1 0-3.001.001A1.5 1.5 0 0 0 9.5 8Z"></path></svg> \[Settings]** をクリックします。 \[設定] タブが表示されない場合は、 **\[<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-kebab-horizontal" aria-label="More" role="img"><path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path></svg>]** ドロップダウン メニューを選び、 **\[設定]** をクリックします。

   ![タブを示すリポジトリ ヘッダーのスクリーンショット。 \[設定\] タブが濃いオレンジ色の枠線で強調表示されています。](/assets/images/help/repository/repo-actions-settings.png)

3. サイドバーの \[セキュリティと品質] セクションで、\[ **<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-codescan" aria-label="codescan" role="img"><path d="M8.47 4.97a.75.75 0 0 0 0 1.06L9.94 7.5 8.47 8.97a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06l-2-2a.75.75 0 0 0-1.06 0ZM6.53 6.03a.75.75 0 0 0-1.06-1.06l-2 2a.75.75 0 0 0 0 1.06l2 2a.75.75 0 1 0 1.06-1.06L5.06 7.5l1.47-1.47Z"></path><path d="M12.246 13.307a7.501 7.501 0 1 1 1.06-1.06l2.474 2.473a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM1.5 7.5a6.002 6.002 0 0 0 3.608 5.504 6.002 6.002 0 0 0 6.486-1.117.748.748 0 0 1 .292-.293A6 6 0 1 0 1.5 7.5Z"></path></svg>Advanced Security**] をクリックします。

4. \[Secret Protection] の \[カスタム パターン] の右側にある \[ **新しいパターン**] をクリックします。

5. 新しいカスタム パターンの詳細を入力します。 少なくともパターンの名前と、シークレットパターンのフォーマットとして正規表現を提供しなければなりません。

   1. \[Pattern name] (パターン名) フィールドにパターンの名前を入力します。
   2. \[シークレット形式] フィールドに、シークレット パターンの形式の正規表現を入力します。
   3. \[ **その他のオプション] <svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-chevron-down" aria-label="chevron-down" role="img"><path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path></svg>** をクリックすると、その他の周囲のコンテンツやシークレット形式の追加の一致要件を指定できます。 「[カスタム パターン リファレンス](/ja/code-security/reference/secret-security/custom-patterns#syntax-for-manually-defining-custom-patterns)」を参照してください。
   4. サンプルのテスト文字列を指定し、設定内容が期待するパターンにマッチすることを確認できます。

   ![記入したカスタム secret scanning パターン形式のスクリーンショット。](/assets/images/help/repository/secret-scanning-create-custom-pattern.png)

6. 新しいカスタム パターンをテストする準備ができたら、アラートを作成せずにリポジトリで一致するものを特定するために、 **\[保存してドライ ラン]** をクリックします。

7. ドライ ランが完了すると、結果のサンプル (最大 1000 個) が表示されます。 結果をレビューし、誤検知の結果を特定します。
   ![ドライ ランの結果を示すスクリーンショット。](/assets/images/help/repository/secret-scanning-publish-pattern.png)

8. 新しいカスタム パターンを編集して結果に関するすべての問題を修正してから、 **\[保存してドライ ラン]** をクリックして変更をテストします。

9. 新しいカスタム パターンに問題がなければ、 **\[パターンの発行]** をクリックします。

10. 任意で、カスタム パターンのプッシュ保護を有効にするには、 **\[有効にする]** をクリックします。 詳細については、「[プッシュプロテクション](/ja/code-security/concepts/secret-security/push-protection)」を参照してください。

    > \[!NOTE]
    > ドライ ランが成功し、パターンを公開するまで、\[Enable] ボタンは使用できません。

パターンが作成されたら、 secret scanningはGitHubリポジトリ中に存在するすべてのブランチのGit履歴全体に対して、あらゆるシークレットをスキャンします。シークレット スキャンニング アラートの表示の詳細については、「 [シークレット スキャン アラートの管理](/ja/code-security/how-tos/manage-security-alerts/manage-secret-scanning-alerts)」を参照してください。

## 組織のカスタムパターンの定義

カスタム パターンを定義する前に、組織内でスキャンするリポジトリの secret scanning を有効にする必要があります。\
security configurationsを使用して、組織内のすべてのリポジトリでsecret scanningを有効にすることができます。 詳細については、「[大規模なセキュリティ機能の有効化](/ja/code-security/concepts/security-at-scale/organization-security)」を参照してください。

1. GitHub の右上隅にあるプロフィール画像をクリックしてから、**\[<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-organization" aria-label="organization" role="img"><path d="M1.75 16A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0h8.5C11.216 0 12 .784 12 1.75v12.5c0 .085-.006.168-.018.25h2.268a.25.25 0 0 0 .25-.25V8.285a.25.25 0 0 0-.111-.208l-1.055-.703a.749.749 0 1 1 .832-1.248l1.055.703c.487.325.779.871.779 1.456v5.965A1.75 1.75 0 0 1 14.25 16h-3.5a.766.766 0 0 1-.197-.026c-.099.017-.2.026-.303.026h-3a.75.75 0 0 1-.75-.75V14h-1v1.25a.75.75 0 0 1-.75.75Zm-.25-1.75c0 .138.112.25.25.25H4v-1.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 .75.75v1.25h2.25a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25h-8.5a.25.25 0 0 0-.25.25ZM3.75 6h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5ZM3 3.75A.75.75 0 0 1 3.75 3h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 3 3.75Zm4 3A.75.75 0 0 1 7.75 6h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 7 6.75ZM7.75 3h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5ZM3 9.75A.75.75 0 0 1 3.75 9h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 3 9.75ZM7.75 9h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5Z"></path></svg> Your organizations]** をクリックします。

2. 組織をクリックして選択します。

3. Organization 名の下で、**\[<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-gear" aria-label="gear" role="img"><path d="M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.103-.303c.644-.176 1.392.021 1.82.63.27.385.506.792.704 1.218.315.675.111 1.422-.364 1.891l-.814.806c-.049.048-.098.147-.088.294.016.257.016.515 0 .772-.01.147.038.246.088.294l.814.806c.475.469.679 1.216.364 1.891a7.977 7.977 0 0 1-.704 1.217c-.428.61-1.176.807-1.82.63l-1.102-.302c-.067-.019-.177-.011-.3.071a5.909 5.909 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.106c-.168.646-.715 1.196-1.458 1.26a8.006 8.006 0 0 1-1.402 0c-.743-.064-1.289-.614-1.458-1.26l-.289-1.106c-.018-.066-.079-.158-.212-.224a5.738 5.738 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.103.303c-.644.176-1.392-.021-1.82-.63a8.12 8.12 0 0 1-.704-1.218c-.315-.675-.111-1.422.363-1.891l.815-.806c.05-.048.098-.147.088-.294a6.214 6.214 0 0 1 0-.772c.01-.147-.038-.246-.088-.294l-.815-.806C.635 6.045.431 5.298.746 4.623a7.92 7.92 0 0 1 .704-1.217c.428-.61 1.176-.807 1.82-.63l1.102.302c.067.019.177.011.3-.071.214-.143.437-.272.668-.386.133-.066.194-.158.211-.224l.29-1.106C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm-.571 1.525c-.036.003-.108.036-.137.146l-.289 1.105c-.147.561-.549.967-.998 1.189-.173.086-.34.183-.5.29-.417.278-.97.423-1.529.27l-1.103-.303c-.109-.03-.175.016-.195.045-.22.312-.412.644-.573.99-.014.031-.021.11.059.19l.815.806c.411.406.562.957.53 1.456a4.709 4.709 0 0 0 0 .582c.032.499-.119 1.05-.53 1.456l-.815.806c-.081.08-.073.159-.059.19.162.346.353.677.573.989.02.03.085.076.195.046l1.102-.303c.56-.153 1.113-.008 1.53.27.161.107.328.204.501.29.447.222.85.629.997 1.189l.289 1.105c.029.109.101.143.137.146a6.6 6.6 0 0 0 1.142 0c.036-.003.108-.036.137-.146l.289-1.105c.147-.561.549-.967.998-1.189.173-.086.34-.183.5-.29.417-.278.97-.423 1.529-.27l1.103.303c.109.029.175-.016.195-.045.22-.313.411-.644.573-.99.014-.031.021-.11-.059-.19l-.815-.806c-.411-.406-.562-.957-.53-1.456a4.709 4.709 0 0 0 0-.582c-.032-.499.119-1.05.53-1.456l.815-.806c.081-.08.073-.159.059-.19a6.464 6.464 0 0 0-.573-.989c-.02-.03-.085-.076-.195-.046l-1.102.303c-.56.153-1.113.008-1.53-.27a4.44 4.44 0 0 0-.501-.29c-.447-.222-.85-.629-.997-1.189l-.289-1.105c-.029-.11-.101-.143-.137-.146a6.6 6.6 0 0 0-1.142 0ZM11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM9.5 8a1.5 1.5 0 1 0-3.001.001A1.5 1.5 0 0 0 9.5 8Z"></path></svg> Settings]** をクリックします。 \[設定] タブが表示されない場合は、 **\[<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-kebab-horizontal" aria-label="More" role="img"><path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path></svg>]** ドロップダウン メニューを選び、 **\[設定]** をクリックします。

   ![組織のプロファイルのタブのスクリーンショット。 \[設定\] タブが濃いオレンジ色の枠線で囲まれています。](/assets/images/help/discussions/org-settings-global-nav-update.png)

4. サイドバーの「セキュリティ」セクションで、 **Advanced Security** ドロップダウンメニューを選択し、 **Global settings** をクリックします。

5. \[カスタム パターン] で、\[ **新しいパターン**] をクリックします。

6. 新しいカスタム パターンの詳細を入力します。 少なくともパターンの名前と、シークレットパターンのフォーマットとして正規表現を提供しなければなりません。

   1. \[Pattern name] (パターン名) フィールドにパターンの名前を入力します。
   2. \[シークレット形式] フィールドに、シークレット パターンの形式の正規表現を入力します。
   3. \[ **その他のオプション] <svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-chevron-down" aria-label="chevron-down" role="img"><path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path></svg>** をクリックすると、その他の周囲のコンテンツやシークレット形式の追加の一致要件を指定できます。 「[カスタム パターン リファレンス](/ja/code-security/reference/secret-security/custom-patterns#syntax-for-manually-defining-custom-patterns)」を参照してください。
   4. サンプルのテスト文字列を指定し、設定内容が期待するパターンにマッチすることを確認できます。

   ![記入したカスタム secret scanning パターン形式のスクリーンショット。](/assets/images/help/repository/secret-scanning-create-custom-pattern.png)

7. 新しいカスタム パターンをテストする準備ができたら、アラートを作成せずにリポジトリの選択で一致するものを特定するために、 **\[保存してドライ ラン]** をクリックします。

8. ドライ ランを実行するリポジトリを選びます。
   * 組織全体でドライ ランを実行するには、**\[組織内のすべてのリポジトリ]** を選択します。
   * ドライ ランを実行するリポジトリを指定するには、 **\[選択済みリポジトリ]** を選び、最大 10 個のリポジトリを検索して選びます。

9. 新しいカスタム パターンをテストする準備ができたら、 **\[実行]** をクリックします。

10. ドライ ランが完了すると、結果のサンプル (最大 1000 個) が表示されます。 結果をレビューし、誤検知の結果を特定します。
    ![ドライ ランの結果を示すスクリーンショット。](/assets/images/help/repository/secret-scanning-publish-pattern.png)

11. 新しいカスタム パターンを編集して結果に関するすべての問題を修正してから、 **\[保存してドライ ラン]** をクリックして変更をテストします。

12. 新しいカスタム パターンに問題がなければ、 **\[パターンの発行]** をクリックします。

13. 任意で、カスタム パターンのプッシュ保護を有効にするには、 **\[有効にする]** をクリックします。 詳細については、「[プッシュプロテクション](/ja/code-security/concepts/secret-security/push-protection#customization)」を参照してください。

    > \[!NOTE]
    >
    > * プッシュ保護を有効にするオプションは、公開されたパターンでのみ表示されます。
    > * カスタム パターンのプッシュ保護は、プッシュ保護として secret scanning が有効になっている組織のリポジトリにのみ適用されます。
    > * 一般的なカスタム パターンに対してプッシュ保護を有効にすると、共同作成者が混乱する可能性があります。

パターンが作成されたら、 secret scanning は、組織内のリポジトリ内のすべてのシークレット (すべてのブランチでの Git 履歴全体を含む) をスキャンします。 Organization の所有者とリポジトリの管理者は、シークレットが見つかるとアラートを受け、シークレットが見つかったリポジトリでアラートをレビューできます。
シークレット スキャンニング アラートの表示の詳細については、「[シークレット スキャン アラートの管理](/ja/code-security/how-tos/manage-security-alerts/manage-secret-scanning-alerts)」を参照してください。

## Enterprise アカウントのカスタム パターンの定義

> \[!NOTE]
>
> * エンタープライズ レベルでは、カスタム パターンの作成者のみがパターンを編集し、ドライ ランで使用できます。
> * ドライ ランは、自分が管理アクセス権を持つリポジトリでのみ実行できます。 エンタープライズ所有者が、組織内の任意のリポジトリでドライ ランを実行するためのアクセス権を必要とする場合は、組織所有者ロールが割り当てられている必要があります。 詳しくは、「[あなたの企業が所有する組織での役割を管理する](/ja/enterprise-cloud@latest/admin/managing-accounts-and-repositories/managing-organizations-in-your-enterprise/managing-your-role-in-an-organization-owned-by-your-enterprise)」をご覧ください。

1. 企業ページに移動してください。 たとえば、GitHub.com の [\[Enterprise\]](https://github.com/settings/enterprises?ref_product=ghec\&ref_type=engagement\&ref_style=text) ページから。

2. ページの上部にある \[**ポリシーの<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-law" aria-label="law" role="img"><path d="M8.75.75V2h.985c.304 0 .603.08.867.231l1.29.736c.038.022.08.033.124.033h2.234a.75.75 0 0 1 0 1.5h-.427l2.111 4.692a.75.75 0 0 1-.154.838l-.53-.53.529.531-.001.002-.002.002-.006.006-.006.005-.01.01-.045.04c-.21.176-.441.327-.686.45C14.556 10.78 13.88 11 13 11a4.498 4.498 0 0 1-2.023-.454 3.544 3.544 0 0 1-.686-.45l-.045-.04-.016-.015-.006-.006-.004-.004v-.001a.75.75 0 0 1-.154-.838L12.178 4.5h-.162c-.305 0-.604-.079-.868-.231l-1.29-.736a.245.245 0 0 0-.124-.033H8.75V13h2.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1 0-1.5h2.5V3.5h-.984a.245.245 0 0 0-.124.033l-1.289.737c-.265.15-.564.23-.869.23h-.162l2.112 4.692a.75.75 0 0 1-.154.838l-.53-.53.529.531-.001.002-.002.002-.006.006-.016.015-.045.04c-.21.176-.441.327-.686.45C4.556 10.78 3.88 11 3 11a4.498 4.498 0 0 1-2.023-.454 3.544 3.544 0 0 1-.686-.45l-.045-.04-.016-.015-.006-.006-.004-.004v-.001a.75.75 0 0 1-.154-.838L2.178 4.5H1.75a.75.75 0 0 1 0-1.5h2.234a.249.249 0 0 0 .125-.033l1.288-.737c.265-.15.564-.23.869-.23h.984V.75a.75.75 0 0 1 1.5 0Zm2.945 8.477c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327Zm-10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327Z"></path></svg>**] をクリックします。

3. <svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-law" aria-label="law" role="img"><path d="M8.75.75V2h.985c.304 0 .603.08.867.231l1.29.736c.038.022.08.033.124.033h2.234a.75.75 0 0 1 0 1.5h-.427l2.111 4.692a.75.75 0 0 1-.154.838l-.53-.53.529.531-.001.002-.002.002-.006.006-.006.005-.01.01-.045.04c-.21.176-.441.327-.686.45C14.556 10.78 13.88 11 13 11a4.498 4.498 0 0 1-2.023-.454 3.544 3.544 0 0 1-.686-.45l-.045-.04-.016-.015-.006-.006-.004-.004v-.001a.75.75 0 0 1-.154-.838L12.178 4.5h-.162c-.305 0-.604-.079-.868-.231l-1.29-.736a.245.245 0 0 0-.124-.033H8.75V13h2.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1 0-1.5h2.5V3.5h-.984a.245.245 0 0 0-.124.033l-1.289.737c-.265.15-.564.23-.869.23h-.162l2.112 4.692a.75.75 0 0 1-.154.838l-.53-.53.529.531-.001.002-.002.002-.006.006-.016.015-.045.04c-.21.176-.441.327-.686.45C4.556 10.78 3.88 11 3 11a4.498 4.498 0 0 1-2.023-.454 3.544 3.544 0 0 1-.686-.45l-.045-.04-.016-.015-.006-.006-.004-.004v-.001a.75.75 0 0 1-.154-.838L2.178 4.5H1.75a.75.75 0 0 1 0-1.5h2.234a.249.249 0 0 0 .125-.033l1.288-.737c.265-.15.564-.23.869-.23h.984V.75a.75.75 0 0 1 1.5 0Zm2.945 8.477c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327Zm-10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327Z"></path></svg> \[Policies] で、**\[Advanced Security Code security]** をクリックします。

4. \[Advanced Security Code security] の \[ **セキュリティ機能**] をクリックします。

5. \[シークレット スキャン カスタム パターン] で、 **\[新しいパターン]** をクリックします。

6. 新しいカスタム パターンの詳細を入力します。 少なくともパターンの名前と、シークレットパターンのフォーマットとして正規表現を提供しなければなりません。

   1. \[Pattern name] (パターン名) フィールドにパターンの名前を入力します。
   2. \[シークレット形式] フィールドに、シークレット パターンの形式の正規表現を入力します。
   3. \[ **その他のオプション] <svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-chevron-down" aria-label="chevron-down" role="img"><path d="M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"></path></svg>** をクリックすると、その他の周囲のコンテンツやシークレット形式の追加の一致要件を指定できます。 「[カスタム パターン リファレンス](/ja/code-security/reference/secret-security/custom-patterns#syntax-for-manually-defining-custom-patterns)」を参照してください。
   4. サンプルのテスト文字列を指定し、設定内容が期待するパターンにマッチすることを確認できます。

   ![記入したカスタム secret scanning パターン形式のスクリーンショット。](/assets/images/help/repository/secret-scanning-create-custom-pattern.png)

7. 新しいカスタム パターンをテストする準備ができたら、アラートを作成せずに Enterprise で一致するものを特定するため、 **\[保存してドライ ラン]** をクリックします。

8. ドライ ランを実行するリポジトリを最大 10 個検索して選択します。

9. 新しいカスタム パターンをテストする準備ができたら、 **\[実行]** をクリックします。

10. ドライ ランが完了すると、結果のサンプル (最大 1000 個) が表示されます。 結果をレビューし、誤検知の結果を特定します。
    ![ドライ ランの結果を示すスクリーンショット。](/assets/images/help/repository/secret-scanning-publish-pattern.png)

11. 新しいカスタム パターンを編集して結果に関するすべての問題を修正してから、 **\[保存してドライ ラン]** をクリックして変更をテストします。

12. 新しいカスタム パターンに問題がなければ、 **\[パターンの発行]** をクリックします。

13. 任意で、カスタム パターンのプッシュ保護を有効にするには、 **\[有効にする]** をクリックします。 詳細については、「[プッシュプロテクション](/ja/code-security/concepts/secret-security/push-protection)」を参照してください。
    > \[!NOTE]
    >
    > * カスタム パターンのプッシュ保護を有効にするには、エンタープライズ レベルでプッシュ保護として secret scanning を有効にする必要があります。
    > * 一般的なカスタム パターンに対してプッシュ保護を有効にすると、共同作成者が混乱する可能性があります。

パターンが作成されたら、 secret scanning は、すべてのブランチの Git 履歴全体を含め、 GitHub Secret Protection が有効になっている組織内のリポジトリ内のシークレットをスキャンします。 Organization の所有者とリポジトリの管理者は、シークレットが見つかるとアラートを受け、シークレットが見つかったリポジトリでアラートをレビューできます。
シークレット スキャンニング アラートの表示の詳細については、「[シークレット スキャン アラートの管理](/ja/code-security/how-tos/manage-security-alerts/manage-secret-scanning-alerts)」を参照してください。