fix(security): add fileFilter mime check to pets upload and Throttling to tickets endpoints
This commit is contained in:
1 parent
4d5159a169
commit
e9582430e6
2 files changed
+15
No files matched your search
@@ -75,6 +75,18 @@ export class PetsController {
|
||||
},
|
||||
}),
|
||||
limits: { fileSize: 10 * 1024 * 1024 }, // 10MB
|
||||
fileFilter: (_req, file, callback) => {
|
||||
const allowedMimeTypes = ['image/jpeg', 'image/png', 'image/webp', 'image/gif'];
|
||||
if (!allowedMimeTypes.includes(file.mimetype)) {
|
||||
return callback(
|
||||
new BadRequestException(
|
||||
'فرمت فایل مجاز نیست. لطفاً یکی از فرمتهای JPG, PNG, WEBP را انتخاب کنید',
|
||||
),
|
||||
false,
|
||||
);
|
||||
}
|
||||
callback(null, true);
|
||||
},
|
||||
}),
|
||||
)
|
||||
@ApiOperation({ summary: 'آپلود تصویر حیوان خانگی' })
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Throttle } from '@nestjs/throttler';
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
@@ -33,6 +34,7 @@ import {
|
||||
export class TicketsController {
|
||||
constructor(private readonly ticketsService: TicketsService) {}
|
||||
|
||||
@Throttle({ default: { limit: 5, ttl: 60000 } })
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Post()
|
||||
@@ -66,6 +68,7 @@ export class TicketsController {
|
||||
return this.ticketsService.getTicketDetails(id, req.user.id, isAdmin);
|
||||
}
|
||||
|
||||
@Throttle({ default: { limit: 10, ttl: 60000 } })
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Post(':id/messages')
|
||||
|
||||
Reference in new issue
Block a user