Skip to content

Commit

Permalink
fix: CE-862: Fixed potential cross site scripting exploit (#497)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Sears <[email protected]>
  • Loading branch information
marqueone-ps and Mike Sears authored Jul 4, 2024
1 parent c491eb2 commit 3833459
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"date-fns": "^3.6.0",
"date-fns-tz": "^3.1.3",
"dotenv": "^16.0.1",
"escape-html": "^1.0.3",
"form-data": "^4.0.0",
"geojson": "^0.5.0",
"jest-mock": "^29.6.1",
Expand Down
5 changes: 2 additions & 3 deletions backend/src/v1/document/document.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Roles } from "../../auth/decorators/roles.decorator";
import { Token } from "../../auth/decorators/token.decorator";
import { COMPLAINT_TYPE } from "../../types/models/complaints/complaint-type";
import { format } from "date-fns";
import { escape } from "escape-html";

@UseGuards(JwtRoleGuard)
@ApiTags("document")
Expand All @@ -27,8 +28,6 @@ export class DocumentController {
@Res() res: Response,
): Promise<void> {
try {
this.logger.debug("TIMEZONE: ", tz);

const fileName = `Complaint-${id}-${type}-${format(new Date(), "yyyy-MM-dd")}.pdf`;
const response = await this.service.exportComplaint(id, type, fileName, tz);

Expand All @@ -47,7 +46,7 @@ export class DocumentController {
res.end(buffer);
} catch (error) {
this.logger.error(`exception: unable to export document for complaint: ${id} - error: ${error}`);
res.status(500).send(`exception: unable to export document for complaint: ${id} - error: ${error}`);
res.status(500).send(`exception: unable to export document for complaint: ${escape(id)}`);
}
}
}

0 comments on commit 3833459

Please sign in to comment.