Protect your unique secret types by defining custom patterns with regular expressions.
You can use AI to generate regular expressions based on a text description of the type of pattern you would like to detect, including optional example strings that should be detected. See Generating regular expressions for custom patterns with AI.
Before defining a custom pattern, you must ensure that Secret Protection is enabled on your repository. For more information, see Enabling secret scanning for your repository.
On GitHub, navigate to the main page of the repository.
Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.

In the "Security and quality" section of the sidebar, click Advanced Security.
Under "Secret Protection", to the right of "Custom patterns", click New pattern.
Enter the details for your new custom pattern. You must at least provide the name for your pattern, and a regular expression for the format of your secret pattern.

When you're ready to test your new custom pattern, to identify matches in the repository without creating alerts, click Save and dry run.
When the dry run finishes, you'll see a sample of results (up to 1000). Review the results and identify any false positive results.

Edit the new custom pattern to fix any problems with the results, then, to test your changes, click Save and dry run.
When you're satisfied with your new custom pattern, click Publish pattern.
Optionally, to enable push protection for your custom pattern, click Enable. For more information, see Push protection.
Note
The "Enable" button isn't available until after the dry run succeeds and you publish the pattern.
After your pattern is created, secret scanning scans for any secrets in your entire Git history on all branches present in your GitHub repository. For more information on viewing secret scanning alerts, see Manage secret scanning alerts.
Before defining a custom pattern, you must ensure that you enable secret scanning for the repositories that you want to scan in your organization. You can use security configurations to enable secret scanning on all repositories in your organization. For more information, see Enabling security features at scale.
In the upper-right corner of GitHub, click your profile picture, then click Organizations.
Select an organization by clicking on it.
Under your organization name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.

In the "Security" section of the sidebar, select the Advanced Security dropdown menu, then click Global settings.
Under "Custom patterns", click New pattern.
Enter the details for your new custom pattern. You must at least provide the name for your pattern, and a regular expression for the format of your secret pattern.

When you're ready to test your new custom pattern, to identify matches in select repositories without creating alerts, click Save and dry run.
Select the repositories where you want to perform the dry run.
When you're ready to test your new custom pattern, click Run.
When the dry run finishes, you'll see a sample of results (up to 1000). Review the results and identify any false positive results.

Edit the new custom pattern to fix any problems with the results, then, to test your changes, click Save and dry run.
When you're satisfied with your new custom pattern, click Publish pattern.
Optionally, to enable push protection for your custom pattern, click Enable. For more information, see Push protection.
Note
After your pattern is created, secret scanning scans for any secrets in repositories in your organization, including their entire Git history on all branches. Organization owners and repository administrators will be alerted to any secrets found and can review the alert in the repository where the secret is found. For more information on viewing secret scanning alerts, see Manage secret scanning alerts.
Note
Navigate to your enterprise. For example, from the Enterprises page on GitHub.com.
At the top of the page, click Policies.
Under "Policies", click Advanced Security.
Under "Advanced Security", click Security features.
Under "Secret scanning custom patterns", click New pattern.
Enter the details for your new custom pattern. You must at least provide the name for your pattern, and a regular expression for the format of your secret pattern.

When you're ready to test your new custom pattern, to identify matches in the enterprise without creating alerts, click Save and dry run.
Search for and select up to 10 repositories where you want to perform the dry run.
When you're ready to test your new custom pattern, click Run.
When the dry run finishes, you'll see a sample of results (up to 1000). Review the results and identify any false positive results.

Edit the new custom pattern to fix any problems with the results, then, to test your changes, click Save and dry run.
When you're satisfied with your new custom pattern, click Publish pattern.
Optionally, to enable push protection for your custom pattern, click Enable. For more information, see Push protection.
Note
After your pattern is created, secret scanning scans for any secrets in repositories within your organizations with GitHub Secret Protection enabled, including their entire Git history on all branches. Organization owners and repository administrators will be alerted to any secrets found, and can review the alert in the repository where the secret is found. For more information on viewing secret scanning alerts, see Manage secret scanning alerts.