Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

fix(persistence): reject non-file recovery artifacts before publication (#35059)

OrcaWin59be15b7ef27
diff --git a/src/main/persistence/profile-state/profile-state-recovery-copy.test.ts b/src/main/persistence/profile-state/profile-state-recovery-copy.test.ts
index 243dd182741..aef4d9cbf90 100644
--- a/src/main/persistence/profile-state/profile-state-recovery-copy.test.ts
+++ b/src/main/persistence/profile-state/profile-state-recovery-copy.test.ts
@@ -93,20 +93,9 @@ describe('independent profile recovery copies', () => {
expect(run).not.toHaveBeenCalled()
})
- describe.skipIf(process.platform !== 'darwin')('Darwin clone failure boundaries', () => {
- it('resolves both process arguments while preserving relative path behavior', () => {
- const { directory, source, target } = fixture()
- const run = vi.spyOn(processes, 'runProcessSync')
- copyProfileStateRecoveryFile(relative(process.cwd(), source), relative(process.cwd(), target))
- const args = run.mock.calls[0]?.[0].args
- expect(args?.[0]).toBe('-c')
- expect(isAbsolute(args?.[1] ?? '')).toBe(true)
- expect(isAbsolute(args?.[2] ?? '')).toBe(true)
- expect(readFileSync(target).equals(readFileSync(source))).toBe(true)
- expectNoTemporary(directory)
- })
-
- it('keeps ordinary-copy semantics for symlinks to large recovery artifacts', () => {
+ it.skipIf(process.platform === 'win32')(
+ 'keeps ordinary-copy semantics for symlinks to large recovery artifacts',
+ () => {
const { directory, source, target } = fixture()
const alias = join(directory, 'alias')
symlinkSync(source, alias)
@@ -118,6 +107,20 @@ describe('independent profile recovery copies', () => {
statSync(source, { bigint: true }).ino
)
expectNoTemporary(directory)
+ }
+ )
+
+ describe.skipIf(process.platform !== 'darwin')('Darwin clone failure boundaries', () => {
+ it('resolves both process arguments while preserving relative path behavior', () => {
+ const { directory, source, target } = fixture()
+ const run = vi.spyOn(processes, 'runProcessSync')
+ copyProfileStateRecoveryFile(relative(process.cwd(), source), relative(process.cwd(), target))
+ const args = run.mock.calls[0]?.[0].args
+ expect(args?.[0]).toBe('-c')
+ expect(isAbsolute(args?.[1] ?? '')).toBe(true)
+ expect(isAbsolute(args?.[2] ?? '')).toBe(true)
+ expect(readFileSync(target).equals(readFileSync(source))).toBe(true)
+ expectNoTemporary(directory)
})
it('cleans a failed partial clone and falls back to an independent ordinary copy', () => {
diff --git a/src/main/persistence/profile-state/profile-state-recovery-copy.ts b/src/main/persistence/profile-state/profile-state-recovery-copy.ts
index 415c8dd6847..8e8003fb4e3 100644
--- a/src/main/persistence/profile-state/profile-state-recovery-copy.ts
+++ b/src/main/persistence/profile-state/profile-state-recovery-copy.ts
@@ -1,4 +1,12 @@
-import { constants, copyFileSync, linkSync, lstatSync, mkdtempSync, rmSync } from 'node:fs'
+import {
+ constants,
+ copyFileSync,
+ linkSync,
+ lstatSync,
+ mkdtempSync,
+ rmSync,
+ statSync
+} from 'node:fs'
import { basename, dirname, join, resolve } from 'node:path'
import { runProcessSync } from '@orca/process-host'
@@ -18,9 +26,12 @@ export function copyProfileStateRecoveryFiles(files: readonly RecoveryCopy[]): v
const clones: RecoveryCopy[] = []
const names = new Set<string>()
for (const file of files) {
- const info = process.platform === 'darwin' ? lstatSync(file.source) : undefined
+ const info = lstatSync(file.source)
+ if (!info.isFile() && (!info.isSymbolicLink() || !statSync(file.source).isFile())) {
+ throw new Error(`Profile recovery artifact is not a file: ${file.source}`)
+ }
const name = basename(file.source)
- if (!info?.isFile() || info.size < MINIMUM_CLONE_BYTES) {
+ if (process.platform !== 'darwin' || !info.isFile() || info.size < MINIMUM_CLONE_BYTES) {
copyFileSync(file.source, file.target, constants.COPYFILE_EXCL)
} else if (
files.length > 1 &&