diff --git a/github_cve_monitor.py b/github_cve_monitor.py index b87c8dc..42dc9f5 100644 --- a/github_cve_monitor.py +++ b/github_cve_monitor.py @@ -166,8 +166,9 @@ def get_today_cve_info(today_cve_info_data): for i in range(len(today_cve_info_data)): try: today_cve_name = re.findall('(CVE\-\d+\-\d+)', today_cve_info_data[i]['cve_name'])[0].upper() - logging.info("get_today_cve_info 函数 today_cve_name的值为 - > {}".format(today_cve_name)) - Verify = query_cve_info_database(today_cve_name.upper()) + if exist_cve(today_cve_name) == 1: + logging.info("get_today_cve_info 函数 today_cve_name的值为 - > {}".format(today_cve_name)) + Verify = query_cve_info_database(today_cve_name.upper()) except Exception as e: Verify = 1 if Verify == 0: @@ -418,6 +419,19 @@ def tgbot(text, msg,token,group_id): bot.send_message(chat_id=group_id, text='{}\r\n{}'.format(text, msg)) except Exception as e: logging.error("tgbot BUG -> {}".format(e)) + +#判断是否存在该CVE +def exist_cve(cve): + try: + query_cve_url = "https://cve.mitre.org/cgi-bin/cvename.cgi?name=" + cve + response = requests.get(query_cve_url, headers=github_headers, timeout=10) + html = etree.HTML(response.text) + des = html.xpath('//*[@id="GeneratedTable"]/table//tr[4]/td/text()')[0].strip() + return 1 + except Exception as e: + logging.error("CVE 官网连接 不通 or 不存在该 CVE 具体BUG -> {}".format(e)) + return 0 + # 根据cve 名字,获取描述,并翻译 def get_cve_des_zh(cve): time.sleep(3)