Skip to content

Commit

Permalink
Merge pull request momosecurity#71 from wangtongzhe/fix-config-weight
Browse files Browse the repository at this point in the history
新增规则权重重复检查逻辑
  • Loading branch information
Flynnon authored Apr 12, 2021
2 parents b46b862 + dd7f390 commit 90577d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions www/rule/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def clean(self):

strategys_list = cd['strategys'].split(',')
controls = cd['controls'].split(',')
weights = cd['weights'].split(',')
customs = cd.get('customs', '').split(':::')
names = cd['names'].split(':::')
if not len(strategys_list) == len(controls) == len(customs) == len(
Expand All @@ -114,6 +115,8 @@ def clean(self):
strategy_uuids.append("".join(item))
if len(set(strategy_uuids)) < len(strategy_uuids):
self.errors['strategys'] = [u'策略原子有重复']
if len(set(weights)) < len(weights):
self.errors['weights'] = ['存在重复权重配置']
return cd

def save(self, *args, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions www/rule/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ def _parse_data(self, request):
strategy_uuids.append("".join(item))
if len(set(strategy_uuids)) < len(strategy_uuids):
raise ValueError(u"策略原子有重复")
if len(set(weights)) < len(weights):
raise ValueError("存在重复权重配置")
for key in (
'title', 'describe', 'names', 'weights', 'strategys',
'controls',
Expand Down

0 comments on commit 90577d8

Please sign in to comment.