Merge pull request #22 from wuyoukm/patch-11
增加黑名单功能,防止恶意批量创建CVE导致CVE推送误报
This commit is contained in:
commit
f61ffdde72
@ -49,6 +49,12 @@ github_headers = {
|
|||||||
'Authorization': "token {}".format(load_config()[1]) # 替换自己的github token https://github.com/settings/tokens/new
|
'Authorization': "token {}".format(load_config()[1]) # 替换自己的github token https://github.com/settings/tokens/new
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#读取黑名单用户
|
||||||
|
def black_user():
|
||||||
|
with open('config.yaml', 'r') as f:
|
||||||
|
config = yaml.load(f, Loader=yaml.FullLoader)
|
||||||
|
black_user = config['all_config']['black_user']
|
||||||
|
return black_user
|
||||||
|
|
||||||
#初始化创建数据库
|
#初始化创建数据库
|
||||||
def create_database():
|
def create_database():
|
||||||
@ -93,20 +99,23 @@ def getNews():
|
|||||||
today_date = datetime.date.today()
|
today_date = datetime.date.today()
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
cve_url = json_str['items'][i]['html_url']
|
cve_url = json_str['items'][i]['html_url']
|
||||||
try:
|
if cve_url.split("/")[-2] not in black_user():
|
||||||
cve_name_tmp = json_str['items'][i]['name'].upper()
|
try:
|
||||||
cve_name = re.findall('(CVE\-\d+\-\d+)', cve_name_tmp)[0].upper()
|
cve_name_tmp = json_str['items'][i]['name'].upper()
|
||||||
except Exception as e:
|
cve_name = re.findall('(CVE\-\d+\-\d+)', cve_name_tmp)[0].upper()
|
||||||
pass
|
except Exception as e:
|
||||||
pushed_at_tmp = json_str['items'][i]['pushed_at']
|
pass
|
||||||
pushed_at = re.findall('\d{4}-\d{2}-\d{2}', pushed_at_tmp)[0]
|
pushed_at_tmp = json_str['items'][i]['pushed_at']
|
||||||
# today_cve_info_tmp.append({"cve_name": cve_name, "cve_url": cve_url, "pushed_at": pushed_at})
|
pushed_at = re.findall('\d{4}-\d{2}-\d{2}', pushed_at_tmp)[0]
|
||||||
if pushed_at == str(today_date):
|
# today_cve_info_tmp.append({"cve_name": cve_name, "cve_url": cve_url, "pushed_at": pushed_at})
|
||||||
today_cve_info_tmp.append({"cve_name":cve_name,"cve_url":cve_url,"pushed_at":pushed_at})
|
if pushed_at == str(today_date):
|
||||||
|
today_cve_info_tmp.append({"cve_name":cve_name,"cve_url":cve_url,"pushed_at":pushed_at})
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("[-] 该{}的更新时间为{},不属于今天的CVE".format(cve_name,pushed_at))
|
||||||
|
logging.info("[-] 该{}的更新时间为{},不属于今天的CVE".format(cve_name,pushed_at))
|
||||||
else:
|
else:
|
||||||
print("[-] 该{}的更新时间为{},不属于今天的CVE".format(cve_name,pushed_at))
|
logging.info("该{},属于黑名单用户{}提交的CVE".format(cve_name,cve_url.split("/")[-2]))
|
||||||
logging.info("[-] 该{}的更新时间为{},不属于今天的CVE".format(cve_name,pushed_at))
|
|
||||||
today_cve_info = OrderedDict()
|
today_cve_info = OrderedDict()
|
||||||
for item in today_cve_info_tmp:
|
for item in today_cve_info_tmp:
|
||||||
today_cve_info.setdefault(item['cve_name'], {**item, })
|
today_cve_info.setdefault(item['cve_name'], {**item, })
|
||||||
|
Loading…
Reference in New Issue
Block a user