Description
This check verifies that Bitbucket repositories are configured to require at least one approval before a pull request can be merged. This control ensures that code changes are reviewed by another team member before being incorporated into the target branch.
Note: Only repository-level branch restrictions are detected. Restrictions set only at the project level are not returned by Bitbucket’s API and will result in a FAIL. Configure the restriction at the repository level for accurate results.
Rationale
Requiring at least one reviewer approval helps improve code quality, detect defects early, enforce development standards, and reduce the risk of introducing security vulnerabilities or unauthorized changes. Peer review also promotes knowledge sharing and accountability within development teams.
Impact
Increase the time required to merge pull requests.
Require developers to obtain approval from another contributor before merging changes.
Improve code quality and governance.
Reduce the likelihood of defects and security issues reaching production environments.
Default Value
By default, Bitbucket does not require pull request approvals before merge. Repository administrators must configure merge checks to enforce approval requirements.
Pre-Requisites
Access to the repository
An existing Bitbucket repository
Test Plan
Sign in to Bitbucket at https://bitbucket.org.
Navigate to the target repository.
Select Repository settings.
Under Workflow, click Branch Restriction.
Review the existing or create a new Branch Restriction configuration.
Verify that the minimum number of approvals is enabled.
Confirm that the value is configured as 1 or greater.
If a branch protection rule is not created with the minimum number of approvals, follow the implementation steps
Expected Result: The repository requires at least one approval before a pull request can be merged.
Implementation Steps
Sign in to Bitbucket at https://bitbucket.org.
Navigate to the target repository.
Select Repository settings.
Under Workflow, click Branch Restriction
Review the existing or create a new Branch Restriction configuration.
In the branch Restriction,Select by branch name or pattern add “*” value (it will include all branches) .
In the merge settings, check box the Minimum number of approvals value would be 1 or greater than 1.
Save the configuration.
Backout Plan
Sign in to Bitbucket at https://bitbucket.org.
If this configuration was enabled as part of the remediation and needs to be reverted:
Log in to Bitbucket with access to the repository.
Navigate to the target repository.
Select Repository settings.
Under Workflow, click Branch Restriction.Edit the branch restriction.
Locate the Minimum number of approvals setting.
Disable the setting or change the value to 0 according to organizational requirements.
Save the configuration.
Confirm normal repository operations after the rollback.
Reference
https://support.atlassian.com/bitbucket-cloud/docs/checks-for-merging-pull-requests/
https://support.atlassian.com/bitbucket-cloud/docs/work-with-pull-requests/
https://support.atlassian.com/bitbucket-cloud/docs/configure-a-projects-merge-strategies-and-checks/