Beispiel #1
0
 def run(self):
     global logger, misp, lock
     if not misp:
         return
     while self._running():
         try:
             sighting = self.outq.get(block=True, timeout=1)
         except Empty:
             continue
         misp_sighting = stix2_sighting_to_misp(sighting)
         lock.acquire()
         resp = misp.add_sighting(misp_sighting)
         if not resp or type(resp) is dict and resp.get("message", None):
             logger.error(
                 f"Failed to add sighting to MISP: '{sighting}' Error: {resp}"
             )
         else:
             logger.debug(f"Reported sighting: {resp}")
         lock.release()
         self.outq.task_done()
 def test_valid_stix_sighting(self):
     misp_sighting = stix2_sighting_to_misp(self.sighting)
     self.assertIsNotNone(misp_sighting)
     self.assertEqual(type(misp_sighting), MISPSighting)
 def test_invalid_stix_sightings(self):
     self.assertIsNone(stix2_sighting_to_misp(None))
     self.assertIsNone(stix2_sighting_to_misp("Hello"))
     self.assertIsNone(stix2_sighting_to_misp(self))