fix(security): resolve all critical, high, and medium security vulnerabilities
This commit is contained in:
1 parent
da26dd1c8d
commit
dc88677169
33 files changed
+438
-85
No files matched your search
@@ -8,6 +8,7 @@ import {
|
||||
Param,
|
||||
Query,
|
||||
UseGuards,
|
||||
BadRequestException,
|
||||
} from '@nestjs/common';
|
||||
import { AdminService, CouponInput } from './admin.service';
|
||||
import { ProductDto } from './dto/product.dto';
|
||||
@@ -28,9 +29,13 @@ import {
|
||||
import { CreateUserDto, UpdateUserDto } from './dto/user.dto';
|
||||
import { SettingsService } from '../settings/settings.service';
|
||||
|
||||
import { RolesGuard } from '../common/guards/roles.guard';
|
||||
import { Roles } from '../common/decorators/roles.decorator';
|
||||
|
||||
@ApiTags('Admin - مدیریت سیستم')
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin', 'SUPER_ADMIN')
|
||||
@Controller('admin')
|
||||
export class AdminController {
|
||||
constructor(
|
||||
@@ -109,9 +114,20 @@ export class AdminController {
|
||||
@Body('type') type: 'deposit' | 'withdrawal' | 'refund',
|
||||
@Body('description') description?: string,
|
||||
) {
|
||||
const numAmount = Number(amount);
|
||||
if (!numAmount || isNaN(numAmount) || numAmount <= 0) {
|
||||
throw new BadRequestException('مبلغ باید یک عدد مثبت باشد');
|
||||
}
|
||||
if (numAmount > 100_000_000_000) {
|
||||
throw new BadRequestException('مبلغ بیش از حد مجاز است');
|
||||
}
|
||||
if (!['deposit', 'withdrawal', 'refund'].includes(type)) {
|
||||
throw new BadRequestException('نوع تراکنش معتبر نیست');
|
||||
}
|
||||
|
||||
const result = await this.adminService.adjustUserWallet(
|
||||
id,
|
||||
Number(amount),
|
||||
numAmount,
|
||||
type,
|
||||
description,
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user