Skip to content

The agent that grows with you

style(desktop): keep PM source-check bridge lint clean

ethernetebc69c5faf61
diff --git a/apps/desktop/electron/updater/checkout-legacy.test.ts b/apps/desktop/electron/updater/checkout-legacy.test.ts
index 403ad3bc219..1dec0fbb4b3 100644
--- a/apps/desktop/electron/updater/checkout-legacy.test.ts
+++ b/apps/desktop/electron/updater/checkout-legacy.test.ts
@@ -115,6 +115,7 @@ it.skipIf(process.platform !== 'win32')(
hermesHome: home,
channel: 'stable' as const
}
+
await expect(readSourceUpdate(probe)).resolves.toMatchObject({ supported: true, channel: 'stable', behind: null })
await expect(readSourceUpdate({ ...probe, branch: 'main&echo INJECTED' })).rejects.toThrow(
'unsafe Windows command argument'
diff --git a/apps/desktop/electron/updater/checkout-source.ts b/apps/desktop/electron/updater/checkout-source.ts
index 0a0171cbdf6..f5714441606 100644
--- a/apps/desktop/electron/updater/checkout-source.ts
+++ b/apps/desktop/electron/updater/checkout-source.ts
@@ -46,6 +46,7 @@ export async function readSourceUpdate(probe: SourceUpdateProbe): Promise<Source
// The install launcher boots PM's committed Python and dependency generation.
// A PATH Python can import this checkout yet lack its selected dependencies.
const managed = existsSync(path.join(probe.updateRoot, 'pm'))
+
const launcher = managed
? resolveInstallationLauncher(probe.updateRoot, process.platform === 'win32', probe.hermesHome)
: null
@@ -79,13 +80,16 @@ export async function readSourceUpdate(probe: SourceUpdateProbe): Promise<Source
...(probe.cachePath ? ['--cache-path', probe.cachePath] : []),
...(probe.branchConfigPath ? ['--branch-config-path', probe.branchConfigPath] : [])
]
+
const command: string = (managed ? launcher : probe.python)!
const viaCmd: boolean = process.platform === 'win32' && /\.cmd$/i.test(command)
+
// Node refuses direct .cmd execFile; shell:true interpolates untrusted branch
// and path arguments. Keep cmd.exe's one unavoidable parse fail-closed.
if (viaCmd && [command, ...args].some((value: string): boolean => /["%&|<>^\r\n]/.test(value))) {
throw new Error('The source check contains an unsafe Windows command argument.')
}
+
const result: { stdout: string; stderr: string } = await execute(
viaCmd ? (process.env.ComSpec ?? 'cmd.exe') : command,
viaCmd