diff --git a/pymisp/api.py b/pymisp/api.py index 81f9f938f..e17e464e1 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -1326,16 +1326,18 @@ def sighting_per_json(self, json_file): jdata = json.load(f) return self.set_sightings(jdata) - def sighting(self, value, source=None, type=None, timestamp=None, **kwargs): + def sighting(self, value=None, uuid=None, id=None, source=None, type=None, timestamp=None, **kwargs): """ Set a single sighting. - :value: Value can either be the attribute's value (to update sighting on all the attributes with this value), - or an UUID in order to update the sightings of one particular attribute. + :value: Value of the attribute the sighting is related too. Pushing this object + will update the sighting count of each attriutes with thifs value on the instance + :uuid: UUID of the attribute to update + :id: ID of the attriute to update :source: Source of the sighting :type: Type of the sighting :timestamp: Timestamp associated to the sighting """ s = MISPSighting() - s.from_dict(value=value, source=source, type=type, timestamp=timestamp, **kwargs) + s.from_dict(value=value, uuid=uuid, id=id, source=source, type=type, timestamp=timestamp, **kwargs) return self.set_sightings(s) # ############## Sharing Groups ################## diff --git a/pymisp/mispevent.py b/pymisp/mispevent.py index 26a98fce9..5d96719a3 100644 --- a/pymisp/mispevent.py +++ b/pymisp/mispevent.py @@ -752,15 +752,19 @@ class MISPSighting(AbstractMISP): def __init__(self): super(MISPSighting, self).__init__() - def from_dict(self, value, source=None, type=None, timestamp=None, **kwargs): + def from_dict(self, value=None, uuid=None, id=None, source=None, type=None, timestamp=None, **kwargs): """Initialize the MISPSighting from a dictionary - :value: Value can either be the attribute's value (to update sighting on all the attributes with this value), - or an UUID in order to update the sightings of one particular attribute. + :value: Value of the attribute the sighting is related too. Pushing this object + will update the sighting count of each attriutes with thifs value on the instance + :uuid: UUID of the attribute to update + :id: ID of the attriute to update :source: Source of the sighting :type: Type of the sighting :timestamp: Timestamp associated to the sighting """ self.value = value + self.uuid = uuid + self.id = id self.source = source self.type = type self.timestamp = timestamp @@ -769,6 +773,10 @@ def from_dict(self, value, source=None, type=None, timestamp=None, **kwargs): def __repr__(self): if hasattr(self, 'value'): return '<{self.__class__.__name__}(value={self.value})'.format(self=self) + if hasattr(self, 'id'): + return '<{self.__class__.__name__}(value={self.id})'.format(self=self) + if hasattr(self, 'uuid'): + return '<{self.__class__.__name__}(value={self.uuid})'.format(self=self) return '<{self.__class__.__name__}(NotInitialized)'.format(self=self)