Skip to content

Conversation

RoshniNaveenaS
Copy link
Contributor

@RoshniNaveenaS RoshniNaveenaS commented Aug 5, 2025

PR fix Reference - #231

Key Changes:

1) Unified and Improved Handler Registration for Draft vs Non-Draft

2) Standardized Draft and Non-Draft Handler Registration:

AttachmentsSrv.registerDraftUpdateHandlers() for drafts
AttachmentsSrv.registerUpdateHandlers() for non-drafts

3) Service Manager Authentication via mTLS in helper.js

4) Documentation Examples

5) Improved logs

Copy link
Collaborator

@vlovini vlovini left a comment

Choose a reason for hiding this comment

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

Code looks fine and seems be working fine - both non draft and draft entity (tested locally).

Just a little change in regards of the isAttachmentAnnotated function to be reviewed.

@vlovini
Copy link
Collaborator

vlovini commented Aug 11, 2025

Please, document the API usage

@RoshniNaveenaS RoshniNaveenaS requested a review from vlovini August 12, 2025 02:37
@RoshniNaveenaS
Copy link
Contributor Author

Code looks fine and seems be working fine - both non draft and draft entity.

Just a little change in regards of the isAttachmentAnnotated function to be reviewed.

have added the same

@RoshniNaveenaS
Copy link
Contributor Author

Please, document the API usage

have added it in the readme, have referenced to the ./tests/non-draft-request.http where I have updated the Requests with UpID

Copy link

@maheshsooryambylu maheshsooryambylu left a comment

Choose a reason for hiding this comment

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

There were couple of review comments based on logging and potential issue based on usage inconsistency

await updateStatus(AttachmentsSrv, key, "Scanning", currEntity, draftEntity, activeEntity)

const credentials = getCredentials()
DEBUG?.(`Malware Scanning: Scanning content to entity ${key} - credentials = ${JSON.stringify(credentials)}`);

Choose a reason for hiding this comment

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

We should not log credentials in any log output

Copy link
Collaborator

Choose a reason for hiding this comment

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

This log was added just for debug options. I was having several problem with credentials checking, thought it would be useful. May be removed if you find insecure.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll move this to a separate PR.

const contentStream = await AttachmentsSrv.get(currEntity, key)

DEBUG?.(`Malware Scanning: Scanning content to entity ${key} - contentStream = ${contentStream}`);

Choose a reason for hiding this comment

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

Are we logging contentStream binary ? What purpose does it serve?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above - just checking if every step is being complete, since in BTP is not possible to debug with breakpoints.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll move this to a separate PR.

req.data.url = `${req.tenant}_${req.data.url}`;
}
req.data.ID = cds.utils.uuid()
let ext = extname(req.data.filename).toLowerCase().slice(1)

Choose a reason for hiding this comment

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

Is there any chance the user sends the request with a file without extension? Will this code break if extension is not there for file ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like that if nothing is found at the Ext2MimeTypes map, it will fallback as "application/octet-stream" mime type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, The code will not break if there’s no file extension. It will simply assign mimeType = "application/octet-stream".

@RoshniNaveenaS
Copy link
Contributor Author

Hello @vlovini ,
Error handling and adding more debug logs could be taken in a seperate PR?
Can we merge this PR for now?

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.

5 participants