Skip to content

Commit 828f808

Browse files
authored
EDI-fy "Working with push protection from the command line" (#59216)
1 parent 714525a commit 828f808

File tree

4 files changed

+39
-45
lines changed

4 files changed

+39
-45
lines changed

content/code-security/concepts/secret-security/about-delegated-bypass-for-push-protection.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ redirect_from:
1818
contentType: concepts
1919
---
2020

21-
## About delegated bypass for push protection
22-
2321
{% data reusables.secret-scanning.push-protection-delegate-bypass-beta-note %}
2422

23+
## About delegated bypass for push protection
24+
2525
When push protection is enabled for a repository, users with write access can bypass push protection and push a secret if they provide a reason and the bypass is approved.
2626

2727
With delegated bypass for push protection, you can:
@@ -33,7 +33,7 @@ With delegated bypass for push protection, you can:
3333

3434
To set up delegated bypass, organization owners or repository administrators create a list of users with bypass privileges. This designated list of users can then:
3535
* Bypass push protection, by specifying a reason for bypassing the block.
36-
* Manage (approve or deny) bypass requests coming from all other contributors. These requests are located in the "Push protection bypass" page in the **Security** tab of the repository.
36+
* Manage (approve or deny) bypass requests coming from all other contributors. These requests are located in the "Push protection bypass" page in the **Security** tab of the repository, and will expire after 7 days.
3737

3838
The following types of users can always bypass push protection without having to request bypass privileges:
3939
* Organization owners

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ children:
1818
- /about-delegated-bypass-for-push-protection
1919
- /about-secret-scanning-for-partners
2020
- /github-secret-types
21+
- /push-protection-from-the-command-line
2122
- /working-with-push-protection-and-the-github-mcp-server
2223
- /working-with-push-protection-from-the-rest-api
2324
redirect_from:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: Push protection from the command line
3+
shortTitle: Command line protection
4+
intro: Understand how {% data variables.product.github %} uses push protection to prevent secret leaks from the command line.
5+
permissions: '{% data reusables.permissions.push-protection-resolve-block %}'
6+
versions:
7+
fpt: '*'
8+
ghes: '*'
9+
ghec: '*'
10+
topics:
11+
- Secret scanning
12+
- Secret Protection
13+
- Alerts
14+
- Repositories
15+
contentType: concepts
16+
---
17+
18+
Push protection prevents you from accidentally committing secrets to a repository by blocking pushes containing supported secrets.
19+
20+
When you attempt to push a supported secret from the command line to a repository secured by push protection, {% data variables.product.prodname_dotcom %} will block the push.
21+
22+
You should either:
23+
24+
* **Remove** the secret from your branch. For more information, see [Resolving a blocked push](/code-security/how-tos/secure-your-secrets/work-with-leak-prevention/working-with-push-protection-from-the-command-line#resolving-a-blocked-push).
25+
* **Follow a provided URL** to see what options are available to you to allow the push. For more information, see [Bypassing push protection](/code-security/how-tos/secure-your-secrets/work-with-leak-prevention/working-with-push-protection-from-the-command-line#bypassing-push-protection) and [Requesting bypass privileges](/code-security/how-tos/secure-your-secrets/work-with-leak-prevention/working-with-push-protection-from-the-command-line#requesting-bypass-privileges).
26+
27+
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.
28+
29+
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. Real secrets that have been exposed must be revoked to avoid unauthorized access. You might consider first rotating the secret before revoking it. For more information, see [AUTOTITLE](/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository).
30+
31+
{% data reusables.secret-scanning.push-protection-multiple-branch-note %}

content/code-security/how-tos/secure-your-secrets/work-with-leak-prevention/working-with-push-protection-from-the-command-line.md

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,20 @@ redirect_from:
1717
- /code-security/secret-scanning/working-with-secret-scanning-and-push-protection/working-with-push-protection-from-the-command-line
1818
---
1919

20-
## About push protection from the command line
21-
22-
Push protection prevents you from accidentally committing secrets to a repository by blocking pushes containing supported secrets.
23-
24-
When you attempt to push a supported secret from the command line to a repository secured by push protection, {% data variables.product.prodname_dotcom %} will block the push.
25-
26-
You should either:
27-
28-
* **Remove** the secret from your branch. For more information, see [Resolving a blocked push](#resolving-a-blocked-push).
29-
* **Follow a provided URL** to see what options are available to you to allow the push. For more information, see [Bypassing push protection](#bypassing-push-protection) and [Requesting bypass privileges](#requesting-bypass-privileges).
30-
31-
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.
32-
33-
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. Real secrets that have been exposed must be revoked to avoid unauthorized access. You might consider first rotating the secret before revoking it. For more information, see [AUTOTITLE](/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository).
34-
35-
{% data reusables.secret-scanning.push-protection-multiple-branch-note %}
36-
3720
## Resolving a blocked push
3821

3922
To resolve a blocked push, you must remove the secret from all of the commits it appears in.
4023
* If the secret was introduced by your latest commit, see [Removing a secret introduced by the latest commit on your branch](#removing-a-secret-introduced-by-the-latest-commit-on-your-branch).
4124
* If the secret appears in earlier commits, see [Removing a secret introduced by an earlier commit on your branch](#removing-a-secret-introduced-by-an-earlier-commit-on-your-branch).
4225

43-
>[!NOTE] To learn how to resolved a blocked commit in the {% data variables.product.prodname_dotcom %} UI, see [AUTOTITLE](/code-security/secret-scanning/working-with-secret-scanning-and-push-protection/working-with-push-protection-in-the-github-ui#resolving-a-blocked-commit).
44-
4526
### Removing a secret introduced by the latest commit on your branch
4627

47-
If the blocked secret was introduced by the latest commit on your branch, you can follow the guidance below.
48-
4928
1. Remove the secret from your code.
5029
1. To commit the changes, run `git commit --amend --all`. This updates the original commit that introduced the secret instead of creating a new commit.
5130
1. Push your changes with `git push`.
5231

5332
### Removing a secret introduced by an earlier commit on your branch
5433

55-
You can also remove the secret if the secret appears in an earlier commit in the Git history. To do so, you will need to identify which commit first introduced the secret and modify the commit history with an interactive rebase.
56-
5734
1. Examine the error message that displayed when you tried to push your branch, which lists all of the commits that contain the secret.
5835

5936
```text
@@ -121,13 +98,7 @@ You can also remove the secret if the secret appears in an earlier commit in the
12198

12299
## Bypassing push protection
123100

124-
If {% data variables.product.prodname_dotcom %} blocks a secret that you believe is safe to push, you may be able to bypass the block by specifying a reason for allowing the secret to be pushed.
125-
126-
{% data reusables.secret-scanning.push-protection-allow-secrets-alerts %}
127-
128-
{% data reusables.secret-scanning.push-protection-allow-email %}
129-
130-
If you don't see the option to bypass the block, the repository administrator or organization owner has configured tighter controls around push protection. Instead, you should remove the secret from the commit, or submit a request for "bypass privileges" in order to push the blocked secret. For more information, see [Requesting bypass privileges](/code-security/secret-scanning/working-with-secret-scanning-and-push-protection/working-with-push-protection-from-the-command-line#requesting-bypass-privileges).
101+
> [!NOTE] If you don't see the option to bypass a block, you should remove the secret from the commit, or submit a request for "bypass privileges" in order to push the blocked secret. See [Requesting bypass privileges](#requesting-bypass-privileges).
131102
132103
{% data reusables.secret-scanning.push-protection-visit-URL %}
133104
{% data reusables.secret-scanning.push-protection-choose-allow-secret-options %}
@@ -137,22 +108,13 @@ If you don't see the option to bypass the block, the repository administrator or
137108

138109
## Requesting bypass privileges
139110

140-
{% data reusables.secret-scanning.push-protection-delegate-bypass-beta-note %}
141-
142-
If your push has been blocked by push protection and you believe the secret is safe to push, you can request permission to bypass the block. Your request is sent to a designated group of reviewers, who will either approve or deny the request.
143-
144-
Requests expire after 7 days.
145-
146111
{% data reusables.secret-scanning.push-protection-visit-URL %}
147112
{% data reusables.secret-scanning.push-protection-bypass-request-add-comment %}
148113
{% data reusables.secret-scanning.push-protection-submit-bypass-request %}
149-
{% data reusables.secret-scanning.push-protection-bypass-request-check-email %}
150-
151-
{% data reusables.secret-scanning.push-protection-bypass-request-decision-email %}
152-
153-
If your request is approved, you can push the commit (or commits) containing the secret to the repository, as well as any future commits that contain the same secret.
114+
{% data reusables.secret-scanning.push-protection-bypass-request-check-email %} {% data reusables.secret-scanning.push-protection-bypass-request-decision-email %}
154115

155-
If your request is denied, you will need to remove the secret from all commits containing the secret before pushing again. For information on how to remove a blocked secret, see [Resolving a blocked push](#resolving-a-blocked-push).
116+
* If your request is **approved**, you can push the commit (or commits) containing the secret to the repository, as well as any future commits that contain the same secret.
117+
* If your request is **denied**, you need to remove the secret from all commits before pushing again. For information on how to remove a blocked secret, see [Resolving a blocked push](#resolving-a-blocked-push).
156118

157119
## Further reading
158120

0 commit comments

Comments
 (0)