Skip to main content

Verify Branch Protection Setting

Type: Rule
ID: github-repo-branch-protection
Source: v2/rules/github/repository/branch-protection.yaml
Rego Source: branch-protection.rego
Labels: GitHub, Repository

Verify branch protection is configured in the GitHub repository.

note

This rule requires Github Repository Discovery Evidence. See here for more details.

tip

Signed Evidence for this rule IS NOT required by default but is recommended.

warning

Rule requires evaluation with a target or an asset input. Without one, it will be disabled unless the --all-evidence flag is provided.

info

Rule is scoped by product and target.

Usage example

uses: github/repository/branch-protection@v2
with:
desired_protected: true
branches:
- 'main'
- 'master'

Mitigation

Ensure branch protection settings are correctly configured to reduce the risk of unauthorized changes.

Description

This rule ensures that branch protection is configured in the GitHub repository. It performs the following steps:

  1. Checks the repository settings for branch protection.
  2. Verifies that the protection settings match the expected values.

Evidence Requirements:

  • Evidence must be provided by the Scribe Platform's CLI tool through scanning GitHub repository settings.

Evidence Requirements

FieldValue
filter-by['product', 'target']
signedFalse
content_body_typegeneric
target_typedata
predicate_typehttp://scribesecurity.com/evidence/discovery/v0.1
asset_platformgithub
asset_typerepo

Input Definitions

ParameterTypeRequiredDescriptionDefault
desired_protectedbooleanFalseDesired branch protection setting.True
branchesarrayFalseList of branches to be protected.['main', 'master']