KEMBAR78
:bug: Skip tag-only rulesets during Branch-Protection by trask · Pull Request #4699 · ossf/scorecard · GitHub
Skip to content

Conversation

trask
Copy link
Contributor

@trask trask commented Jul 10, 2025

Problem

Scorecard was incorrectly applying repository rulesets that target tags to branch protection analysis. This caused false positive warnings about admin enforcement when a repository had:

  • Tag-only rulesets with bypass actors (targeting tags, not branches)
  • Proper branch protection rules that do enforce admin compliance

The issue occurred because the repoRuleSet struct was missing the Target field from the GraphQL query, causing all rulesets to be treated as if they applied to branches.

Solution

  1. Added missing Target field to the repoRuleSet struct to capture the ruleset target from GitHub's GraphQL API
  2. Updated rulesMatchingBranch function to filter out rulesets where Target != "branch"
  3. Updated GraphQL query to include the target field in the rulesets query

Testing

Verified the fix by running Scorecard against the https://github.com/open-telemetry/opentelemetry-java-contrib repository.

@trask trask requested a review from a team as a code owner July 10, 2025 03:21
@trask trask requested review from raghavkaul and spencerschrock and removed request for a team July 10, 2025 03:21
@spencerschrock
Copy link
Member

spencerschrock commented Jul 10, 2025

incorrectly applying repository rulesets that target tags to branch protection analysis

We do have some feature requests for this kind of analysis though. Both are requested as new checks, so perhaps re-enabling tag analysis is a problem for another day/place

#10
#2476

@trask
Copy link
Contributor Author

trask commented Jul 10, 2025

We do have some feature requests for this kind of analysis though

makes sense, I made some updates to make it more future proof for when those features land

@codecov
Copy link

codecov bot commented Jul 14, 2025

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 68.29%. Comparing base (353ed60) to head (244a329).
Report is 194 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4699      +/-   ##
==========================================
+ Coverage   66.80%   68.29%   +1.49%     
==========================================
  Files         230      249      +19     
  Lines       16602    18898    +2296     
==========================================
+ Hits        11091    12907    +1816     
- Misses       4808     5131     +323     
- Partials      703      860     +157     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@spencerschrock
Copy link
Member

/scdiff generate Branch-Protection

@github-actions
Copy link

Copy link
Member

@spencerschrock spencerschrock left a comment

Choose a reason for hiding this comment

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

trask added 4 commits July 14, 2025 09:25
…rulesets

Signed-off-by: Trask Stalnaker <trask.stalnaker@gmail.com>
Signed-off-by: Trask Stalnaker <trask.stalnaker@gmail.com>
This reverts commit df8855a.

Signed-off-by: Trask Stalnaker <trask.stalnaker@gmail.com>
Signed-off-by: Trask Stalnaker <trask.stalnaker@gmail.com>
@trask trask temporarily deployed to integration-test July 14, 2025 16:40 — with GitHub Actions Inactive
@spencerschrock spencerschrock changed the title Fixes false warnings in the "branch protection applies to admins" probe when repositories have tag-only rulesets configured 🐛 Skip tag-only rulesets during Branch-Protection Jul 14, 2025
@spencerschrock spencerschrock merged commit e6b369d into ossf:main Jul 14, 2025
40 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants