Skip to content

Commit f196993

Browse files
authored
Merge pull request #26367 from github/mchammer01/push-protection-public
[Shipping April 4] Secret scanning - push protection (public beta)
2 parents 02dfed4 + 2a35e1f commit f196993

18 files changed

+192
-5
lines changed
Loading
Loading
Loading
Loading

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ If your project communicates with an external service, you might use a token or
3838

3939
Service providers can partner with {% data variables.product.company_short %} to provide their secret formats for scanning. {% data reusables.secret-scanning.partner-program-link %}
4040

41+
{% if secret-scanning-push-protection %}
42+
43+
You can also enable {% data variables.product.prodname_secret_scanning %} as a push protection for a repository or an organization. When you enable this feature, {% data variables.product.prodname_secret_scanning %} prevents contributors from pushing code with a detected secret. To proceed, contributors must either remove the secret(s) from the push or, if needed, bypass the protection. For more information, see "[Protecting pushes with {% data variables.product.prodname_secret_scanning %}](/code-security/secret-scanning/protecting-pushes-with-secret-scanning)."
44+
45+
{% endif %}
46+
47+
4148
{% ifversion fpt or ghec %}
4249
## About {% data variables.product.prodname_secret_scanning_partner %}
4350

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ You can enable {% data variables.product.prodname_secret_scanning_GHAS %} for an
3535
5. Review the impact of enabling {% data variables.product.prodname_advanced_security %}, then click **Enable {% data variables.product.prodname_GH_advanced_security %} for this repository**.
3636
6. When you enable {% data variables.product.prodname_advanced_security %}, {% data variables.product.prodname_secret_scanning %} may automatically be enabled for the repository due to the organization's settings. If "{% data variables.product.prodname_secret_scanning_caps %}" is shown with an **Enable** button, you still need to enable {% data variables.product.prodname_secret_scanning %} by clicking **Enable**. If you see a **Disable** button, {% data variables.product.prodname_secret_scanning %} is already enabled.
3737
![Enable {% data variables.product.prodname_secret_scanning %} for your repository](/assets/images/help/repository/enable-secret-scanning-dotcom.png)
38-
38+
{% if secret-scanning-push-protection %}
39+
7. Optionally, if you want to enable push protection, click **Enable** to the right of "Push protection." {% data reusables.secret-scanning.push-protection-overview %} For more information, see "[Protecting pushes with {% data variables.product.prodname_secret_scanning %}](/code-security/secret-scanning/protecting-pushes-with-secret-scanning)."
40+
![Enable push protection for your repository](/assets/images/help/repository/secret-scanning-enable-push-protection.png)
41+
{% endif %}
3942
{% ifversion ghae %}
4043
1. Before you can enable {% data variables.product.prodname_secret_scanning %}, you need to enable {% data variables.product.prodname_GH_advanced_security %} first. To the right of "{% data variables.product.prodname_GH_advanced_security %}", click **Enable**.
4144
![Enable {% data variables.product.prodname_GH_advanced_security %} for your repository](/assets/images/enterprise/github-ae/repository/enable-ghas-ghae.png)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ children:
2020
- /defining-custom-patterns-for-secret-scanning
2121
- /managing-alerts-from-secret-scanning
2222
- /secret-scanning-patterns
23+
- /protecting-pushes-with-secret-scanning
2324
---
2425

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
title: Protecting pushes with secret scanning
3+
intro: 'You can use {% data variables.product.prodname_secret_scanning %} to prevent supported secrets from being pushed into your organization or repository by enabling push protection.'
4+
product: '{% data reusables.gated-features.secret-scanning %}'
5+
miniTocMaxHeadingLevel: 3
6+
versions:
7+
feature: 'secret-scanning-push-protection'
8+
redirect_from:
9+
- /early-access/code-security/secret-scanning/protecting-pushes-with-secret-scanning
10+
type: how_to
11+
topics:
12+
- Secret scanning
13+
- Advanced Security
14+
- Alerts
15+
- Repositories
16+
shortTitle: Push protection
17+
---
18+
19+
{% data reusables.secret-scanning.beta %}
20+
{% data reusables.secret-scanning.enterprise-enable-secret-scanning %}
21+
{% data reusables.secret-scanning.push-protection-beta %}
22+
23+
## About push protection for secrets
24+
25+
Up to now, {% data variables.product.prodname_secret_scanning_GHAS %} checks for secrets _after_ a push and alerts users to exposed secrets. {% data reusables.secret-scanning.push-protection-overview %}
26+
27+
{% data variables.product.prodname_secret_scanning_caps %} as a push protection currently scans repositories for secrets issued by the following service providers.
28+
29+
{% data reusables.secret-scanning.secret-list-private-push-protection %}
30+
31+
## Enabling {% data variables.product.prodname_secret_scanning %} as a push protection
32+
33+
For you to use {% data variables.product.prodname_secret_scanning %} as a push protection, the organization or repository needs to have both {% data variables.product.prodname_GH_advanced_security %} and {% data variables.product.prodname_secret_scanning %} enabled. For more information, see "[Managing security and analysis settings for your organization](/organizations/keeping-your-organization-secure/managing-security-and-analysis-settings-for-your-organization)," "[Managing security and analysis settings for your repository](/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-security-and-analysis-settings-for-your-repository)," and "[About {% data variables.product.prodname_GH_advanced_security %}](/get-started/learning-about-github/about-github-advanced-security)."
34+
35+
Organization owners, security managers, and repository administrators can enable push protection for {% data variables.product.prodname_secret_scanning %} via the UI and API. For more information, see "[Repositories](/rest/reference/repos#update-a-repository)" and expand the "Properties of the `security_and_analysis` object" section in the REST API documentation.
36+
37+
### Enabling {% data variables.product.prodname_secret_scanning %} as a push protection for an organization
38+
39+
{% data reusables.organizations.navigate-to-org %}
40+
{% data reusables.organizations.org_settings %}
41+
{% data reusables.organizations.security-and-analysis %}
42+
{% data reusables.repositories.navigate-to-ghas-settings %}
43+
{% data reusables.advanced-security.secret-scanning-push-protection-org %}
44+
45+
### Enabling {% data variables.product.prodname_secret_scanning %} as a push protection for a repository
46+
47+
{% data reusables.repositories.navigate-to-repo %}
48+
{% data reusables.repositories.sidebar-settings %}
49+
{% data reusables.repositories.navigate-to-security-and-analysis %}
50+
{% data reusables.repositories.navigate-to-ghas-settings %}
51+
{% data reusables.advanced-security.secret-scanning-push-protection-repo %}
52+
53+
54+
## Using {% data variables.product.prodname_secret_scanning %} as a push protection from the command line
55+
56+
When you attempt to push a supported secret to a repository or organization with {% data variables.product.prodname_secret_scanning %} as a push protection enabled, {% data variables.product.prodname_dotcom %} will block the push. You can remove the secret from your commit or follow a provided URL to allow the push.
57+
58+
Up to five detected secrets will be displayed at a time on the command line. If a particular secret has already been detected in the repository and an alert already exists, {% data variables.product.prodname_dotcom %} will not block that secret.
59+
60+
![Screenshot showing that a push is blocked when a user attempts to push a secret to a repository](/assets/images/help/repository/secret-scanning-push-protection-with-link.png)
61+
62+
If you need to remove the secret from your latest commit (that is, `HEAD`) on the branch being pushed and any earlier commits that contain the secret, you can remove the secret from `HEAD`, then squash the commits between when the commit was introduced and the first version of `HEAD` for which the secret has been removed.
63+
64+
{% note %}
65+
66+
**Notes**:
67+
68+
* If your git configuration supports pushes to multiple branches, and not only to the default branch, your push may be blocked due to additional and unintended refs being pushed. For more information, see the [`push.default` options](https://git-scm.com/docs/git-config#Documentation/git-config.txt-pushdefault) in the Git Docs.
69+
* If {% data variables.product.prodname_secret_scanning %} upon a push times out, {% data variables.product.prodname_dotcom %} will still run a scan after the push.
70+
71+
{% endnote %}
72+
73+
### Allowing a blocked secret to be pushed
74+
75+
If {% data variables.product.prodname_dotcom %} blocks a secret that you believe is safe to push, you can allow the secret and specify the reason why it should be allowed.
76+
77+
If you confirm a secret is real and that you intend to fix it later, you should aim to remediate the secret as soon as possible. For example, you might revoke the secret and remove the secret from the repository's commit history. For more information, see "[Removing sensitive data from a repository](/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository)."
78+
79+
When you allow a secret to be pushed, an alert is created in the "Security" tab. The alert is closed and no notifications are sent if you specify that the secret is a false positive or used only in tests. If you specify that the secret is real and that you will fix it later, the security alert remains open and notifications are sent to the author of the commit and repository administrators. For more information, see "[Managing alerts from secret scanning](/code-security/secret-scanning/managing-alerts-from-secret-scanning)."
80+
81+
1. Visit the URL returned by {% data variables.product.prodname_dotcom %} when your push was blocked.
82+
![Screenshot showing form with options for unblocking the push of a secret](/assets/images/help/repository/secret-scanning-unblock-form.png)
83+
2. Choose the option that best describes why you should be able to push the secret.
84+
- If the secret is only used in tests and poses no threat, click **It's used in tests**.
85+
- If the detected string is not a secret, click **It's a false positive**.
86+
- If the secret is real but you intend to fix it later, click **I'll fix it later**.
87+
3. Click **Allow me to push this secret**.
88+
4. Reattempt the push on the command line within three hours. If you have not pushed within three hours, you will need to repeat this process.

content/get-started/learning-about-github/about-github-advanced-security.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ A {% data variables.product.prodname_GH_advanced_security %} license provides th
2626

2727
- **{% data variables.product.prodname_code_scanning_capc %}** - Search for potential security vulnerabilities and coding errors in your code. For more information, see "[About {% data variables.product.prodname_code_scanning %}](/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/about-code-scanning)."
2828

29-
- **{% data variables.product.prodname_secret_scanning_caps %}** - Detect secrets, for example keys and tokens, that have been checked into the repository. For more information, see "[About {% data variables.product.prodname_secret_scanning %}](/code-security/secret-scanning/about-secret-scanning)."
29+
- **{% data variables.product.prodname_secret_scanning_caps %}** - Detect secrets, for example keys and tokens, that have been checked into the repository.{% if secret-scanning-push-protection %} If push protection is enabled, also detects secrets when they are pushed to your repository. For more information, see "[About {% data variables.product.prodname_secret_scanning %}](/code-security/secret-scanning/about-secret-scanning)" and "[Protecting pushes with {% data variables.product.prodname_secret_scanning %}](/code-security/secret-scanning/protecting-pushes-with-secret-scanning)."{% else %} For more information, see "[About {% data variables.product.prodname_secret_scanning %}](/code-security/secret-scanning/about-secret-scanning)."{% endif %}
3030

3131
{% ifversion fpt or ghes > 3.1 or ghec or ghae-issue-4864 %}
3232
- **Dependency review** - Show the full impact of changes to dependencies and see details of any vulnerable versions before you merge a pull request. For more information, see "[About dependency review](/code-security/supply-chain-security/about-dependency-review)."
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Reference: #5620.
2+
# Documentation for secret scanning as a push protection
3+
versions:
4+
ghes: '>=3.5'
5+
ghae: 'issue-5620'
6+
ghec: '*'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1. Under "{% data variables.product.prodname_secret_scanning_caps %}", under "Push protection", click **Enable all**.
2+
![Screenshot showing how to enable push protection for {% data variables.product.prodname_secret_scanning %} for an organization](/assets/images/help/organizations/secret-scanning-enable-push-protection.png)
3+
1. Optionally, click "Automatically enable for private repositories added to {% data variables.product.prodname_secret_scanning %}."
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1. Under "{% data variables.product.prodname_secret_scanning_caps %}", under "Push protection", click **Enable**.
2+
![Screenshot showing how to enable push protection for {% data variables.product.prodname_secret_scanning %} for a repository](/assets/images/help/repository/secret-scanning-enable-push-protection.png)

data/reusables/gated-features/secret-scanning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!--This reusable describes the GHAS secret scanning feature. For a reusable that also covers the free secret scanning for public repositories on GitHub.com, use `secret-scanning-parter.md` -->
1+
<!--This reusable describes the GHAS secret scanning feature. For a reusable that also covers the free secret scanning for public repositories on GitHub.com, use `secret-scanning-partner.md` -->
22

33
{%- ifversion ghec or ghes %}
44
{% data variables.product.prodname_secret_scanning_GHAS_caps %} is available for organization-owned repositories in {% data variables.product.product_name %} if your enterprise has a license for {% data variables.product.prodname_GH_advanced_security %}.

data/reusables/rest-reference/secret-scanning/secret-scanning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The {% data variables.product.prodname_secret_scanning %} API lets you{% ifversion fpt or ghec or ghes > 3.1 or ghae %}:
44

5-
- Enable or disable {% data variables.product.prodname_secret_scanning %} for a repository. For more information, see "[Repositories](/rest/reference/repos#update-a-repository)" in the REST API documentation.
5+
- Enable or disable {% data variables.product.prodname_secret_scanning %}{% if secret-scanning-push-protection %} and push protection{% endif %} for a repository. For more information, see "[Repositories](/rest/reference/repos#update-a-repository)" and expand the "Properties of the `security_and_analysis` object" section in the REST API documentation.
66
- Retrieve and update {% data variables.product.prodname_secret_scanning_GHAS %} alerts from a repository. For further details, see the sections below.
77
{%- else %} retrieve and update {% data variables.product.prodname_secret_scanning %} alerts from a repository.{% endif %}
88

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% ifversion fpt or ghec %}
22
To find out about our partner program, see "[{% data variables.product.prodname_secret_scanning_caps %} partner program](/developers/overview/secret-scanning-partner-program)."
33
{% else %}
4-
To find out about our partner program, see "[{% data variables.product.prodname_secret_scanning_caps %} partner program](/free-pro-team@latest/developers/overview/secret-scanning-partner-program)" in the {% data variables.product.prodname_ghe_cloud %} documentation
4+
To find out about our partner program, see "[{% data variables.product.prodname_secret_scanning_caps %} partner program](/enterprise-cloud@latest/developers/overview/secret-scanning-partner-program)" in the {% data variables.product.prodname_ghe_cloud %} documentation.
55
{% endif %}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% note %}
2+
3+
**Note:** {% data variables.product.prodname_secret_scanning_caps %} as a protection push is currently in beta and subject to change. To request access to the beta release, [contact your account management team](https://github.com/enterprise/contact).
4+
5+
{% endnote %}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
When you enable push protection, {% data variables.product.prodname_secret_scanning %} also checks pushes for high-confidence secrets (those identified with a low false positive rate). {% data variables.product.prodname_secret_scanning_caps %} lists any secrets it detects so the author can review the secrets and remove them or, if needed, allow those secrets to be pushed.

0 commit comments

Comments
 (0)