def _store_in_db(self, scan, reaper=False, notes=None, tags=None): if reaper and not self._getSetting("reaper.store", False): return # Hash calculation to prevent duplicates sha1=codecs.encode(hashlib.sha1(json.dumps(scan).encode('utf-8')).digest(), "hex").decode("utf-8") if not db.p_queryData(self.collection, {'sha1': sha1}): data={"scan": scan, "sha1": sha1} if type(notes) == str: data["notes"] = notes if type(tags) == list: data["tags"] = tags db.p_addEntry(self.collection, data) return True return False
def search(self, text, **args): threat = [x["id"] for x in db.p_queryData(self.collectionName, {'threats': {"$regex": text, "$options": "-i"}})] misp_tag = [x["id"] for x in db.p_queryData(self.collectionName, {'tags': {"$regex": text, "$options": "-i"}})] return [{'n': 'Threat', 'd': threat}, {'n': 'MISP tag', 'd': misp_tag}]
def search(self, text, **args): if not args["current_user"].is_authenticated(): return data = [x["cve"] for x in db.p_queryData(self.collectionName, {"notes.notes":{"$regex": text, "$options": "-i"}, "notes.user": args["current_user"].get_id()})] return [{'n': 'Notes', 'd': data}]