Suppress Git Credential Manager OAuth popup loop in Orca-run git — clone, terminals/agents, setup hooks (fixes #7652) (#7986)
* Suppress Git Credential Manager OAuth popup on git clone (fixes #7652) Orca's git runner disables the interactive credential prompt on every git call that goes through gitExecFileAsync/gitStreamStdout, but the two raw 'git clone' spawns (desktop repos:clone and the runtime clone path) passed no env, so they inherited process.env with no guard. On Windows a clone that needs GitHub auth then makes Git Credential Manager pop its 'Connect to GitHub' OAuth window, and in a network-restricted intranet the browser/device flow never completes while git's credential retry re-pops it. Apply nonInteractiveGitEnv() to both clone spawns so the prompt is suppressed (GCM_INTERACTIVE=never, credential.interactive=false, GIT_TERMINAL_PROMPT=0). The credential *helper* is kept, so cached-token clones for private repos still work; only the interactive fallback popup is disabled and the clone fails fast with a clear error instead. * Suppress GCM OAuth popup in agent terminals and setup hooks too (#7652) The clone-spawn fix stopped Orca's own managed git from popping Git Credential Manager, but git run in terminals and setup scripts inherited process.env with no guard. That is the more likely source of the reported loop: agents are told to run 'git pull --rebase'/'git fetch'/retry 'git push' (preamble + conflict/push-failure prompts), and each retry re-pops GCM's 'Connect to GitHub' window in a network-restricted intranet. Apply the credential-prompt guard to: - setup/archive/hook scripts (hooks.ts non-WSL exec env), which run unattended on worktree create/archive. - the shared PTY host env (buildPtyHostEnv), via a small applyTerminalGitCredentialPromptGuard helper. Agent terminals are guarded unconditionally (they cannot dismiss a GUI popup); user terminals are guarded by default via the new terminalSuppressGitCredentialPrompt setting so power users can opt out. The credential helper is kept, so cached gh auth still works; only the interactive fallback prompt is disabled. Verified end-to-end in a real Orca terminal (GIT_TERMINAL_PROMPT=0 + GCM_INTERACTIVE=never by default; absent when the opt-out is set). * Scope user-terminal credential guard to Windows, add settings toggle, forward guard into WSL (#7652) * Retrigger PR checks (Actions dropped the synchronize dispatch for 57e7ce249) * Keep shell locale out of the terminal/hook credential guard (#7652 review fix) * Fix Fable review findings: guard WSL hook branch, wire settings search, catalog keyword keys, sparse-env askpass, one-shot agent classification (#7652) * fix(terminal): harden Git credential popup guard * test(pty): cover SSH credential guard setting * fix(git): guard remote clones and setup runners * fix(git): scope credential guards to unattended work --------- Co-authored-by: Brennan Benson <brennanbenson@Brennans-MacBook-Pro.local>
This commit is contained in:
co-authored by
Brennan Benson
parent
699f709c3f
commit
1a6abc87d1
@@ -13,6 +13,7 @@ import {
|
||||
hasUnsupportedRevParsePathFormatEcho,
|
||||
isUnsupportedWorktreeListZError
|
||||
} from './git-worktree-command-capabilities'
|
||||
import { gitCredentialPromptGuardEnv } from './git-credential-prompt-env'
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
const image = process.env.ORCA_GIT_COMPAT_IMAGE
|
||||
@@ -26,7 +27,7 @@ describeBinaryCompatibility('real Git binary compatibility', () => {
|
||||
let repoPath = ''
|
||||
let version = { major: 0, minor: 0 }
|
||||
|
||||
async function runGit(args: string[]): Promise<GitResult> {
|
||||
async function runGit(args: string[], env?: NodeJS.ProcessEnv): Promise<GitResult> {
|
||||
if (image) {
|
||||
const dockerUser =
|
||||
typeof process.getuid === 'function' && typeof process.getgid === 'function'
|
||||
@@ -39,6 +40,9 @@ describeBinaryCompatibility('real Git binary compatibility', () => {
|
||||
'--rm',
|
||||
'--network=none',
|
||||
...dockerUser,
|
||||
...Object.entries(env ?? {}).flatMap(([key, value]) =>
|
||||
value === undefined ? [] : ['--env', `${key}=${value}`]
|
||||
),
|
||||
'-v',
|
||||
`${repoPath}:/repo`,
|
||||
'-w',
|
||||
@@ -51,7 +55,11 @@ describeBinaryCompatibility('real Git binary compatibility', () => {
|
||||
{ maxBuffer: 2 * 1024 * 1024 }
|
||||
)
|
||||
}
|
||||
return execFileAsync(binary!, args, { cwd: repoPath, maxBuffer: 2 * 1024 * 1024 })
|
||||
return execFileAsync(binary!, args, {
|
||||
cwd: repoPath,
|
||||
env: env ? { ...process.env, ...env } : undefined,
|
||||
maxBuffer: 2 * 1024 * 1024
|
||||
})
|
||||
}
|
||||
|
||||
function supports(major: number, minor: number): boolean {
|
||||
@@ -142,4 +150,19 @@ describeBinaryCompatibility('real Git binary compatibility', () => {
|
||||
await expect(runGit([...legacyArgs, head, head])).resolves.toBeDefined()
|
||||
}
|
||||
})
|
||||
|
||||
it('degrades indexed credential config safely at the Git 2.31 boundary', async () => {
|
||||
const guardEnv = gitCredentialPromptGuardEnv({}, 'linux')
|
||||
await expect(runGit(['status', '--short'], guardEnv)).resolves.toBeDefined()
|
||||
|
||||
try {
|
||||
const result = await runGit(['config', '--get', 'credential.interactive'], guardEnv)
|
||||
expect(supports(2, 31)).toBe(true)
|
||||
expect(result.stdout.trim()).toBe('false')
|
||||
} catch {
|
||||
// Git 2.25 ignores the indexed variables rather than rejecting commands;
|
||||
// the scalar prompt guards still provide the baseline fail-fast behavior.
|
||||
expect(supports(2, 31)).toBe(false)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user