Description
Ensure the repository's default branch has an active ruleset applied to it, establishing a baseline of protection rather than leaving the branch completely unprotected.
Rationale
Without any active ruleset, the default branch has no restrictions on direct pushes, deletions, force pushes, or unreviewed merges. A baseline ruleset is the foundation required before any of the more specific protections, such as required reviews or status checks, can be enforced.
Impact
Establishes a minimum baseline of protection for the repository's most important branch
Provides the foundation required to enforce reviews, status checks, and other controls
Reduces the risk of unrestricted direct pushes, deletions, or force pushes to production code
Supports compliance with secure software development frameworks
Default Value
By default, a newly created repository's default branch has no ruleset applied to it.
Pre-Requisites
Admin access to the repository
Test Plan
Sign in to GitHub at https://github.com.
Select the relevant repository.
Click Settings.
In the "Code, planning, and automation" section of the sidebar, click Rulesets.
Verify that an active ruleset exists whose target branches include the default branch.
If no active ruleset covers the default branch, follow the implementation steps.
Implementation Steps
Sign in to GitHub at https://github.com.
Select the relevant repository.
Click Settings.
In the "Code, planning, and automation" section of the sidebar, click Rulesets.
Click New ruleset, then New branch ruleset.
Under Ruleset Name, enter a name, and set Enforcement status to Active.
Under Target branches, click Add target, then select Include default branch.
Under Rules, select the protections appropriate to your organization's policy, such as required pull requests, status checks, and restrictions on force pushes and deletions.
Click Create.
Backout Plan
Sign in to GitHub at https://github.com.
Select the relevant repository.
Click Settings.
In the "Code, planning, and automation" section of the sidebar, click Rulesets.
Next to the ruleset targeting the default branch, click the options menu, then click Delete ruleset.
Confirm the deletion.
Reference