Closed mokaddem closed 1 month ago
I started to poe around a bit and it looks pretty good (the mypy issues are mostly trivial to solve). But there is a problem with AnalystDataBehaviorMixin
and AbstractMISP
and the edited
property.
Would it make sense to have AnalystDataBehaviorMixin
as a subclass of AbstractMISP
?
Do you mean keeping the inheritance from all the different data structures (MISPAttribute, MISPObject, MISPEvent, and so on…) to both AbstractMISP
and AnalystDataBehaviorMixin
while making also AnalystDataBehaviorMixin
inherit from AbstractMISP
? (or even make all classes subclass of AnalystDataBehaviorMixin
and AnalystDataBehaviorMixin
subclass of AbstractMISP
?)
We discussed it in the office, and to me it sounded like one of the reasons for implementing AnalystDataBehaviorMixin
this way was to have the add_note
, add_relationship
, add_opinion
methods in one place instead of having them in each class - i.e the classes for the structures that can have a note, relationship or opinion, which are almost all the data structures except a few ones, like Tag
My points were:
to_json
, from_dict
and so on - are add_tag
and add_attribute
, which are only common to MISPEvent
and MISPAttribute
So in the end, I guess it is more a matter or implementation preference as both would work.
Moving the methods to MISPNote
, MISPOpinion
and MISPRelationship
would comply with the current implementation of the different classes but require to add all the methods in the different classes
Keeping AnalystDataBehaviorMixin
is a new implementation where it is an intermediate class between the existing ones and AbstractMISP
I'm fine with having the AnalystDataBehaviorMixin
being a standalone class we use as an extra parent whenever we need it.
The reason I was talking of AbstractMISP
as a potential parents to AnalystDataBehaviorMixin
is in case we need its features applied to the members of AnalystDataBehaviorMixin
. The main one being edited
, which if True
will make sure the timestamp
key is removed from the json when dumped, allowing MISP to only update the members that have actually been modified instead of everything in the event.
Closing as we have another PR open here https://github.com/MISP/PyMISP/pull/1212
Usage example