Skip to content

Commit 3157980

Browse files
lucascostimchammer01Grey Bakertimeyoutakeit
authored
Add docs for secret scanning user defined patterns beta (github#19589)
* New secret scanning article part 1 * Add other procedures and links * Apply suggestions from code review Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com> * UI variable suggestions Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com> * Clarify org setting and beta note * Fix GHES version * Apply suggestions from @greysteil's code review Co-authored-by: Grey Baker <greysteil@github.com> * Remove beta view restriction * Add section on regex syntax Co-authored-by: Grey Baker <greysteil@github.com> * Regex support edit Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com> Co-authored-by: Grey Baker <greysteil@github.com> Co-authored-by: Amy Burns <timeyoutakeit@github.com>
1 parent b3bf15b commit 3157980

11 files changed

Lines changed: 99 additions & 2 deletions
82 KB
Loading
128 KB
Loading
52.4 KB
Loading

content/code-security/secret-security/about-secret-scanning.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ When {% data variables.product.prodname_secret_scanning %} detects a set of cred
4949

5050
If you're a repository administrator or an organization owner, you can enable {% data variables.product.prodname_secret_scanning %} for {% if currentVersion == "free-pro-team@latest" %} private{% endif %} repositories that are owned by organizations. You can enable {% data variables.product.prodname_secret_scanning %} for all your repositories, or for all new repositories within your organization.{% if currentVersion == "free-pro-team@latest" %} {% data variables.product.prodname_secret_scanning_caps %} is not available for user-owned private repositories.{% endif %} For more information, see "[Managing security and analysis settings for your repository](/github/administering-a-repository/managing-security-and-analysis-settings-for-your-repository)" and "[Managing security and analysis settings for your organization](/organizations/keeping-your-organization-secure/managing-security-and-analysis-settings-for-your-organization)."
5151

52+
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@3.1" or currentVersion == "github-ae@next" %}You can also define custom {% data variables.product.prodname_secret_scanning %} patterns that only apply to your repository or organization. For more information, see "[Defining custom patterns for {% data variables.product.prodname_secret_scanning %}](/code-security/secret-security/defining-custom-patterns-for-secret-scanning)."{% endif %}
53+
5254
When you push commits to a{% if currentVersion == "free-pro-team@latest" %} private{% endif %} repository with {% data variables.product.prodname_secret_scanning %} enabled, {% data variables.product.prodname_dotcom %} scans the contents of the commits for secrets.
5355

5456
When {% data variables.product.prodname_secret_scanning %} detects a secret in a{% if currentVersion == "free-pro-team@latest" %} private{% endif %} repository, {% data variables.product.prodname_dotcom %} generates an alert.
@@ -71,11 +73,13 @@ To monitor results from {% data variables.product.prodname_secret_scanning %} ac
7173

7274
{% data reusables.secret-scanning.partner-secret-list-private-repo %}
7375

76+
{% if currentVersion ver_lt "enterprise-server@3.2" or currentVersion == "github-ae@latest" %}
7477
{% note %}
7578

7679
**Note:** {% data variables.product.prodname_secret_scanning_caps %} does not currently allow you to define your own patterns for detecting secrets.
7780

7881
{% endnote %}
82+
{% endif %}
7983

8084
### Further reading
8185

content/code-security/secret-security/configuring-secret-scanning-for-your-repositories.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ topics:
3232

3333
{% if currentVersion ver_gt "enterprise-server@2.22" or currentVersion == "github-ae@next" %}
3434
You can enable {% data variables.product.prodname_secret_scanning %} for any repository that is owned by an organization.
35-
{% endif %} Once enabled, {% data variables.product.prodname_secret_scanning %} will scan for any secrets your entire Git history on all branches present in your {% data variables.product.prodname_dotcom %} repository.
35+
{% endif %} Once enabled, {% data reusables.secret-scanning.secret-scanning-process %}
3636

3737
{% data reusables.repositories.navigate-to-repo %}
3838
{% data reusables.repositories.sidebar-settings %}
@@ -85,3 +85,4 @@ You can also ignore individual alerts from {% data variables.product.prodname_se
8585
### Further reading
8686

8787
- "[Managing security and analysis settings for your organization](/organizations/keeping-your-organization-secure/managing-security-and-analysis-settings-for-your-organization)"
88+
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@3.1" or currentVersion == "github-ae@next" %}- "[Defining custom patterns for {% data variables.product.prodname_secret_scanning %}](/code-security/secret-security/defining-custom-patterns-for-secret-scanning)"{% endif %}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
title: Defining custom patterns for secret scanning
3+
shortTitle: 'Defining custom patterns'
4+
intro: 'You can define custom patterns for {% data variables.product.prodname_secret_scanning %} in organizations and private repositories.'
5+
product: '{% data reusables.gated-features.secret-scanning %}'
6+
versions:
7+
free-pro-team: '*'
8+
enterprise-server: '>=3.2'
9+
github-ae: 'next'
10+
topics:
11+
- Repositories
12+
---
13+
14+
{% note %}
15+
16+
**Note:** Custom patterns for {% data variables.product.prodname_secret_scanning %} is currently in beta and is subject to change.
17+
18+
{% endnote %}
19+
20+
### About custom patterns for {% data variables.product.prodname_secret_scanning %}
21+
22+
{% data variables.product.company_short %} performs {% data variables.product.prodname_secret_scanning %} on {% if currentVersion == "free-pro-team@latest" %}public and private{% endif %} repositories for secret patterns provided by {% data variables.product.company_short %} and {% data variables.product.company_short %} partners. For more information on the {% data variables.product.prodname_secret_scanning %} partner program, see "<a href="/developers/overview/secret-scanning" class="dotcom-only">Secret scanning</a>."
23+
24+
However, there can be situations where you want to scan for other secret patterns in your {% if currentVersion == "free-pro-team@latest" %}private{% endif %} repositories. For example, you might have a secret pattern that is internal to your organization. For these situations, you can define custom {% data variables.product.prodname_secret_scanning %} patterns in organizations and {% if currentVersion == "free-pro-team@latest" %}private{% endif %} repositories on {% data variables.product.product_name %}. You can define up to 20 custom patterns for each {% if currentVersion == "free-pro-team@latest" %}private{% endif %} repository or organization.
25+
26+
{% note %}
27+
28+
**Note:** During the beta, there are some limitations when using custom patterns for {% data variables.product.prodname_secret_scanning %}:
29+
30+
* There is no dry-run functionality.
31+
* You cannot edit custom patterns after they're created. To change a pattern, you must delete it and recreate it.
32+
* There is no API for creating, editing, or deleting custom patterns. However, results for custom patterns are returned in the [secret scanning alerts API](/rest/reference/secret-scanning).
33+
34+
{% endnote %}
35+
36+
### Regular expression syntax for custom patterns
37+
38+
Custom patterns for {% data variables.product.prodname_secret_scanning %} are specified as regular expressions. {% data variables.product.prodname_secret_scanning_caps %} uses the [Hyperscan library](https://github.com/intel/hyperscan) and only supports Hyperscan regex constructs, which are a subset of PCRE syntax. Hyperscan option modifiers are not supported. For more information on Hyperscan pattern constructs, see "[Pattern support](http://intel.github.io/hyperscan/dev-reference/compilation.html#pattern-support)" in the Hyperscan documentation.
39+
40+
### Defining a custom pattern for a repository
41+
42+
Before defining a custom pattern, you must ensure that {% data variables.product.prodname_secret_scanning %} is enabled on your repository. For more information, see "[Configuring {% data variables.product.prodname_secret_scanning %} for your repositories](/code-security/secret-security/configuring-secret-scanning-for-your-repositories)."
43+
44+
{% data reusables.repositories.navigate-to-repo %}
45+
{% data reusables.repositories.sidebar-settings %}
46+
{% data reusables.repositories.navigate-to-security-and-analysis %}
47+
{% data reusables.repositories.navigate-to-ghas-settings %}
48+
{% data reusables.repositories.secret-scanning-add-custom-pattern %}
49+
50+
After your pattern is created, {% data reusables.secret-scanning.secret-scanning-process %} For more information on viewing {% data variables.product.prodname_secret_scanning %} alerts, see "[Managing alerts from {% data variables.product.prodname_secret_scanning %}](/code-security/secret-security/managing-alerts-from-secret-scanning)."
51+
52+
### Defining a custom pattern for an organization
53+
54+
Before defining a custom pattern, you must ensure that you enable {% data variables.product.prodname_secret_scanning %} for the {% if currentVersion == "free-pro-team@latest" %}private{% endif %} repositories that you want to scan in your organization. To enable {% data variables.product.prodname_secret_scanning %} on all {% if currentVersion == "free-pro-team@latest" %}private{% endif %} repositories in your organization, see "[Managing security and analysis settings for your organization](/organizations/keeping-your-organization-secure/managing-security-and-analysis-settings-for-your-organization)."
55+
56+
{% note %}
57+
58+
**Note:** There is no dry-run functionality during the custom patterns beta. To avoid excess false-positive {% data variables.product.prodname_secret_scanning %} alerts, we recommend that you test your custom patterns in a repository before defining them for your entire organization.
59+
60+
{% endnote %}
61+
62+
{% data reusables.profile.access_org %}
63+
{% data reusables.profile.org_settings %}
64+
{% data reusables.organizations.security-and-analysis %}
65+
{% data reusables.repositories.navigate-to-ghas-settings %}
66+
{% data reusables.repositories.secret-scanning-add-custom-pattern %}
67+
68+
After your pattern is created, {% data variables.product.prodname_secret_scanning %} scans for any secrets in {% if currentVersion == "free-pro-team@latest" %}private{% endif %} 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 {% data variables.product.prodname_secret_scanning %} alerts, see "[Managing alerts from {% data variables.product.prodname_secret_scanning %}](/code-security/secret-security/managing-alerts-from-secret-scanning)."
69+
70+
### Removing a custom pattern
71+
72+
Removing a custom pattern also closes all the {% data variables.product.prodname_secret_scanning %} alerts that the pattern created.
73+
74+
1. Navigate to the **Security & analysis** settings for the repository or organization where the custom pattern was created. For more information, see "[Defining a custom pattern for a repository](#defining-a-custom-pattern-for-a-repository)" or "[Defining a custom pattern for an organization](#defining-a-custom-pattern-for-an-organization)" above.
75+
{% data reusables.repositories.navigate-to-ghas-settings %}
76+
1. Under "{% data variables.product.prodname_secret_scanning_caps %}", find the custom pattern you want to remove and click **Remove**.
77+
78+
![Remove a custom {% data variables.product.prodname_secret_scanning %} pattern](/assets/images/help/repository/secret-scanning-remove-custom-pattern.png)
79+
1. Review the confirmation and click **Remove custom pattern**.

content/code-security/secret-security/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ topics:
1414
children:
1515
- /about-secret-scanning
1616
- /configuring-secret-scanning-for-your-repositories
17+
- /defining-custom-patterns-for-secret-scanning
1718
- /managing-alerts-from-secret-scanning
1819
---
1920

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1. Under "Configure security and analysis features", find "{% data variables.product.prodname_GH_advanced_security %}."
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
1. Under "{% data variables.product.prodname_secret_scanning_caps %}", click **Add a {% data variables.product.prodname_secret_scanning %} custom pattern**.
2+
3+
![Add a {% data variables.product.prodname_secret_scanning %} custom pattern](/assets/images/help/repository/secret-scanning-add-custom-pattern.png)
4+
1. Enter the details for your new custom pattern:
5+
1. You must at least provide the name for your pattern, and a regular expression for the format of your secret pattern.
6+
1. You can click **More options {% octicon "chevron-down" aria-label="down" %}** to provide other surrounding content or additional match requirements for the secret format.
7+
1. You can provide a sample test string and click the **Test** button to make sure your configuration is matching the patterns you expect.
8+
9+
![Create a custom {% data variables.product.prodname_secret_scanning %} pattern form](/assets/images/help/repository/secret-scanning-create-custom-pattern.png)
10+
1. When you are satisfied with your new custom pattern, click **Create custom pattern**.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
If someone checks a secret from a {% data variables.product.company_short %} partner into a {% if currentVersion == "free-pro-team@latest" %}public or private{% endif %} repository on {% data variables.product.product_name %}, {% data variables.product.prodname_secret_scanning %} catches the secret as it's checked in, and helps you mitigate the impact of the leak.
1+
If someone checks a secret with a known pattern into a {% if currentVersion == "free-pro-team@latest" %}public or private{% endif %} repository on {% data variables.product.product_name %}, {% data variables.product.prodname_secret_scanning %} catches the secret as it's checked in, and helps you mitigate the impact of the leak.
22
Repository administrators are notified about any commit that contains a secret, and they can quickly view all detected secrets in the Security tab for the repository.

0 commit comments

Comments
 (0)