def test_extractHashesFromText_argument_data_should_return_hahes(self): md5_hash = "e17cff4eb3e8fbe6ca3b83fb47532dba" sha1_hash = "f81efbe70f8116fcf3dc4e9b37725dcb949719f5" sha256_hash = "7cd444af3d8de9e195b1f1cb55e7b7d9409dcd4648247c853a2f64b7578dc9b7" sha512_hash = "a55a2fe120d7d7d6e2ba930e6c56faa30b9d24a3178a0aff1d89312a89d61d8a9d5b7743e3af6b1a318d99974a1145ed76f85aa8c6574074dfb347613ccd3249" hashes = SpiderFootHelpers.extractHashesFromText( f"spiderfoot{md5_hash}spiderfoot{sha1_hash}spiderfoot{sha256_hash}spiderfoot{sha512_hash}spiderfoot" ) self.assertIsInstance(hashes, list) self.assertIn(("MD5", md5_hash), hashes) self.assertIn(("SHA1", sha1_hash), hashes) self.assertIn(("SHA256", sha256_hash), hashes) self.assertIn(("SHA512", sha512_hash), hashes)
def handleEvent(self, event): eventName = event.eventType srcModuleName = event.module eventData = event.data self.debug(f"Received event, {eventName}, from {srcModuleName}") hashes = SpiderFootHelpers.extractHashesFromText(eventData) for hashtup in hashes: hashalgo, hashval = hashtup evt = SpiderFootEvent("HASH", f"[{hashalgo}] {hashval}", self.__name__, event) if event.moduleDataSource: evt.moduleDataSource = event.moduleDataSource else: evt.moduleDataSource = "Unknown" self.notifyListeners(evt)
def test_extractHashesFromText_should_return_a_list(self): invalid_types = [None, list(), dict(), int()] for invalid_type in invalid_types: with self.subTest(invalid_type=invalid_type): hashes = SpiderFootHelpers.extractHashesFromText(invalid_type) self.assertIsInstance(hashes, list)