Skip to content

Commit

Permalink
之前kunpeng的更新写少了插件初始化,导致即使自动更新也不会出现在插件列表中,通过推送功能更新kunpeng库后立刻安装替换原来的数据…
Browse files Browse the repository at this point in the history
…(会导致kunpeng类的插件统计归零)
  • Loading branch information
ywolf committed Mar 19, 2019
1 parent f4f7003 commit c0617e1
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions vulscan/vulscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,33 @@ def get_config():
except Exception, e:
print e

def install_kunpeng_plugin():
time_ = datetime.datetime.now()
for plugin in kp.get_plugin_list():
level_list = ['严重','高危','中危','低危','提示']
plugin_info = {
'_id': plugin['references']['kpid'],
'name': 'Kunpeng -' + plugin['name'],
'info': plugin['remarks'] + ' ' + plugin['references']['cve'],
'level': level_list[int(plugin['level'])],
'type': plugin['type'],
'author': plugin['author'],
'url': plugin['references']['url'],
'source': 1,
'keyword': '',
'add_time': time_,
'filename': plugin['references']['kpid'],
'count': 0
}
na_plugin.insert(plugin_info)

def init():
time_ = datetime.datetime.now()
if na_plugin.find().count() >= 1:
return
script_plugin = []
json_plugin = []
print 'init plugins'
file_list = os.listdir(sys.path[0] + '/vuldb')
for filename in file_list:
try:
Expand Down Expand Up @@ -282,23 +302,7 @@ def init():
na_plugin.insert(plugin_info)
except:
pass
for plugin in kp.get_plugin_list():
level_list = ['严重','高危','中危','低危','提示']
plugin_info = {
'_id': plugin['references']['kpid'],
'name': 'Kunpeng -' + plugin['name'],
'info': plugin['remarks'] + ' ' + plugin['references']['cve'],
'level': level_list[int(plugin['level'])],
'type': plugin['type'],
'author': plugin['author'],
'url': plugin['references']['url'],
'source': 1,
'keyword': '',
'add_time': time_,
'filename': plugin['references']['kpid'],
'count': 0
}
na_plugin.insert(plugin_info)
install_kunpeng_plugin()


def kp_check():
Expand All @@ -322,6 +326,7 @@ def kp_check():
'source': 'kunpeng'
}
na_update.insert(row)
time.sleep(60 * 60 * 48)
except Exception as e:
print e
time.sleep(60 * 30)
Expand All @@ -334,6 +339,8 @@ def kp_update():
{'source': 'kunpeng', 'isInstall': 1})
if row:
kp.update_version(row['unicode'])
na_plugin.delete_many({'_id':re.compile('^KP')})
install_kunpeng_plugin()
except Exception as e:
print e
time.sleep(10)
Expand Down

0 comments on commit c0617e1

Please sign in to comment.