Skip to content

fix(BED-10679): model App permissions and branch protection exceptions - #119

Merged
jaredcatkinson merged 1 commit into
mainfrom
fix/BED-10679-app-branch-protection-exceptions
Nov 25, 2026
Merged

jaredcatkinson merged 1 commit into
mainfrom
fix/BED-10679-app-branch-protection-exceptions

Conversation

@jaredcatkinson

@jaredcatkinson jaredcatkinson commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem and behavior

GitHub App actors on classic branch protection push and pull-request bypass lists were omitted from the graph. Resolve these actors to the active installation with access to the repository and emit non-traversable GH_RestrictionsCanPush and GH_BypassPullRequestAllowances relationships. When GraphQL returns partial errors on these allowance fields, recover details through a targeted REST request and merge them with successful GraphQL actors; log gaps when recovery fails.

Split requested App and granted installation permissions into permissions_repository, permissions_organization, permissions_enterprise, and permissions_account arrays of permission:access values, retaining unknown keys in permissions_unclassified. This replaces the graph's flat permissions property; raw collection input is unchanged. Update App privilege-zone rules and descriptions to use the scoped properties. Installations also receive non-traversable GH_CanAccess edges to their organization or enterprise target.

Traversable installation capability edges and branch capability scopes are deferred to separate work. Force-push App actor recovery remains unsupported: the reproduced GraphQL error has no equivalent actor list in the REST protection response.

Validation

  • Full test suite: 753 passed (26 dependency deprecation warnings).
  • Ruff lint and formatting checks on changed Python files; git diff --check.
  • Previously verified targeted REST recovery against a configured App push allowance and confirmed the installation-to-rule relationship.

Ticket: BED-10679

Summary by CodeRabbit

  • New Features
    • GitHub App permissions are now organized by repository, organization, enterprise, and account scope, with unclassified permissions retained.
    • App installations can be associated with their resolved organization or enterprise, and branch protection exceptions can include eligible App installations.
    • Branch protection allowance details can be recovered when GraphQL responses contain partial errors, while preserving actors that were successfully collected.
  • Documentation
    • Clarified that App exceptions alone do not establish repository write access and that other protection requirements still apply.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change classifies GitHub App permissions by scope, adds installation access relationships and repository-level installation lookup, and records App actors on branch-protection rules. It also recovers allowance actors through REST when GraphQL reports partial allowance errors and updates related schemas, rules, and tests.

Changes

App Installations and Branch Protection

