Fix paste ownership, input bounds, and IPC validation
Supersedes #5745, #5746, and #5747.
This commit is contained in:
@@ -8,6 +8,10 @@
|
||||
// (d) parseProjectPaste shorthand owner-only alphabet matches the renderer,
|
||||
// (e) project owner/capability caches stay bounded in long sessions.
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
import {
|
||||
GITHUB_PROJECT_REF_INPUT_MAX_BYTES,
|
||||
GITHUB_PROJECT_REF_INPUT_TOO_LARGE_ERROR
|
||||
} from '../../shared/github-project-ref-input'
|
||||
import {
|
||||
PROJECT_VIEW_OWNER_CACHE_MAX_ENTRIES,
|
||||
_getProjectViewCacheSizesForTests,
|
||||
@@ -21,7 +25,8 @@ import {
|
||||
classifyProjectError,
|
||||
isValidOwnerSlug,
|
||||
isValidRepoSlug,
|
||||
parseProjectPaste
|
||||
parseProjectPaste,
|
||||
resolveProjectRef
|
||||
} from './project-view'
|
||||
|
||||
describe('classifyProjectError', () => {
|
||||
@@ -151,6 +156,39 @@ describe('parseProjectPaste', () => {
|
||||
expect(parseProjectPaste('')).toBeNull()
|
||||
expect(parseProjectPaste(' ')).toBeNull()
|
||||
})
|
||||
|
||||
it('rejects oversized valid-looking URLs without parsing the secret-bearing tail', () => {
|
||||
const secret = 'project-url-secret'
|
||||
const input = [
|
||||
'https://github.com/orgs/acme/projects/42?',
|
||||
secret,
|
||||
'x'.repeat(GITHUB_PROJECT_REF_INPUT_MAX_BYTES)
|
||||
].join('')
|
||||
|
||||
expect(parseProjectPaste(input)).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('resolveProjectRef', () => {
|
||||
it('rejects oversized project refs with a metadata-only validation error', async () => {
|
||||
const secret = 'project-url-secret'
|
||||
const input = [
|
||||
'https://github.com/orgs/acme/projects/42?',
|
||||
secret,
|
||||
'x'.repeat(GITHUB_PROJECT_REF_INPUT_MAX_BYTES)
|
||||
].join('')
|
||||
|
||||
await expect(resolveProjectRef({ input })).resolves.toEqual({
|
||||
ok: false,
|
||||
error: {
|
||||
type: 'validation_error',
|
||||
message: GITHUB_PROJECT_REF_INPUT_TOO_LARGE_ERROR
|
||||
}
|
||||
})
|
||||
await expect(resolveProjectRef({ input })).resolves.not.toMatchObject({
|
||||
error: { message: expect.stringContaining(secret) }
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('project view owner caches', () => {
|
||||
|
||||
Reference in New Issue
Block a user