Skip to content

fix(desktop): always allow unsafe custom binary for simple-git - #71944

Open
martin-lin-asg wants to merge 1 commit into
NousResearch:mainfrom
martin-lin-asg:fix/desktop-simple-git-unsafe-binary
Open

fix(desktop): always allow unsafe custom binary for simple-git#71944
martin-lin-asg wants to merge 1 commit into
NousResearch:mainfrom
martin-lin-asg:fix/desktop-simple-git-unsafe-binary

Conversation

@martin-lin-asg

@martin-lin-asg martin-lin-asg commented Jul 26, 2026

Copy link
Copy Markdown

Problem

On Windows, simple-git's custom-binary validation rejects git paths containing spaces (the default install is C:\Program Files\Git\cmd\git.exe) and also rejects non-standard paths from MSYS/WSL shims.

The previous fix enabled allowUnsafeCustomBinary only when the git binary path contained whitespace — but the regex check also rejects other characters, so the error still fires for MSYS-style paths like /c/Program Files/Git/cmd/git.exe.

Fix

Unconditionally enable unsafe.allowUnsafeCustomBinary: true in gitFor(). This is safe because gitBin is resolved by the Electron main process from known install locations and PATH — never from renderer/user input.

Files Changed

  • apps/desktop/electron/git-review-ops.tsgitFor() now always passes the unsafe escape hatch to simpleGit()

Error eliminated

Invalid value supplied for custom binary, restricted characters must be removed or supply the unsafe.allowUnsafeCustomBinary option

simple-git's custom-binary validation rejects paths containing spaces
(the default Windows install is C:\Program Files\Git\cmd\git.exe) and
also rejects non-standard paths from MSYS/WSL shims.

Previously, allowUnsafeCustomBinary was enabled conditionally only when
the git binary path contained whitespace. This missed cases where the
path contained other characters that fail the regex check.

Since gitBin is resolved by the Electron main process from known install
locations and PATH — never from user input — the binary path is trusted
and the escape hatch can be safely enabled unconditionally.
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/desktop Electron desktop app (apps/desktop/*) platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows labels Jul 26, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: #67612 and #54888. #67612 covers spaced trusted Git paths; this follow-up broadens the same trusted resolver path to non-whitespace custom-binary forms such as MSYS/WSL shims, so it is related rather than a duplicate.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for extending the Windows Git-path handling. The broader trusted-resolver approach may be appropriate, but the stated reproduction does not demonstrate a remaining failure on current main.

Problems

  • apps/desktop/electron/git-review-ops.ts:58 already enables allowUnsafeCustomBinary for any whitespace-containing gitBin. The cited /c/Program Files/Git/cmd/git.exe example therefore takes the existing safe branch.
  • apps/desktop/dist/electron-main.mjs:8463 shows simple-git rejects characters beyond whitespace, but apps/desktop/electron/git-review-ops.test.ts:37 covers only a spaced path. The PR does not identify or test a non-whitespace resolver output that reaches the rejection.

Suggested changes

  • Add a regression case for a concrete non-whitespace character that resolveGitBinary() can return (apps/desktop/electron/main.ts:2216-2231) and that simple-git rejects, so the broader opt-in is tied to a verified failure.

Automated hermes-sweeper review.

trimmed: false,
...(gitBin && /\s/.test(gitBin) ? { unsafe: { allowUnsafeCustomBinary: true } } : {})
unsafe: { allowUnsafeCustomBinary: true }
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The MSYS example in the PR body contains a space, so current main's gitBin && /\s/.test(gitBin) condition already enables this option for it. Please add a regression case for a concrete non-whitespace rejected character produced by resolveGitBinary() to demonstrate the remaining gap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have platform/windows Native Windows-specific behavior or breakage sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants