You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
Copy file name to clipboardExpand all lines: content/code-security/how-tos/scan-code-for-vulnerabilities/manage-your-configuration/set-code-scanning-merge-protection.md
+1-22Lines changed: 1 addition & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Set code scanning merge protection
3
3
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.'
5
5
permissions: '{% data reusables.permissions.security-org-enable %}'
6
6
product: '{% data reusables.gated-features.code-scanning %}'
7
7
versions:
@@ -16,27 +16,6 @@ redirect_from:
16
16
contentType: how-tos
17
17
---
18
18
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
-
40
19
## Creating a merge protection ruleset for a repository
41
20
42
21
{% data reusables.repositories.navigate-to-repo %}
0 commit comments