def to_cve(self, id): cve = CVEInfo() cve.id = id cve.src = self.NAME_CH() cve.url = self.url_cve + id self.get_cve_info(cve, cve.url) return cve
def to_cve(self, vul): cve = CVEInfo() cve.src = self.NAME_CH() cve.url = self.url_cve + vul[1] cve.time = vul[0] + time.strftime(" %H:%M:%S", time.localtime()) cve.title = re.sub(r'\(CVE-\d+-\d+\)', '', vul[2]) rst = re.findall(r'(CVE-\d+-\d+)', vul[2]) cve.id = rst[0] if rst else '' return cve
def to_cve(self, vul): cve = CVEInfo() cve.src = self.name_ch cve.url = self.url_cve + vul[1] cve.time = vul[0] + time.strftime(" %H:%M:%S", time.localtime()) cve.title = re.sub(r"\(CVE-\d+-\d+\)", "", vul[2]) rst = re.findall(r"(CVE-\d+-\d+)", vul[2]) cve.id = rst[0] if rst else "" return cve
def to_cve(self, json_obj): cve = CVEInfo() cve.src = self.name_ch cve.url = self.url_cve + json_obj["id"] cve.time = json_obj["pub_time"] title = json_obj.get("title") cve.title = re.sub(r"CVE-\d+-\d+", "", title).strip() rst = re.findall(r"(CVE-\d+-\d+)", title) cve.id = rst[0] if rst else "" return cve
def to_cve(self, json_obj): cve = CVEInfo() cve.src = self.NAME_CH() cve.url = self.url_cve + json_obj.get('id') cve.time = json_obj.get('pub_time') title = json_obj.get('title') cve.title = re.sub(r'CVE-\d+-\d+', '', title).strip() rst = re.findall(r'(CVE-\d+-\d+)', title) cve.id = rst[0] if rst else '' return cve
def to_cve(self, json_obj): cve = CVEInfo() cve.src = self.name_ch id = str(json_obj.get("id")) or "" cve.url = self.url_cve + id cve.title = json_obj.get("bug_title") or "" seconds = json_obj.get("updated_at") or 0 localtime = time.localtime(seconds) cve.time = time.strftime("%Y-%m-%d %H:%M:%S", localtime) self.get_cve_info(cve, id) return cve
def to_cve(self, json_obj): cve = CVEInfo() cve.src = self.NAME_CH() id = str(json_obj.get('id')) or '' cve.url = self.url_cve + id cve.title = json_obj.get('bug_title') or '' seconds = json_obj.get('updated_at') or 0 localtime = time.localtime(seconds) cve.time = time.strftime('%Y-%m-%d %H:%M:%S', localtime) self.get_cve_info(cve, id) return cve
def to_cve(self, item): cve = CVEInfo() cve.src = self.NAME_CH() _id = item.xpath("./title")[0].text cve.id = re.sub(r' \(.*?\)', '', _id) cve.url = self.url_cve + cve.id _time = item.xpath("./dc_date")[0].text cve.time = _time.replace('T', ' ').replace('Z', ' ') cve.info = item.xpath("./description")[0].text cve.title = cve.info return cve
def to_cve(self, item): cve = CVEInfo() cve.src = self.NAME_CH() cve.id = item.xpath("./title")[0].text cve.url = item.xpath("./link")[0].text _time = item.xpath("./pubDate")[0].text cve.time = datetime.strptime(_time, '%a, %d %b %Y %H:%M:%S GMT') _desc = item.xpath("./description")[0].text _desc = _desc.replace('\r', '').replace('\n', '') cve.info = re.findall(r'Description</h3>\s*<p>(.*?)</p>', _desc, re.DOTALL)[0].strip() cve.title = cve.info return cve
def to_cve(self, json_obj): cve = CVEInfo() cve.src = self.name_ch cve.url = self.url_cve + (json_obj.get("id") or "") cve.info = (json_obj.get("description") or "").strip().replace("\n\n", "\n") seconds = json_obj.get("update_time") or 0 localtime = time.localtime(seconds) cve.time = time.strftime("%Y-%m-%d %H:%M:%S", localtime) title = json_obj.get("title") or "" cve.title = re.sub(r"CVE-\d+-\d+:", "", title).strip() rst = re.findall(r"(CVE-\d+-\d+)", title) cve.id = rst[0] if rst else "" return cve
def to_cve(self, json_obj): cve = CVEInfo() cve.src = self.NAME_CH() cve.url = self.url_cve + (json_obj.get('id') or '') cve.info = (json_obj.get('description') or '').strip().replace('\n\n', '\n') seconds = json_obj.get('update_time') or json_obj.get('add_time') or 0 localtime = time.localtime(seconds) cve.time = time.strftime('%Y-%m-%d %H:%M:%S', localtime) title = json_obj.get('title') or '' cve.title = re.sub(r'CVE-\d+-\d+:', '', title).strip() rst = re.findall(r'(CVE-\d+-\d+)', title) cve.id = rst[0] if rst else '' return cve
def to_cve(self, xml): cve = CVEInfo() cve.src = self.NAME_CH() rst = re.findall(r'href="/vul/(.*?)">(.*?)</a>', xml, re.DOTALL) if rst: cve.url = self.url + rst[0][0] cve.title = rst[0][1].strip() rst = re.findall(r'(CVE-\d+-\d+)', xml) if rst: cve.id = rst[0] rst = re.findall(r'</i>(\d\d\d\d-\d\d-\d\d)', xml) if rst: cve.time = rst[1] + time.strftime(" %H:%M:%S", time.localtime()) return cve
def to_cve(self, json_obj, title): cve = CVEInfo() cve.src = self.name_ch cve.url = json_obj.get("permlink") or "" cve.info = (json_obj.get("abstract") or "").strip().replace("\n\n", "\n") cve.title = title.strip() utc_time = json_obj.get("publish_time") or "" # utc_time to datetime cve.time = utc_time.replace("T", " ").replace(".000Z", "") content = json_obj.get("content") rst = re.findall(r"ID(</strong>)?</td>\n<td>(.*?)</td>", content) if rst: if "<br>" in rst[0][1]: ids = rst[0][1].split("<br>") else: ids = rst[0][1].split(" ") cve.id = ", ".join(ids) return cve
def to_cve(self, json_obj, title): cve = CVEInfo() cve.src = self.NAME_CH() cve.url = json_obj.get('permlink') or '' cve.info = (json_obj.get('abstract') or '').strip().replace('\n\n', '\n') cve.title = title.strip() utc_time = json_obj.get('publish_time') or '' # utc_time to datetime cve.time = utc_time.replace('T', ' ').replace('.000Z', '') content = json_obj.get('content') rst = re.findall(r'ID(</strong>)?</td>\n<td>(.*?)</td>', content) if rst: if '<br>' in rst[0][1]: ids = rst[0][1].split('<br>') else: ids = rst[0][1].split(' ') cve.id = ', '.join(ids) return cve