Layer / File(s) Summary
Scoped app permissions
src/openhound_github/models/app_permissions.py, src/openhound_github/models/app_installation.py, descriptions/nodes/*, extension/schema.json, extension/privilege_zone_rules/*, tests/test_app_permissions.py, tests/test_credential_permission_models.py
App and installation permissions are split into repository, organization, enterprise, account, and unclassified properties. Tier 0 rules now check permissions_repository.
Installation access resolution
src/openhound_github/lookup.py, src/openhound_github/main.py, src/openhound_github/transforms.py, src/openhound_github/models/app_installation.py, descriptions/edges/GH_CanAccess.md, extension/schema.json, tests/test_app_installation_lookup.py, tests/test_preproc.py, tests/test_enterprise_app_installation.py, tests/test_repository_scopes.py
Preprocessing provides installation and repository-access inputs. Lookup resolves a unique eligible organization installation for a repository. Installations link to resolved organization or enterprise targets, and all-repository organization installations retain repository-scope edges.
App actors on protection rules
src/openhound_github/graphql.py, src/openhound_github/models/branch_protection_rule.py, descriptions/edges/GH_BypassPullRequestAllowances.md, descriptions/edges/GH_RestrictionsCanPush.md, extension/schema.json, tests/test_branch_protection_app_actors.py
Allowance queries request actor types and app identifiers. Branch-protection rules resolve app actors to installations and emit edges for pull-request bypass and push-restriction allowances.
REST allowance recovery
src/openhound_github/resources/branch_protection_helpers.py, src/openhound_github/resources/organization.py, README.md, tests/test_branch_allowance_recovery.py
When GraphQL reports an allowance error, organization rule collection requests REST protection details for the affected rule. Valid REST actors are merged with GraphQL actors; failed or incomplete recovery logs a collection gap.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Organization as Organization.branch_protection_rules
  participant GraphQL as GraphQL API
  participant Recovery as recover_branch_allowances
  participant REST as RESTClient
  Organization->>GraphQL: Request protection rules
  GraphQL-->>Organization: Return rules and allowance errors
  Organization->>Recovery: Pass affected rule and allowance fields
  Recovery->>REST: Request branch protection details
  REST-->>Recovery: Return allowance actors
  Recovery-->>Organization: Return merged rule or original rule
Loading

Suggested reviewers: d3vzer0, strandutton, jonasbk

Merge Risk: Minimal · up to 44fa1

This change splits App permissions by scope, adds non-traversable App exception edges on branch-protection rules, and recovers allowance actors over REST after partial GraphQL errors. No actionable merge-blocking defect was found. The remaining caveat is a narrow race: if branch protection changes mid-collection, recovered actors could briefly be attached to the wrong rule. Fixing it would take disproportionate effort for its reward.

Security architecture risk: Moderate · up to 44fa1

Updating the Tier Zero rules before refreshing existing graph data can temporarily hide highly privileged Apps and installations. Branch-protection recovery improves visibility, but a rule change during collection can cause an exception to be reported against the wrong rule. Neither issue grants access in GitHub.

Retained concerns

  • Medium · security · observed: Both updated Tier Zero rules omit otherwise eligible installations that still have only the legacy permission property, and may also omit their parent Apps. Updating the rules before all affected imports are refreshed creates a classification gap. Rolling back only the rules can produce the inverse gap for nodes with scoped properties only. Freshly converted data matches the new predicates; the timing and duration of any gap depend on deployment ordering.
  • Low · security · inferred: If a representative branch's effective protection changes between discovery and REST recovery, allowances from the later rule can be attached to the earlier GraphQL rule and reported for other branches that reference it. The base did not merge a second snapshot. The new path is limited to affected fields in the same repository, and App relationships still require an eligible installation and remain non-traversable. An actual misattribution was not verified.
Security review details

Security Blast Radius

  • inferred — A mixed-version import can hide Tier Zero classifications across all affected organizations for installations with organization-wide repository reach and qualifying write permissions, and for their parent Apps. The change affects security visibility, not GitHub authorization.

Trust Boundaries and Controls

  • observed — Repository and branch identifiers are quoted into a fixed REST route. The graph lookup binds the App slug and repository ID as parameters and requires exactly one active organization installation with all-repository access or an explicit grant for that repository in the owning organization. Unresolved or ambiguous installations do not produce an App exception edge.

Resilience and Maintainability Implications

  • observed — A failed request or invalid REST field preserves the available GraphQL data and logs the gap. Published rule nodes and App exception edges do not distinguish unresolved collection gaps from complete results. Missing actors were already unmarked at the base; the head adds recovery and diagnostics.

Hardening Proposals

  • proposed — Stage the Tier Zero rule cutover behind a verified refresh of affected imports, or support both property shapes during the transition. Check that qualifying installations and Apps remain classified after an interrupted import and after rollback.
  • proposed — Revalidate the branch-to-rule association before publishing recovered allowances where the upstream API supports it, and expose unresolved allowance completeness in the graph so consumers do not mistake missing data for an empty exception list.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(BED-10679): model App permissions and branch protection exceptions" matches the main changes. The PR replaces the flat App permissions property with scoped permission arrays (repository…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(BED-10679): model App permissions and branch protection exceptions" matches the main changes. The PR replaces the flat App permissions property with scoped permission arrays (repository, organization, enterprise, account, unclassified). It also adds App actors from branch-protection push and bypass allowances as non-traversable edges, with REST recovery for partial GraphQL errors. The title names both major parts. It uses a conventional-commit prefix with a ticket reference, which is acceptable. It does not mention the REST recovery or the CAN_ACCESS edges, but it does not need to cover every detail.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the branch at dawn,
And sorts permissions, row by row.
App actors find their matching home,
While REST brings back the names that flow.
The rule keeps what GraphQL knew,
Then hops along with its actors too.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e7217c2b-2f2c-4ce0-9d36-7b99d967d4d4
Commits

Reviewing files that changed from the base of the PR and between e83b97f and 44fa1cf.

Files selected for processing: 26

  • README.md
  • descriptions/edges/GH_BypassPullRequestAllowances.md
  • descriptions/edges/GH_CanAccess.md
  • descriptions/edges/GH_RestrictionsCanPush.md
  • descriptions/nodes/GH_App.md
  • descriptions/nodes/GH_AppInstallation.md
  • extension/privilege_zone_rules/t0-app-installations-all-repos.json
  • extension/privilege_zone_rules/t0-apps-all-repos.json
  • extension/schema.json
  • src/openhound_github/graphql.py
  • src/openhound_github/lookup.py
  • src/openhound_github/main.py
  • src/openhound_github/models/app_installation.py
  • src/openhound_github/models/app_permissions.py
  • src/openhound_github/models/branch_protection_rule.py
  • src/openhound_github/resources/branch_protection_helpers.py
  • src/openhound_github/resources/organization.py
  • src/openhound_github/transforms.py
  • tests/test_app_installation_lookup.py
  • tests/test_app_permissions.py
  • tests/test_branch_allowance_recovery.py
  • tests/test_branch_protection_app_actors.py
  • tests/test_credential_permission_models.py
  • tests/test_enterprise_app_installation.py
  • tests/test_preproc.py
  • tests/test_repository_scopes.py

Included review availability: This review used your included allowance. 9 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.

@jaredcatkinson
jaredcatkinson merged commit 7966df1 into main Nov 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants