policy name: code_review_not_limited_to_code_owners
It is recommended to require code review only from designated individuals specified in CODEOWNERS file. Turning this option on enforces that only the allowed owners can approve a code change. This option is found in the branch protection setting of the repository.
A pull request may be approved by any contributor with write access. Specifying specific code owners can ensure review is only done by individuals with the correct expertise required for the review of the changed files, potentially preventing bugs and security risks.
- Note: The remediation steps applys to legacy branch protections, rules set based protection should be updated from the rules set page
- Make sure you have admin permissions
- Go to the repo’s settings page
- Enter “Branches” tab
- Under “Branch protection rules”
- Click “Edit” on the default branch rule
- Check “Require a pull request before merging”
- Check “Require review from Code Owners”
- Click “Save changes”