CERT-Polska / mwdblib

Client library for the mwdb service by CERT Polska.
https://mwdblib.readthedocs.io/en/latest/
MIT License
40 stars 13 forks source link

Feature request: implement remove_comment function #86

Closed jasperla closed 1 year ago

jasperla commented 1 year ago

Currently it's not possible to remove comments from samples, even though it's possible to add them with add_comment(). There are functions to remove tags and attributes, and it would be helpful if it's also possible to remove comments.

Comments already have a unique ID associated with them which could be used as the parameter to a new remove_comment() function.

I have not checked if mwdb-core needs support for this or if a DELETE request is already handled.

msm-code commented 1 year ago

FWIW looks like mwdb-core supports it: https://github.com/CERT-Polska/mwdb-core/blob/504ad2f7d4c3c96fbf3fdf6b0fd7e88639ce33c2/mwdb/resources/comment.py#L143

msm-code commented 1 year ago

Also just checked: this can be easily achieved with mwdblib low-level facilities already:

>>> m
<mwdblib.core.MWDB object at 0x7fad48dd6f40>
>>> m.api
<mwdblib.api.api.APIClient object at 0x7fad48da00d0>
>>> o.id
'95541fdb28429005ded498da8314f343ad592e1c4e5ecdfa71023533738764bb'
>>> o.comments[0].id
1
>>> m.api.delete(f"object/{o.id}/comment/{o.comments[0].id}")
msm-code commented 1 year ago

Hell, since I've already reproduced it and all, I've created a PR for this: https://github.com/CERT-Polska/mwdblib/pull/87