Description:
This control ensures that pull requests cannot be merged into protected branches until they have received the required number of approvals from authorized reviewers. The review process helps validate code quality, security, and compliance with organizational standards before changes are integrated.
Rationale:
Requiring review approvals before merging pull requests enforces peer review and segregation of duties, reducing the risk of introducing defects, security vulnerabilities, or unauthorized changes into protected branches. It also promotes accountability, collaboration, and knowledge sharing among development teams.
Impact:
Prevents unreviewed code from being merged into protected branches.
Improves code quality, maintainability, and security.
Supports organizational change management and compliance requirements.
Promotes peer review and accountability.
May increase the time required to merge pull requests due to the review process.
Default Value:
Disabled by default. Repository administrators must explicitly configure pull request review requirements to require approval before merge.
Remediation
Test Plan
Navigate to the target GitHub repository.
Create a pull request against a protected branch.
Attempt to merge the pull request without obtaining the required approval(s).
Verify that the merge is blocked.
Obtain the required approval(s) from an authorized reviewer.
Attempt to merge the pull request again.
Verify that pull request approvals are configured and enforced before merge.
If pull request approvals are not configured or enforced, follow the Implementation Plan to remediate the issue and repeat the test.
Implementation Steps:
Sign in to GitHub with administrative access to the repository.
Navigate to the target repository.
Select Settings.
Under Code and automation, select Rules → Rulesets.
Click New ruleset and select New branch ruleset, or edit an existing branch ruleset.
Enter a name for the ruleset.
Under Enforcement status, select Active.
Under Target branches, specify the branch or branch pattern to protect (e.g., main).
In the Rules section, enable Require a pull request before merging.
Configure the Required approvals setting and specify the minimum number of approving reviews required before a pull request can be merged.
Configure any additional review requirements as required by organizational policy.
Click Create to apply the ruleset.
Backout Plan:
Sign in to GitHub with administrative access to the repository.
Navigate to the target repository.
Select Settings.
Under Code and automation, select Rules → Rulesets.
Edit the applicable branch ruleset.
Reduce the Required approvals value or disable Require a pull request before merging.
Click Save changes.
Verify that pull requests can be merged according to the updated configuration.
References: