Fix paste ownership, input bounds, and IPC validation

Supersedes #5745, #5746, and #5747.
This commit is contained in:
Jinwoo Hong
2026-06-19 17:14:55 -07:00
committed by GitHub
parent a5920b2183
commit 972078f2c4
592 changed files with 33303 additions and 3737 deletions
+28 -1
View File
@@ -1,10 +1,14 @@
import { describe, expect, it, vi } from 'vitest'
import { afterEach, describe, expect, it, vi } from 'vitest'
import {
syncForkDefaultBranch,
validateGitForkSyncExpectedUpstream,
type GitForkSyncRunner
} from './git-fork-sync'
afterEach(() => {
vi.restoreAllMocks()
})
function createRunner(overrides: {
remotes?: string
upstreamUrl?: string
@@ -101,6 +105,29 @@ describe('syncForkDefaultBranch', () => {
expect(flattenedCommands(calls)).not.toContain('push origin')
})
it('scans newline-heavy remote and default-branch output without line-array splitting', async () => {
const splitSpy = vi.spyOn(String.prototype, 'split')
const { runGit } = createRunner({
remotes: `${'\r\n'.repeat(10_000)}origin\r\nupstream\r\n`,
defaultBranchOutput: `${'metadata\r\n'.repeat(
10_000
)}ref: refs/heads/main\tHEAD\r\n0123456789012345678901234567890123456789\tHEAD\r\n`,
aheadBehind: '0\t0\n'
})
await expect(syncForkDefaultBranch(runGit)).resolves.toMatchObject({
status: 'up-to-date',
branchName: 'main'
})
const usedLineSplit = splitSpy.mock.calls.some(
([separator]) =>
(typeof separator === 'string' && separator === '\n') ||
(separator instanceof RegExp && separator.source === '\\r?\\n')
)
expect(usedLineSplit).toBe(false)
})
it('blocks when the fork has commits that are not upstream', async () => {
const { runGit, calls } = createRunner({ aheadBehind: '2\t4\n' })