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
+19 -1
View File
@@ -1,9 +1,13 @@
// Why: covers two recent classifier fixes — Retry-After honoring on 429
// (transient detection must propagate, not silently retry on 250ms cadence)
// and stderr extraction from execFile rejections (err.message is unreliable).
import { describe, expect, it } from 'vitest'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { extractExecError, isTransientGhError, parseRetryAfterMs } from './runner'
afterEach(() => {
vi.restoreAllMocks()
})
describe('parseRetryAfterMs', () => {
it('returns null when no Retry-After is present', () => {
expect(parseRetryAfterMs('HTTP 429 Too Many Requests')).toBeNull()
@@ -17,6 +21,20 @@ describe('parseRetryAfterMs', () => {
expect(parseRetryAfterMs(' retry-after: 12 \n')).toBe(12_000)
})
it('parses large stderr output without full-string retry-after matching', () => {
const matchSpy = vi.spyOn(String.prototype, 'match')
const stderr = `${'noise\n'.repeat(10_000)}Retry-After: 12\n`
expect(parseRetryAfterMs(stderr)).toBe(12_000)
const usedRetryAfterMatch = matchSpy.mock.calls.some(
([pattern]) =>
pattern instanceof RegExp &&
pattern.source.startsWith('retry-after:') &&
pattern.source.includes('[^\\r\\n]')
)
expect(usedRetryAfterMatch).toBe(false)
})
it('returns null for malformed values', () => {
expect(parseRetryAfterMs('Retry-After: not-a-date')).toBeNull()
})