Skip to main content

CI/CD provider

ISSUE-501CriticalAccess and Authorization

Branch protection missing

Control: Branch must be protectedยท Config key: branchMustBeProtected

๐Ÿ“‹ What is this?

A branch is not protected on the repository.

โš ๏ธ Impact

Unprotected branches are highly vulnerable to unauthorized modifications. For instance, any member can push malicious code directly to your production branch without any review or validation.

๐Ÿ”ง How to fix

Enable branch protection on the branch to restrict changes to authorized users only.

โœ— BeforeThe `main` branch has no protection, violating the policy.
# GitLab project settings: โŒ Branch not protected
# Branch "main" has no protection rules
# Anyone with Developer access can:
# - Push directly
# - Force push
# - Delete the branch
# .plumber.yaml configuration requiring protection:
branchMustBeProtected:
enabled: true
defaultMustBeProtected: true
namePatterns:
- main
- release/*
โœ“ AfterProper branch protection with restricted push access and code review requirements.
# GitLab project settings: โœ… Branch properly protected
# Settings > Repository > Protected Branches:
#
# Branch: main
# Allowed to merge: Developers + Maintainers
# Allowed to push: Maintainers
# Allow force push: No
# Code owner approval required: Yes
# .plumber.yaml
branchMustBeProtected:
enabled: true
defaultMustBeProtected: true
namePatterns:
- main
- release/*
allowForcePush: false
codeOwnerApprovalRequired: true
minMergeAccessLevel: 30 # Developer
minPushAccessLevel: 40 # Maintainer

๐Ÿ’ก Tips

  • Use namePatterns with wildcards to protect branch families (e.g., release/*).
  • Set minPushAccessLevel: 40 (Maintainer) to prevent developers from pushing directly.
  • Enable codeOwnerApprovalRequired if you use a CODEOWNERS file.

โš™๏ธ Configuration

This control is configured in .plumber.yaml under the gitlab section:

gitlab:
  controls:
    branchMustBeProtected:
      enabled: true

See the CLI documentation for the full configuration reference. On Plumber Platform, the same key is used in your policy configuration.