[fix] 修复关键字监控入库错误,新增关键字入库前检查是否有 cve 防止与 cve 监控重复推送
This commit is contained in:
parent
a1b9633afd
commit
c4f7f7818e
@ -1,12 +1,12 @@
|
|||||||
all_config:
|
all_config:
|
||||||
github_token: xxxxxx
|
github_token: xxxxxx
|
||||||
dingding:
|
dingding:
|
||||||
- enable: 0
|
- enable: 1
|
||||||
- webhook: xxxxxxx
|
- webhook: xxxxxxx
|
||||||
- secretKey: xxxxxxx
|
- secretKey: xxxxxxx
|
||||||
- app_name: dingding
|
- app_name: dingding
|
||||||
feishu:
|
feishu:
|
||||||
- enable: 1
|
- enable: 0
|
||||||
- webhook: xxx
|
- webhook: xxx
|
||||||
- app_name: feishu
|
- app_name: feishu
|
||||||
server:
|
server:
|
||||||
@ -25,4 +25,4 @@ all_config:
|
|||||||
translate:
|
translate:
|
||||||
- enable: 0
|
- enable: 0
|
||||||
black_user:
|
black_user:
|
||||||
- AlAIAL90
|
- AlAIAL90
|
@ -143,11 +143,8 @@ def getKeywordNews(keyword):
|
|||||||
today_keyword_info_tmp = []
|
today_keyword_info_tmp = []
|
||||||
try:
|
try:
|
||||||
# 抓取本年的
|
# 抓取本年的
|
||||||
year = datetime.datetime.now().year
|
|
||||||
api = "https://api.github.com/search/repositories?q={}&sort=updated".format(keyword)
|
api = "https://api.github.com/search/repositories?q={}&sort=updated".format(keyword)
|
||||||
json_str = requests.get(api, headers=github_headers, timeout=10).json()
|
json_str = requests.get(api, headers=github_headers, timeout=10).json()
|
||||||
# cve_total_count = json_str['total_count']
|
|
||||||
# cve_description = json_str['items'][0]['description']
|
|
||||||
today_date = datetime.date.today()
|
today_date = datetime.date.today()
|
||||||
n = len(json_str['items'])
|
n = len(json_str['items'])
|
||||||
if n > 20:
|
if n > 20:
|
||||||
@ -161,8 +158,9 @@ def getKeywordNews(keyword):
|
|||||||
pushed_at = re.findall('\d{4}-\d{2}-\d{2}', pushed_at_tmp)[0]
|
pushed_at = re.findall('\d{4}-\d{2}-\d{2}', pushed_at_tmp)[0]
|
||||||
if pushed_at == str(today_date):
|
if pushed_at == str(today_date):
|
||||||
today_keyword_info_tmp.append({"keyword_name": keyword_name, "keyword_url": keyword_url, "pushed_at": pushed_at})
|
today_keyword_info_tmp.append({"keyword_name": keyword_name, "keyword_url": keyword_url, "pushed_at": pushed_at})
|
||||||
|
print("[+] keyword: {} ,{}".format(keyword, keyword_name))
|
||||||
else:
|
else:
|
||||||
print("[-] 该{}的更新时间为{}, 不属于今天".format(keyword_name, pushed_at))
|
print("[-] keyword: {} ,该{}的更新时间为{}, 不属于今天".format(keyword, keyword_name, pushed_at))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -176,7 +174,7 @@ def getKeywordNews(keyword):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e, "github链接不通")
|
print(e, "github链接不通")
|
||||||
return '', '', ''
|
return today_keyword_info_tmp
|
||||||
|
|
||||||
#获取到的关键字仓库信息插入到数据库
|
#获取到的关键字仓库信息插入到数据库
|
||||||
def keyword_insert_into_sqlite3(data):
|
def keyword_insert_into_sqlite3(data):
|
||||||
@ -208,13 +206,16 @@ def get_today_keyword_info(today_keyword_info_data):
|
|||||||
for i in range(len(today_keyword_info_data)):
|
for i in range(len(today_keyword_info_data)):
|
||||||
try:
|
try:
|
||||||
today_keyword_name = today_keyword_info_data[i]['keyword_name']
|
today_keyword_name = today_keyword_info_data[i]['keyword_name']
|
||||||
if exist_cve(today_keyword_name) == 1:
|
today_cve_name = re.findall('(CVE\-\d+\-\d+)', today_keyword_info_data[i]['keyword_name'].upper())
|
||||||
Verify = query_keyword_info_database(today_keyword_name)
|
# 如果仓库名字带有 cve-xxx-xxx, 先查询看看 cve 监控中是否存在, 防止重复推送
|
||||||
if Verify == 0:
|
if len(today_cve_name) > 0 and query_cve_info_database(today_cve_name.upper()) == 1:
|
||||||
print("[+] 数据库里不存在{}".format(today_keyword_name))
|
pass
|
||||||
today_all_keyword_info.append(today_keyword_info_data[i])
|
Verify = query_keyword_info_database(today_keyword_name)
|
||||||
else:
|
if Verify == 0:
|
||||||
print("[-] 数据库里存在{}".format(today_keyword_name))
|
print("[+] 数据库里不存在{}".format(today_keyword_name))
|
||||||
|
today_all_keyword_info.append(today_keyword_info_data[i])
|
||||||
|
else:
|
||||||
|
print("[-] 数据库里存在{}".format(today_keyword_name))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
return today_all_keyword_info
|
return today_all_keyword_info
|
||||||
@ -618,6 +619,7 @@ if __name__ == '__main__':
|
|||||||
# 关键字监控 , 最好不要太多关键字,防止 github 次要速率限制 https://docs.github.com/en/rest/overview/resources-in-the-rest-api#secondary-rate-limits=
|
# 关键字监控 , 最好不要太多关键字,防止 github 次要速率限制 https://docs.github.com/en/rest/overview/resources-in-the-rest-api#secondary-rate-limits=
|
||||||
for keyword in keyword_list:
|
for keyword in keyword_list:
|
||||||
keyword_data = getKeywordNews(keyword)
|
keyword_data = getKeywordNews(keyword)
|
||||||
|
|
||||||
if len(keyword_data) > 0:
|
if len(keyword_data) > 0:
|
||||||
today_keyword_data = get_today_keyword_info(keyword_data)
|
today_keyword_data = get_today_keyword_info(keyword_data)
|
||||||
if len(today_keyword_data) > 0:
|
if len(today_keyword_data) > 0:
|
||||||
|
@ -15,6 +15,7 @@ tools_list:
|
|||||||
- https://api.github.com/repos/EdgeSecurityTeam/Vulnerability
|
- https://api.github.com/repos/EdgeSecurityTeam/Vulnerability
|
||||||
|
|
||||||
keyword_list:
|
keyword_list:
|
||||||
|
- Sql注入
|
||||||
- rce
|
- rce
|
||||||
- cnvd
|
- cnvd
|
||||||
- 未授权
|
- 未授权
|
||||||
|
Loading…
Reference in New Issue
Block a user