Update github_cve_monitor.py

配置文件标准化,修复BUG
This commit is contained in:
wuyoukm 2021-08-27 17:30:36 +08:00 committed by GitHub
parent b24ef08d64
commit d199c260a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,21 +27,21 @@ def load_config():
with open('config.yaml', 'r') as f: with open('config.yaml', 'r') as f:
config = yaml.load(f,Loader=yaml.FullLoader) config = yaml.load(f,Loader=yaml.FullLoader)
github_token = config['all_config']['github_token'] github_token = config['all_config']['github_token']
if int(config['all_config']['dingding'][0].split(":")[1]) == 1: if int(config['all_config']['dingding'][0]['enable']) == 1:
dingding_webhook = "https:"+config['all_config']['dingding'][1].split(":")[2] dingding_webhook = config['all_config']['dingding'][1]['webhook']
dingding_secretKey = config['all_config']['dingding'][2].split(":")[1] dingding_secretKey = config['all_config']['dingding'][2]['secretKey']
app_name = config['all_config']['dingding'][3].split(":")[1] app_name = config['all_config']['dingding'][3]['app_name']
return app_name,github_token,dingding_webhook,dingding_secretKey return app_name,github_token,dingding_webhook,dingding_secretKey
elif int(config['all_config']['server'][0].split(":")[1]) == 1: elif int(config['all_config']['server'][0]['enable']) == 1:
server_sckey = config['all_config']['server'][1].split(":")[1] server_sckey = config['all_config']['server'][1]['sckey']
app_name = config['all_config']['server'][2].split(":")[1] app_name = config['all_config']['server'][2]['app_name']
return app_name,github_token,server_sckey return app_name,github_token,server_sckey
elif int(config['all_config']['tgbot'][0].split(":")[1]) ==1 : elif int(config['all_config']['tgbot'][0]['enable']) ==1 :
tgbot_token = config['all_config']['tgbot'][1].split(":")[1] tgbot_token = config['all_config']['tgbot'][1]['token']
tgbot_group_id = config['all_config']['tgbot'][2].split(":")[1] tgbot_group_id = config['all_config']['tgbot'][2]['group_id']
app_name = config['all_config']['tgbot'][3].split(":")[1] app_name = config['all_config']['tgbot'][3]['app_name']
return app_name,github_token,tgbot_token,tgbot_group_id return app_name,github_token,tgbot_token,tgbot_group_id
elif int(config['all_config']['tgbot'][0].split(":")[1]) == 0 and int(config['all_config']['server'][0].split(":")[1]) == 0 and int(config['all_config']['dingding'][0].split(":")[1]) == 0: elif int(config['all_config']['tgbot'][0]['enable']) == 0 and int(config['all_config']['server'][0]['enable']) == 0 and int(config['all_config']['dingding'][0]['enable']) == 0:
print("[-] 配置文件有误三个社交软件的enable不能为0") print("[-] 配置文件有误三个社交软件的enable不能为0")
logging.error("[-] 配置文件有误三个社交软件的enable不能为0") logging.error("[-] 配置文件有误三个社交软件的enable不能为0")