File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ description: |
44 Benchmark application that uses modern technologies and implements a set of
55 common security vulnerabilities
66type : application
7- version : 0.0.60
7+ version : 0.0.61
88keywords :
99 - brokencrystals
1010 - brkn
Original file line number Diff line number Diff line change @@ -37,6 +37,15 @@ export class ProductsController {
3737
3838 constructor ( private readonly productsService : ProductsService ) { }
3939
40+ private parseDate ( dateString : string ) : Date {
41+ const dateParts = dateString . split ( '-' ) ;
42+ const year = parseInt ( dateParts [ 2 ] , 10 ) ;
43+ const month = parseInt ( dateParts [ 1 ] , 10 ) - 1 ;
44+ const day = parseInt ( dateParts [ 0 ] , 10 ) ;
45+
46+ return new Date ( year , month , day ) ;
47+ }
48+
4049 @Get ( )
4150 @UseGuards ( AuthGuard )
4251 @JwtType ( JwtProcessorType . RSA )
@@ -67,10 +76,14 @@ export class ProductsController {
6776 let df = new Date ( new Date ( ) . setFullYear ( new Date ( ) . getFullYear ( ) - 1 ) ) ;
6877 let dt = new Date ( ) ;
6978 if ( dateFrom ) {
70- df = new Date ( ` ${ dateFrom } 00:00:00.000Z` ) ;
79+ df = this . parseDate ( dateFrom ) ;
7180 }
7281 if ( dateTo ) {
73- dt = new Date ( `${ dateTo } 00:00:00.000Z` ) ;
82+ dt = this . parseDate ( dateTo ) ;
83+ }
84+
85+ if ( isNaN ( df . getTime ( ) ) || isNaN ( dt . getTime ( ) ) ) {
86+ throw new BadRequestException ( 'Invalid date format' ) ;
7487 }
7588
7689 const allProducts = await this . productsService . findAll ( df , dt ) ;
You can’t perform that action at this time.
0 commit comments