mirror of https://github.com/MISP/PyMISP
fix: Allow to pass value, UUID, or ID to a sighting.
parent
076393d55e
commit
837372cf3e
|
@ -1326,16 +1326,18 @@ class PyMISP(object):
|
||||||
jdata = json.load(f)
|
jdata = json.load(f)
|
||||||
return self.set_sightings(jdata)
|
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.
|
""" Set a single sighting.
|
||||||
:value: Value can either be the attribute's value (to update sighting on all the attributes with this value),
|
:value: Value of the attribute the sighting is related too. Pushing this object
|
||||||
or an UUID in order to update the sightings of one particular attribute.
|
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
|
:source: Source of the sighting
|
||||||
:type: Type of the sighting
|
:type: Type of the sighting
|
||||||
:timestamp: Timestamp associated to the sighting
|
:timestamp: Timestamp associated to the sighting
|
||||||
"""
|
"""
|
||||||
s = MISPSighting()
|
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)
|
return self.set_sightings(s)
|
||||||
|
|
||||||
# ############## Sharing Groups ##################
|
# ############## Sharing Groups ##################
|
||||||
|
|
|
@ -752,15 +752,19 @@ class MISPSighting(AbstractMISP):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(MISPSighting, self).__init__()
|
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
|
"""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),
|
:value: Value of the attribute the sighting is related too. Pushing this object
|
||||||
or an UUID in order to update the sightings of one particular attribute.
|
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
|
:source: Source of the sighting
|
||||||
:type: Type of the sighting
|
:type: Type of the sighting
|
||||||
:timestamp: Timestamp associated to the sighting
|
:timestamp: Timestamp associated to the sighting
|
||||||
"""
|
"""
|
||||||
self.value = value
|
self.value = value
|
||||||
|
self.uuid = uuid
|
||||||
|
self.id = id
|
||||||
self.source = source
|
self.source = source
|
||||||
self.type = type
|
self.type = type
|
||||||
self.timestamp = timestamp
|
self.timestamp = timestamp
|
||||||
|
@ -769,6 +773,10 @@ class MISPSighting(AbstractMISP):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
if hasattr(self, 'value'):
|
if hasattr(self, 'value'):
|
||||||
return '<{self.__class__.__name__}(value={self.value})'.format(self=self)
|
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)
|
return '<{self.__class__.__name__}(NotInitialized)'.format(self=self)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue