Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

初次运行console模式、添加规则时没有添加规则level值 #168

Closed
mark0smith opened this issue Jul 28, 2021 · 0 comments
Closed

Comments

@mark0smith
Copy link
Contributor

System and Python Environment

Item Tooltip Value
System uname -a Windows 10
Python python -V Python 3.9.2
Cobra python kunlun.py v2.5.1

Description

初次运行console模式、添加规则时没有添加规则level值。

Kunlun-M/core/rule.py

Lines 182 to 189 in 2e26ae9

r = Rules(rule_name=ruleclass.vulnerability, svid=ruleclass.svid,
language=ruleclass.language.lower(), author=ruleclass.author,
description=ruleclass.description, status=ruleclass.status,
match_mode=ruleclass.match_mode, match=ruleclass.match,
match_name=match_name, black_list=black_list, unmatch=unmatch, keyword=keyword,
vul_function=ruleclass.vul_function, main_function=main_function_content)
r.save()

上面代码没添加level值进数据库,导致添加到数据库规则里的level值均为5。

class Rules(models.Model):
rule_name = models.CharField(max_length=50)
svid = models.CharField(max_length=10)
language = models.CharField(max_length=20)
author = models.CharField(max_length=20)
description = models.TextField(null=True)
level = models.IntegerField(default=5)

Steps to Reproduce

Move-Item -Path .\Kunlun_M\settings.py.bak -Destination .\Kunlun_M\settings.py
python .\kunlun.py init initialize
python .\kunlun.py console # 直接输入exit,退出console模式
python .\kunlun.py console # 再次运行,就会报错

报错信息为:

 [23:38:44] [INIT] RuleCheck start.
 [23:38:44] [INIT][Load Rules] Check Rule CVI_5001 硬编码密码
 [23:38:44] [INIT][Rule Check] CVI_5001 config level has changed:
 [23:38:44] [INIT][Rule Check] level in Rule File is 2
 [23:38:44] [INIT][Rule Check] level in Database is 5
 [23:38:44] [INIT][Rule Check] whether load new level from Rule File(Y/N):

Step to Fix

/core/rule.py的第182行至 第187行之间,加入level=ruleclass.level,即可。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant