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

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

@adrian-lorenzo adrian-lorenzo 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.

Thanks for tightening the validation!

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.
@o-mid
o-mid force-pushed the fix/validate-workspace-default-branch branch from 165e9f7 to 3e22d7d Compare October 17, 2026 07:50

This branch has not been deployed

No deployments
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