List cap (F4): a server read with overrideAccess: true that passes a request on is not capped (the cookie scanner's scheduled crawl read its review list through the token request); reference types without the e2e fixtures; changelog heading covers all of 1.18.0
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e23edb2429
commit
2af8ef180f
@@ -45,6 +45,18 @@ beforeAll(async () => {
|
||||
{ slug: 'media', fields: [], upload: { staticDir: path.join(os.tmpdir(), 'ipal-test-media') } },
|
||||
],
|
||||
db: testDatabase('query_guard'),
|
||||
// the server's own read on behalf of a request without an account (the cookie scanner's scheduled crawl does this)
|
||||
endpoints: [
|
||||
{
|
||||
handler: async (req) => {
|
||||
const all = await req.payload.find({ collection: 'notes' as never, depth: 0, limit: 0, overrideAccess: true, pagination: false, req })
|
||||
const asCaller = await req.payload.find({ collection: 'notes' as never, depth: 0, limit: 0, overrideAccess: false, pagination: false, req })
|
||||
return Response.json({ all: all.docs.length, asCaller: asCaller.docs.length })
|
||||
},
|
||||
method: 'get',
|
||||
path: '/own-read',
|
||||
},
|
||||
],
|
||||
editor: lexicalEditor(),
|
||||
plugins: [iapl({ access: { authCollection: 'users' }, i18n: { defaultLocale: 'pl', locales: [{ code: 'pl', label: 'Polski' }] }, twoFactor: false })],
|
||||
secret: 'integration-test-secret-0123456789',
|
||||
@@ -81,6 +93,11 @@ describe('F4: public lists are capped for callers that are not staff', () => {
|
||||
expect((await payload.find({ collection: 'notes' as never, limit: 1000 })).docs).toHaveLength(130)
|
||||
})
|
||||
|
||||
test('a read that bypasses access, inside a request without an account, is the server\'s own: not capped', async () => {
|
||||
const res = await fetch(`${base}/api/own-read`, { headers: { origin: base } })
|
||||
expect(await res.json()).toEqual({ all: 130, asCaller: 100 })
|
||||
})
|
||||
|
||||
test('GraphQL lists from outside are capped as well', async () => {
|
||||
const res = await fetch(`${base}/api/graphql`, { body: JSON.stringify({ query: '{ Notes(limit: 100000) { docs { id } } }' }), headers: { 'content-type': 'application/json', origin: base }, method: 'POST' })
|
||||
const body = (await res.json()) as { data?: { Notes?: { docs: unknown[] } } }
|
||||
|
||||
@@ -249,6 +249,7 @@ describe('denial of service and injection — lists from outside (F4, F5)', () =
|
||||
it('F4: staff, the Local API, one document by id and listLimit: false are left alone; max / exclude / staff adapt it', () => {
|
||||
expect(run({ limit: 5000 }, staff)).toEqual({ limit: 5000 })
|
||||
expect(run({ limit: 5000 }, { ...visitor, payloadAPI: 'local' })).toEqual({ limit: 5000 })
|
||||
expect(run({ limit: 0, overrideAccess: true, pagination: false }, visitor)).toEqual({ limit: 0, overrideAccess: true, pagination: false })
|
||||
expect(run({ id: 'a', limit: 5000 }, visitor)).toEqual({ id: 'a', limit: 5000 })
|
||||
expect(run({ limit: 5000 }, visitor, 'read', buildQueryGuardHook({ listLimit: false }))).toEqual({ limit: 5000 })
|
||||
expect(run({ limit: 5000 }, visitor, 'read', buildQueryGuardHook({ listLimit: { max: 20 } }))).toMatchObject({ limit: 20 })
|
||||
|
||||
Reference in New Issue
Block a user