Skip to content

[WRONG BRANCH] security: restrict closed-PR branch cleanup to disposable namespaces - #361

Closed
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-vulnerability-in-branch-deletion-workflow
Closed

[WRONG BRANCH] security: restrict closed-PR branch cleanup to disposable namespaces#361
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-vulnerability-in-branch-deletion-workflow

Conversation

@luvs01

@luvs01 luvs01 commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Motivation

  • A scheduled cleanup used closed-PR metadata to decide deletions and could remove an unrelated unprotected repository branch that shared a head name. This introduces a confused-deputy risk where PR management authority alone authorized destructive ref deletion.
  • The change limits the cleanup planner so PR state cannot by itself delete arbitrary refs and confines deletion to explicitly disposable automation branches.

Description

  • Added DISPOSABLE_BRANCH_PREFIXES and a new keep reason OUTSIDE_DISPOSABLE_NAMESPACE to the planner so only branches in the reserved codex/ and ingw/ namespaces are eligible. (.github/scripts/closed-pr-branch-cleanup.cjs).
  • Early-return keep rule added to planClosedPrBranchDeletions to skip branches that do not start with an allowed disposable prefix and therefore never reach the deletion plan. (.github/scripts/closed-pr-branch-cleanup.cjs).
  • Updated test fixtures to supply head OIDs and adjusted tests to assert SHA-aware behavior and the new namespace restriction, including a regression test that proves a persistent branch outside disposable namespaces is not deleted. (.github/scripts/closed-pr-branch-cleanup.test.cjs).
  • Preserved existing safeguards (protected branch list, fork heads, open/merged PRs, base-of-open rule, grace period, and tip/sha checks) so deletion remains conservative.

Testing

  • Ran node --test .github/scripts/closed-pr-branch-cleanup.test.cjs and the planner unit tests passed (12/12).
  • Ran ./node_modules/.bin/bun test tests/ci-workflows.test.ts tests/repo-hygiene.test.ts and the targeted workflow/hygiene suites passed (147/147).
  • Ran git diff --check with no issues detected.
  • Ran PATH="$PWD/node_modules/.bin:$PATH" bun run prepush (full prepush flow); typecheck and GUI lint passed, but the full test stage exposed unrelated environment-sensitive failures (lab sandbox / proxy env) that prevented completing the full suite in this environment (warning-level).

Codex Task

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot changed the title security: restrict closed-PR branch cleanup to disposable namespaces [WRONG BRANCH] security: restrict closed-PR branch cleanup to disposable namespaces Aug 28, 2026
@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bc17cba0-6ffa-4967-8c04-7841b625b9b9


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions
github-actions Bot marked this pull request as draft August 28, 2026 04:21
@luvs01 luvs01 closed this Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant