Skip to content

fix: reject unsafe repository default branches before git switch - #341

Open
o-mid wants to merge 1 commit into
theam:mainfrom
o-mid:fix/validate-workspace-default-branch
Open

fix: reject unsafe repository default branches before git switch#341
o-mid wants to merge 1 commit into
theam:mainfrom
o-mid:fix/validate-workspace-default-branch

Conversation

@o-mid

@o-mid o-mid commented Sep 8, 2026

Copy link
Copy Markdown

Addresses unsafe git start-points from a stored repository default branch.

Workspace prepare already rejected unsafe story branches, then passed origin/${defaultBranch} to git switch without the same check. A default of main..evil is git range syntax.

Prepare now rejects that class of default branch before clone. Valid hostile names such as $(id) still pass because git is invoked as argv, not a shell string.

Test plan

  • pnpm --filter @facility/api exec vitest run test/git-branch.test.ts
  • pnpm --filter @facility/api test
  • Confirm $(id), release/2026, and foo"bar remain accepted
  • Confirm main..evil, foo@{upstream}, and chore/../other are rejected

Story branches were already checked, but origin/${defaultBranch} was not,
so a stored default of main..evil could be passed to git as revision-range
syntax.
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.

1 participant