def find_by_last_days(self, days): time = datetime.now() - timedelta(days) iocs = list() cursor = self.collection.find({"date": {"$gt": time}}) for ioc in cursor: iocs.append(IOC(**ioc)) return iocs
def sync(self): r = requests.get(self.uri, timeout=60) info = r.text.split('\n') db = IOCModel() for url in info: if re.match(self.regex, url): self.data['domain'] = url feed = IOC(**self.data) db.save(feed)
def sync(self): r = requests.get(self.uri, timeout=60) info = r.text.split('\n') db = IOCModel() for ip in info: if re.match(self.regex, ip): self.data['ip'] = ip feed = IOC(**self.data) db.save(feed)
def find_by_key_value(self, key, value): iocs = list() cursor = self.collection.find( {key: { "$regex": ".*{}.*".format(value) }}) for ioc in cursor: iocs.append(IOC(**ioc)) return iocs
def sync(self): r = requests.get(self.uri, timeout=60) info = csv.reader(r.content.decode('utf-8').splitlines()) db = IOCModel() for line in info: if re.match(self.regex, line[0]): self.data['domain'] = line[2] self.data['threat'] = line[4] self.data['type'] = line[5] self.data['info'] = line[6] feed = IOC(**self.data) db.save(feed)
def sync(self): r = requests.get(self.uri, timeout=60) info = csv.reader(r.content.decode('utf-8', 'replace').splitlines()) db = IOCModel() for line in info: if re.match(self.regex, line[0]): self.data['threat'] = line[1] self.data['name'] = line[2] self.data['domain'] = line[4] self.data['isp'] = line[5] self.data['ip'] = line[6] self.data['asn'] = line[7] self.data['country'] = line[8] feed = IOC(**self.data) db.save(feed)
def post(self): data = request.get_json(force=True) self.db.save(IOC(**data)) return jsonify(data)
def find_by_key(self, key): iocs = list() for ioc in self.collection.find({key: {"$exists": True}}): iocs.append(IOC(**ioc)) return iocs
def find(self): iocs = list() for ioc in self.collection.find(): iocs.append(IOC(**ioc)) return iocs