You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As Analyst Data - such as Note, Opinion and Relationship - can be attached to many different data layers, including themselves, all the PyMISP objects inheriting from AnalystDataBehaviorMixin will have the 'Note', 'Opinion' and 'Relationship' fields set to an empty list at their creation.
Then, from_dict populates those fields when needed or leave them empty.
This behavior is causing an issue when we want to use our favorite helpers to populate the different data layers with contained information, for example when using add_attribute at the Event or Object level, in the case where the Attribute contains a Note, Opinion or Relationship created with the related PyMISP object.
In order to have a better understanding, here is the situation described with a few lines of code:
frompymispimportMISPEvent, MISPAttributeevent=MISPEvent()
attribute=MISPAttribute()
attribute.from_dict(type='domain', value='circl.lu')
attribute.add_note(note='CIRCL domain')
# at this stage `add_note` generated a MISPNote and used the `from_dict` method defined in the MISPNote classevent.add_attribute(**attribute)
# this is where the issue happens
The issue appears here because of the following succession of events:
In add_attribute, a MISPAttribute is declared, its from_dict method is called
Then the from_dict method of AnalystDataBehaviorMixin is called
It finds the analyst note within the 'Note' field, it is the MISPNote object mentioned in the code sample
This MISPNote object has also a 'Note' field as any other AnalystDataBehaviorMixin object, it is here an empty list
The information describing the note is replaced here with the empty list
An issue is raised here as kwargs is no longer a dict containing the note fields, but an empty list
This is my example with an Attribute, but it should also impact any data layer containing a Note, Opinion or Relationship, including when there is a Note or Opinion of another Note or Opinion...
NB: no issue is raised when describing a Note, Opinion or Relationship using JSON format or a python dict but you know... the different helpers are there to make our lives easier, let's use them
The text was updated successfully, but these errors were encountered:
As Analyst Data - such as Note, Opinion and Relationship - can be attached to many different data layers, including themselves, all the PyMISP objects inheriting from
AnalystDataBehaviorMixin
will have the'Note'
,'Opinion'
and'Relationship'
fields set to an empty list at their creation.Then,
from_dict
populates those fields when needed or leave them empty.This behavior is causing an issue when we want to use our favorite helpers to populate the different data layers with contained information, for example when using
add_attribute
at the Event or Object level, in the case where the Attribute contains a Note, Opinion or Relationship created with the related PyMISP object.In order to have a better understanding, here is the situation described with a few lines of code:
The issue appears here because of the following succession of events:
add_attribute
, a MISPAttribute is declared, itsfrom_dict
method is calledfrom_dict
method ofAnalystDataBehaviorMixin
is called'Note'
field, it is the MISPNote object mentioned in the code sample'Note'
field as any otherAnalystDataBehaviorMixin
object, it is here an empty listkwargs
is no longer a dict containing the note fields, but an empty listThis is my example with an Attribute, but it should also impact any data layer containing a Note, Opinion or Relationship, including when there is a Note or Opinion of another Note or Opinion...
NB: no issue is raised when describing a Note, Opinion or Relationship using JSON format or a python dict but you know... the different helpers are there to make our lives easier, let's use them
The text was updated successfully, but these errors were encountered: