Skip to content

Bark beetle report - #10

Draft
Ignas-rgb wants to merge 4 commits into
mainfrom
bark-beetle-report
Draft

Bark beetle report#10
Ignas-rgb wants to merge 4 commits into
mainfrom
bark-beetle-report

Conversation

@Ignas-rgb

Copy link
Copy Markdown
Contributor

Add endpoint to send bark beetle reports. No need to save them. They are only sent out for manual tracking via PostMark automatic emails.

New endpoint to accept bark beetle reports and forward them via PostMark for reviewing
@Ignas-rgb
Ignas-rgb requested a review from vycius March 27, 2024 14:17

const attachments = [];

for (let i = 0; i < images.length; i++) {

Check failure

Code scanning / CodeQL

Loop bound injection

Iteration over a user-controlled object with a potentially unbounded .length property from a [user-provided value](1).

const attachments = [];

for (let i = 0; i < images.length; i++) {

Check failure

Code scanning / CodeQL

Type confusion through parameter tampering

Potential type confusion as [this HTTP request parameter](1) may be either an array or a string.

@vycius vycius left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's relatively easy to abuse this feature and inundate email servers, potentially sending millions of emails through Postmark by making multiple calls to this endpoint. Keep this possibility in mind while implementing and using this feature. Otherwise, the code appears good.

attachments.push({
Name: 'nuotrauka' + i + '.jpg',
Content: encodedImageContent,
ContentType: 'image/jpeg',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The image won't always be 'image/jpeg'. I would recommended to detect the file type and extension dynamically using a magic number approach. Utilize libraries like file-type (https://www.npmjs.com/package/file-type) or equivalent for detection.

return this.postmarkService.sendBarkBeetleReport(
createReportDto,
images,
'benas.svedas@aad.am.lt',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend to move email to environment variables.

sendBarkBeetleReport(
@Body() createReportDto: CreateReportDto,
@UploadedFiles() images: Array<Express.Multer.File>,
): Promise<MessageSendingResponse> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's really good to return such response to public. It might contain some confidential information.

@Ignas-rgb
Ignas-rgb marked this pull request as draft June 5, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants