Skip to content

Commit 473aa11

Browse files
[EDI] Set code scanning merge protection (#59575)
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
1 parent 3b1bff9 commit 473aa11

4 files changed

Lines changed: 51 additions & 25 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ children:
1818
- /setup-types
1919
- /about-integration-with-code-scanning
2020
- /sarif-files
21+
- /merge-protection
2122
- /codeql
2223
---
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: Code scanning merge protection
3+
shortTitle: Merge protection
4+
intro: Code scanning rules prevent pull requests with potential vulnerabilities from being merged.
5+
topics:
6+
- Code Security
7+
- Code scanning
8+
product: 'Rulesets are available in public repositories with {% data variables.product.prodname_free_user %} and {% data variables.product.prodname_free_team %} for organizations, and in public and private repositories with {% data variables.product.prodname_pro %}, {% data variables.product.prodname_team %}, and {% data variables.product.prodname_ghe_cloud %}. {% data reusables.gated-features.more-info %}'
9+
permissions: 'Repository administrators and organization owners'
10+
versions:
11+
fpt: '*'
12+
ghes: '*'
13+
ghec: '*'
14+
contentType: concepts
15+
---
16+
17+
## Rulesets for {% data variables.product.prodname_code_scanning %} merge protection
18+
19+
A ruleset is a named list of rules that control how people can interact with branches and tags in your repositories. You can add {% data variables.product.prodname_code_scanning %} rules to rulesets to prevent pull requests from being merged when any of the following conditions are met:
20+
21+
{% data reusables.code-scanning.merge-protection-rulesets-conditions %}
22+
23+
Typically, you should use {% data variables.product.prodname_code_scanning %} merge protection on long-lived feature branches, where you want to guarantee code has been analyzed before pull requests can be merged.
24+
25+
Configuring a {% data variables.product.prodname_code_scanning %} rule will not automatically enable {% data variables.product.prodname_code_scanning %}. To learn how to enable code scanning, see [AUTOTITLE](/code-security/code-scanning/enabling-code-scanning/configuring-default-setup-for-code-scanning).
26+
27+
> [!NOTE]
28+
> * Merge protection with rulesets is not related to status checks. For more information about status checks, see [AUTOTITLE](/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/about-status-checks).
29+
30+
## Availability
31+
32+
You can set {% data variables.product.prodname_code_scanning %} merge protection with rulesets:
33+
* At the repository level
34+
* At the organization level ({% data variables.product.prodname_enterprise %} plans only)
35+
36+
## Exceptions and limitations
37+
38+
Merge protection with rulesets will **not apply** to:
39+
* Merge queue groups
40+
* {% data variables.product.prodname_dependabot %} pull requests analyzed by default setup
41+
42+
Additionally, all the lines of code identified by an alert must exist in the pull request diff. For more information, see [AUTOTITLE](/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning#source-file-locations).
43+
44+
## Next steps
45+
46+
To configure a ruleset that requires {% data variables.product.prodname_code_scanning %} results, see [AUTOTITLE](/code-security/how-tos/scan-code-for-vulnerabilities/manage-your-configuration/set-code-scanning-merge-protection).

content/code-security/how-tos/scan-code-for-vulnerabilities/manage-your-configuration/set-code-scanning-merge-protection.md

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Set code scanning merge protection
33
shortTitle: Set merge protection
4-
intro: You can use rulesets to set {% data variables.product.prodname_code_scanning %} merge protection for pull requests.
4+
intro: 'Secure your codebase by blocking pull requests that fail {% data variables.product.prodname_code_scanning %} checks.'
55
permissions: '{% data reusables.permissions.security-org-enable %}'
66
product: '{% data reusables.gated-features.code-scanning %}'
77
versions:
@@ -16,27 +16,6 @@ redirect_from:
1616
contentType: how-tos
1717
---
1818

19-
## About using rulesets for {% data variables.product.prodname_code_scanning %} merge protection
20-
21-
> [!NOTE]
22-
> * Merge protection with rulesets is not related to status checks. For more information about status checks, see [AUTOTITLE](/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/about-status-checks).
23-
> * Merge protection with rulesets will not apply to merge queue groups or {% data variables.product.prodname_dependabot %} pull requests analyzed by default setup.
24-
> * All the lines of code identified by an alert must exist in the pull request diff. For more information, see [AUTOTITLE](/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning#source-file-locations).
25-
26-
You can use rulesets to prevent pull requests from being merged when one of the following conditions is met:
27-
28-
{% data reusables.code-scanning.merge-protection-rulesets-conditions %}
29-
30-
Typically you should use rulesets target long-lived feature branches, where you would like to guarantee that code has been analyzed before pull requests can be merged.
31-
32-
Configuring a {% data variables.product.prodname_code_scanning %} rule will not automatically enable {% data variables.product.prodname_code_scanning %}. For more information about how to enable code scanning, see [AUTOTITLE](/code-security/code-scanning/enabling-code-scanning/configuring-default-setup-for-code-scanning).
33-
34-
For more information about {% data variables.product.prodname_code_scanning %} alerts, see [AUTOTITLE](/code-security/code-scanning/managing-code-scanning-alerts/about-code-scanning-alerts).
35-
36-
You can set merge protection with rulesets at the repository {% ifversion ghec or ghes %}or organization levels{% else %}level{% endif %}, and for repositories configured with either default setup or advanced setup. You can also use the REST API to set merge protection with rulesets.
37-
38-
For more information about rulesets, see [AUTOTITLE](/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/about-rulesets).
39-
4019
## Creating a merge protection ruleset for a repository
4120

4221
{% data reusables.repositories.navigate-to-repo %}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
* A required tool found a {% data variables.product.prodname_code_scanning %} alert of a severity that is defined in a ruleset.
2-
* A required {% data variables.product.prodname_code_scanning %} tool's analysis is still in progress.
3-
* A required {% data variables.product.prodname_code_scanning %} tool is not configured for the repository.
1+
* A required tool finds a {% data variables.product.prodname_code_scanning %} alert of a severity that is defined in the ruleset.
2+
* A required tool's analysis is still in progress.
3+
* A required tool is not configured for the repository.

0 commit comments

Comments
 (0)