Merge pull request #23 from wuyoukm/patch-12

修复 未经过判断就把不存在的CVE写入数据库
This commit is contained in:
yhy 2021-09-03 16:30:51 +08:00 committed by GitHub
commit 9e2cfcdada
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)