fix(media): bound image work before public rendition

Check avatar uploads and raster fallbacks before decoding. Limit compressed bytes, decoded dimensions, GIF frames and the combined TIFF page budget.
This commit is contained in:
Maurice
2026-12-01 11:56:22 +01:00
parent 1ff8a814ae
commit 28eea68559
7 changed files with 308 additions and 6 deletions
+11
View File
@@ -168,6 +168,17 @@ describe('Avatar', () => {
expect(res.status).toBe(400);
});
it('PROFILE-003b: checks the avatar bytes before storing it', async () => {
const { user } = await makeUser(orm);
const res = await request(app)
.post('/api/auth/avatar')
.set('Cookie', authCookie(user.id))
.attach('avatar', Buffer.from('not an image'), { filename: 'avatar.png', contentType: 'image/png' });
expect(res.status).toBe(400);
expect(await findRow(orm, Users, { id: user.id })).toMatchObject({ avatar: null });
});
it('PROFILE-005 — DELETE /api/auth/avatar clears avatar_url', async () => {
const { user } = await makeUser(orm);
// Upload first