Skip to content

Commit c57e44b

Browse files
authored
fix: improve query params sanitization (prod) (#208)
1 parent cf8ec6e commit c57e44b

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

Diff for: src/modules/deposit/dto.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ApiProperty } from "@nestjs/swagger";
2-
import { IsEnum, IsNumberString, IsOptional, IsString } from "class-validator";
2+
import { Type } from "class-transformer";
3+
import { IsEnum, IsInt, IsOptional, IsString, Max, Min } from "class-validator";
34

45
export class GetDepositsQuery {
56
@IsOptional()
@@ -16,13 +17,19 @@ export class GetDepositsQuery {
1617
status: "filled" | "pending";
1718

1819
@IsOptional()
19-
@IsNumberString({ no_symbols: true })
20-
@ApiProperty({ example: "10", required: false })
20+
@IsInt()
21+
@Min(1)
22+
@Max(100)
23+
@Type(() => Number)
24+
@ApiProperty({ example: 10, required: false })
2125
limit: string;
2226

2327
@IsOptional()
24-
@IsNumberString({ no_symbols: true })
25-
@ApiProperty({ example: "0", required: false })
28+
@IsInt()
29+
@Min(0)
30+
@Max(10_000_000)
31+
@Type(() => Number)
32+
@ApiProperty({ example: 0, required: false })
2633
offset: string;
2734

2835
@IsOptional()

Diff for: src/modules/referral/entry-points/http/dto.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ApiProperty } from "@nestjs/swagger";
2-
import { IsDate, IsDateString, IsNumberString, IsString, Length } from "class-validator";
2+
import { Type } from "class-transformer";
3+
import { IsDateString, IsInt, IsNumberString, IsString, Length, Max, Min } from "class-validator";
34

45
export class GetReferralsSummaryQuery {
56
@IsString()
@@ -14,12 +15,18 @@ export class GetReferralsQuery {
1415
@ApiProperty({ example: "0x9A8f92a830A5cB89a3816e3D267CB7791c16b04D", minLength: 42, maxLength: 42, required: true })
1516
address: string;
1617

17-
@IsNumberString()
18-
@ApiProperty({ example: "10", required: false })
18+
@IsInt()
19+
@Min(1)
20+
@Max(100)
21+
@Type(() => Number)
22+
@ApiProperty({ example: 10, required: true })
1923
limit: string;
2024

21-
@IsNumberString()
22-
@ApiProperty({ example: "0", required: false })
25+
@IsInt()
26+
@Min(0)
27+
@Max(10_000_000)
28+
@Type(() => Number)
29+
@ApiProperty({ example: 0, required: true })
2330
offset: string;
2431
}
2532

0 commit comments

Comments
 (0)