Skip to content

feat: recognize rulesets in branch protection#842

Open
bmendonca3 wants to merge 1 commit into
ossf:mainfrom
bmendonca3:feat-branch-rulesets
Open

feat: recognize rulesets in branch protection#842
bmendonca3 wants to merge 1 commit into
ossf:mainfrom
bmendonca3:feat-branch-rulesets

Conversation

@bmendonca3

Copy link
Copy Markdown

Summary

Adds Check-only Repository Rulesets support to the existing Branch Protection policy.

This keeps the existing classic branch protection behavior, but when a branch is missing or incomplete under classic branch protection, Allstar also checks the active rules returned by Repositories.GetRulesForBranch.

The policy now recognizes direct ruleset equivalents for:

  • pull request reviews
  • required approving review count
  • stale review dismissal
  • code owner reviews
  • required status checks
  • strict/up-to-date status checks
  • signed commits
  • non-fast-forward protection

This intentionally does not add Fix/CRUD support for rulesets. The existing fix action still updates classic branch protection only.

Fixes #475

Testing

  • PATH=/tmp/go/bin:$PATH go test ./pkg/policies/branch
  • PATH=/tmp/go/bin:$PATH go test ./pkg/policies/...
  • PATH=/tmp/go/bin:$PATH go test ./...
  • PATH=/tmp/go/bin:$PATH go vet ./...
  • PATH=/tmp/go/bin:$PATH go build ./...
  • PATH=/tmp/go/bin:$PATH /tmp/go-tools/golangci-lint run --timeout 5m --verbose
  • git diff --check

Live validation

Validated against a disposable public repository:
https://github.com/bmendonca3/allstar-rulesets-validation-20260528154925

Before creating a ruleset:

  • active branch rules: pull_request=0 status_checks=0 non_fast_forward=0 required_signatures=0
  • Allstar Check result: enabled=true pass=false
  • notify text: No protection found for branch main

After creating an active ruleset for main with pull request review and non-fast-forward rules:

  • active branch rules: pull_request=1 status_checks=0 non_fast_forward=1 required_signatures=0
  • Allstar Check result: enabled=true pass=true
  • notify text: empty

Scope note

Rulesets are not used to satisfy enforceOnAdmins, because rulesets model bypass behavior differently than classic branch protection.

Signed-off-by: bmendonca3 <208517100+bmendonca3@users.noreply.github.com>
@bmendonca3 bmendonca3 requested a review from a team as a code owner May 28, 2026 22:54
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 28, 2026

@justaugustus justaugustus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See note about AI contributions —> #841 (comment)

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

This pull request has been marked stale because it has been open for 10 days with no activity

@github-actions github-actions Bot added the Stale label Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files. Stale

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Check rulesets for branch protection rules

2 participants