code.repo.default-branch-protected
Default branches accept changes only through reviewed pull requests
The default branch of every repository rejects direct pushes, requires an approved pull request, and requires the CI status checks to pass.
Assertion
exists protection p for the default branch: p.enable_push == false and p.required_approvals >= 1 and p.enable_status_check == true and p.block_on_rejected_reviews == trueRationale
The default branch is what gets deployed. If it can be pushed to directly, then review, CI, and every check that runs on a pull request are optional, and a single compromised account or careless command puts unreviewed code into production. Branch protection is where “changes are reviewed” stops being a habit and becomes something the forge enforces.
Observation
The collector calls the forge API for each repository’s branch protection rules and finds the one that matches the default branch. The assertion requires four things of it: direct pushes are disabled, at least one approval is required, status checks are required, and a rejected review blocks the merge. A repository with no matching rule fails; so does one whose rule allows a push whitelist, because a whitelist is a direct push for some people.
Remediation
In the repository settings, add a branch protection rule for the default branch with push disabled, one required approval, status checks required with the CI workflow named as a required context, and merges blocked on rejected reviews. Repositories are created from a template that carries this rule, so new repositories pass from their first commit.