Skip to content

Commit

Permalink
fix: force json response for date manipulation vulnerable endpoint (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmstss authored Sep 4, 2024
1 parent 721a32e commit a27c696
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/misc/misc.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('MiscController', () => {
to,
weekday
);
expect(result).toBe(JSON.stringify({ count }, null, 2));
expect(result).toEqual({ count });
});

it('should use default weekday 1 if not provided', async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/misc/misc.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ export class MiscController {
@Query('from') from: string,
@Query('to') to: string,
@Query('weekday') weekday?: string
): Promise<string> {
): Promise<{ count: number }> {
const count = await this.dateService.calculateWeekdays(
from,
to,
weekday ? +weekday : 1
);

return JSON.stringify({ count }, null, 2);
return { count };
}
}

0 comments on commit a27c696

Please sign in to comment.