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

feat: 策略配置优化 #418

Merged
merged 80 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
6eb1c5d
feat: 策略配置优化 --story=118179847
0RAJA Aug 2, 2024
25f55e1
Merge branch 'refs/heads/main' into feat_strategy_new
0RAJA Aug 5, 2024
1e7db56
feat: 策略配置优化 --story=118179847
0RAJA Aug 5, 2024
0b0f84c
feat: 策略配置优化 --story=118179847
0RAJA Aug 6, 2024
250c746
feat: 策略配置优化 --story=118179847
0RAJA Aug 6, 2024
058791f
feat: 策略配置优化 --story=118179847
0RAJA Aug 6, 2024
506adfc
feat: 策略配置优化 --story=118179847
nanasikeai Aug 6, 2024
414eeb4
feat: 变量复制添加前缀 --story=118179847
nanasikeai Aug 6, 2024
f7da7cb
feat: 策略配置优化 --story=118179847
0RAJA Aug 7, 2024
7585038
feat: 变量输入框 --story=118179847
nanasikeai Aug 7, 2024
70b091c
refactor: 策略配置优化 --story=118179847
0RAJA Aug 7, 2024
806102a
feat: 风险预览 --story=118179847
nanasikeai Aug 7, 2024
670da7b
feat: 风险等级不可编辑、点击页面空白关闭pop --story=118179847
nanasikeai Aug 8, 2024
16be529
feat: 编辑填充事件信息 --story=118179847
nanasikeai Aug 8, 2024
e68ce27
refactor: 策略配置优化 --story=118179847
0RAJA Aug 8, 2024
97fc1e3
refactor: 策略配置优化 --story=118179847
0RAJA Aug 8, 2024
fca57f3
feat: 策略详情 --story=118179847
nanasikeai Aug 9, 2024
ce872e1
refactor: 策略配置优化 --story=118179847
0RAJA Aug 9, 2024
f30ce9a
refactor: 策略配置优化 --story=118179847
0RAJA Aug 9, 2024
23ce80f
refactor: 策略配置优化 --story=118179847
0RAJA Aug 9, 2024
1a4a859
Merge pull request #406 from 0RAJA/feat_strategy_new
OrenZhang Aug 9, 2024
f9b6de1
feat: 风险单详情展示二期 --story=118188959
0RAJA Aug 5, 2024
aa4c4a7
feat: 风险单详情展示二期 --story=118188959
0RAJA Aug 7, 2024
cb0f70f
feat: 风险单详情展示二期 --story=118188959
0RAJA Aug 9, 2024
c7625af
Merge pull request #408 from 0RAJA/feat_risk_info
OrenZhang Aug 9, 2024
3257165
feat: 风险单详情展示二期 --story=118188959
nanasikeai Aug 12, 2024
e07773b
feat: 风险单详情展示二期 --story=118188959
0RAJA Aug 12, 2024
3b6d9aa
Merge pull request #410 from 0RAJA/feat_strategy_new
OrenZhang Aug 12, 2024
a7104d3
feat: 风险列表展示风险等级 --story=119035774
nanasikeai Aug 12, 2024
d0a5302
feat: 风险单详情展示二期-重点信息展示 --story=118188959
nanasikeai Aug 12, 2024
56565c5
feat: 风险API增加风险等级 --story=118332270
0RAJA Aug 12, 2024
aa798dd
Merge pull request #409 from 0RAJA/feat_risk_level
OrenZhang Aug 12, 2024
7d654eb
feat: 风险单详情展示二期 --story=118188959
0RAJA Aug 12, 2024
f519ddc
feat: 风险标题 --story=118188959
nanasikeai Aug 13, 2024
d24baf7
feat: 样式调整 --story=118188959
nanasikeai Aug 13, 2024
bdf8d34
fix: 资源,停用不可操作 --bug=128921873
nanasikeai Aug 14, 2024
c3f3620
fix: 增量全量更新,操作栏显示 --bug=128921663
nanasikeai Aug 14, 2024
760130f
fix: 调一下字段显示宽度 --bug=128920617
nanasikeai Aug 14, 2024
1869ebd
fix: 风险危害和风险指引的显示空间 --bug=128920161
nanasikeai Aug 14, 2024
5e79360
fix: 责任人,为啥要折叠 --bug=128920055
nanasikeai Aug 14, 2024
6709f43
fix: 预览,时间数据真实点 --bug=128919345
nanasikeai Aug 14, 2024
437d1dc
fix: 策略配置,高度差异 --bug=128918843
nanasikeai Aug 14, 2024
7e6f81f
fix: 策略配置,字段说明改为长文本输入框 --bug=128918607
nanasikeai Aug 14, 2024
53d63ca
fix: 策略配置,标题唤起变量配置的方式有问题 --bug=128918259
nanasikeai Aug 14, 2024
9d26916
fix: tag要折叠 --bug=128920055
nanasikeai Aug 15, 2024
fde6031
Merge pull request #412 from 0RAJA/feat_strategy_new
OrenZhang Aug 15, 2024
f7fe450
fix: 风险总结XSS注入 --bug=128469127
nanasikeai Aug 15, 2024
9519a1b
fix: 策略名称XSS注入 --bug=128468577
nanasikeai Aug 15, 2024
5a44658
fix: axios更新 --bug=128468577
nanasikeai Aug 16, 2024
ccbbd05
fix: 风险详情,模块间距不足 --bug=129255005
nanasikeai Aug 20, 2024
1c8caa7
fix: 新建策略,输入框组件间距不足 --bug=129255833
nanasikeai Aug 20, 2024
2bb2d7c
fix: 新建策略,缺省图位置偏移 --bug=129256017
nanasikeai Aug 20, 2024
39b9d31
fix: 风险详情,缺少字段空态占位展示 --bug=129256623
nanasikeai Aug 20, 2024
53b5af5
fix: 新建策略,表单溢出时,底部按钮没有按规范吸底 --bug=129256815
nanasikeai Aug 20, 2024
1610167
Merge remote-tracking branch 'tencent/main' into feat_strategy_new
OrenZhang Aug 21, 2024
52a41fc
fix: 策略配置,Enter粘贴变量 --bug=128918449
nanasikeai Aug 21, 2024
76af688
fix: 吸底计算 --bug=129256815
nanasikeai Aug 21, 2024
9495eba
fix: 按条件显示停用启用 --bug=128921663
nanasikeai Aug 21, 2024
d3758f3
fix: 策略配置,Enter生成tag --bug=128918449
nanasikeai Aug 22, 2024
c4e16ab
Merge remote-tracking branch 'base/feat_strategy_new' into feat_strat…
nanasikeai Aug 22, 2024
9604349
feat: 风险单详情展示二期 --story=118188959
0RAJA Aug 22, 2024
1a7bc24
Merge pull request #417 from 0RAJA/feat_strategy_new
OrenZhang Aug 22, 2024
5ccf922
Merge branch 'main' into feat_strategy_new
OrenZhang Aug 26, 2024
c991c45
docs: 补充翻译 --story=118188959
OrenZhang Aug 26, 2024
3d4e683
Merge remote-tracking branch 'tencent/main' into feat_strategy_new
OrenZhang Aug 26, 2024
41e95ea
Merge remote-tracking branch 'tencent/feat_strategy_new' into feat_st…
OrenZhang Aug 26, 2024
505c650
refactor: 代码优化 --story=118179847
nanasikeai Aug 27, 2024
1233888
fix: 国际化问题 --bug=129652813
nanasikeai Aug 27, 2024
1e4a3ca
refactor: 代码优化 --story=118179847
nanasikeai Aug 27, 2024
1f851e1
refactor: 代码优化 --story=118179847
nanasikeai Aug 28, 2024
184c883
fix: 风险详细-国际化问题 --bug=129788897
0RAJA Aug 29, 2024
5638004
fix: 重点信息字段格式没有与下方对齐 --bug=129786199
nanasikeai Aug 29, 2024
bc39c4c
Merge pull request #423 from 0RAJA/fix_strategy_translation
OrenZhang Aug 29, 2024
7f69236
fix: 切换数据关联状态时的预检查增加超时限制 --bug=129651075
0RAJA Aug 30, 2024
98d8265
Merge pull request #424 from 0RAJA/feat_pre_check_timeout
OrenZhang Aug 30, 2024
173c32c
fix: 风险等级、风险单名称输入提示国际化 --bug=129669795
nanasikeai Aug 30, 2024
4560e37
feat: 处理套餐执行动作获取异常 --story=119489432
0RAJA Sep 2, 2024
020bee3
Merge pull request #425 from 0RAJA/fix_template_resp
OrenZhang Sep 3, 2024
c223718
refactor: 代码优化 --story=118179847
nanasikeai Sep 4, 2024
333a5d3
Merge pull request #413 from nanasikeai/feat_strategy_new
OrenZhang Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions release.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
### V1.14.0 版本更新日志

- [ 新增 ] 资产拉取支持配置全量或增量拉取
- [ 新增 ] 风险列表展示风险等级
- [ 新增 ] 风险单详情增加信息展示
- [ 新增 ] 策略配置界面优化
- [ 优化 ] 资产拉取启动失败时展示异常信息
- [ 优化 ] 优化时间选择器交互体验
- [ 修复 ] 修复空间选择器标签偏移
Expand Down Expand Up @@ -63,7 +66,7 @@
- [ 新增 ] 操作日志审计切换为离线计算
- [ 新增 ] 方案参数映射配置时字段名称相同自动填充
- [ 优化 ] 增加AI策略运行周期校验
- [ 优化 ] 套餐配置参数只取标准运维全局变量中需要显示的字段
- [ 优化 ] 套餐配置参数只取标准运维全局变量中需要显示的字段
- [ 优化 ] 更新权限申请审计日志检索操作名称
- [ 优化 ] 适配新版本 BKVision 下拉菜单参数
- [ 修复 ] 修复检索页面完整日志样式异常的问题
Expand Down Expand Up @@ -197,10 +200,10 @@

### V1.1.0 版本更新日志

- [ 新增 ] 支持基于BCS的容器环境日志的采集
- [ 新增 ] 字段清洗支持正则清洗
- [ 优化 ] 支持复制应用系统负责人名单
- [ 优化 ] 应用系统接入模型中资源的操作优化为启用、停用
- [ 新增 ] 支持基于BCS的容器环境日志的采集
- [ 新增 ] 字段清洗支持正则清洗
- [ 优化 ] 支持复制应用系统负责人名单
- [ 优化 ] 应用系统接入模型中资源的操作优化为启用、停用
- [ 优化 ] 应用系统列表支持筛选数据上报状态
- [ 优化 ] 数据检索中操作人选项未输入内容时提示输入用户ID
- [ 优化 ] 数据检索中完整日志按钮显示压线
Expand Down
18 changes: 18 additions & 0 deletions src/backend/apps/notice/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
We undertake not to change the open source license (MIT license) applicable
to the current version of the project delivered to anyone in the future.
"""
from typing import List, Union

from bk_audit.log.models import AuditInstance
from bk_resource.utils.common_utils import get_md5
from django.db import models
from django.db.models import QuerySet
from django.utils.translation import gettext_lazy

from apps.notice.constants import RelateType
Expand Down Expand Up @@ -113,6 +115,22 @@ class Meta:
def audit_instance(self):
return NoticeGroupAuditInstance(self)

@property
def members(self) -> List[str]:
"""
处理组成员
"""

return list({member for member in self.group_member})

@classmethod
def parse_members(cls, groups: Union[QuerySet["NoticeGroup"], List["NoticeGroup"]]) -> List[str]:
"""
解析处理组成员
"""

return list({member for group in groups for member in group.members})


class NoticeLog(OperateRecordModel):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/backend/apps/sops/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@

class GetTemplatesRespSerializer(serializers.Serializer):
id = serializers.IntegerField()
name = serializers.CharField()
name = serializers.CharField(allow_blank=True)
url = serializers.CharField(required=False, allow_null=True, allow_blank=True)
1 change: 1 addition & 0 deletions src/backend/apps/user_manage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
25 changes: 25 additions & 0 deletions src/backend/apps/user_manage/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
TencentBlueKing is pleased to support the open source community by making
蓝鲸智云 - 审计中心 (BlueKing - Audit Center) available.
Copyright (C) 2023 THL A29 Limited,
a Tencent company. All rights reserved.
Licensed under the MIT License (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the
specific language governing permissions and limitations under the License.
We undertake not to change the open source license (MIT license) applicable
to the current version of the project delivered to anyone in the future.
"""

from django.apps import AppConfig
from django.utils.translation import gettext_lazy


class UserManageConfig(AppConfig):
name = "apps.user_manage"
verbose_name = gettext_lazy("用户管理")
35 changes: 35 additions & 0 deletions src/backend/apps/user_manage/resources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
"""
TencentBlueKing is pleased to support the open source community by making
蓝鲸智云 - 审计中心 (BlueKing - Audit Center) available.
Copyright (C) 2023 THL A29 Limited,
a Tencent company. All rights reserved.
Licensed under the MIT License (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the
specific language governing permissions and limitations under the License.
We undertake not to change the open source license (MIT license) applicable
to the current version of the project delivered to anyone in the future.
"""

from bk_resource import CacheResource, api
from bk_resource.exceptions import APIRequestError
from bk_resource.utils.cache import CacheTypeItem
from django.utils.translation import gettext_lazy


class RetrieveLeader(CacheResource):
name = gettext_lazy("获取单个用户的leader信息")
cache_type = CacheTypeItem(key="retrieve_leader", timeout=60 * 60, user_related=False)

def perform_request(self, validated_request_data):
try:
# 获取用户信息&解析出leader信息
user_info = api.user_manage.retrieve_user(validated_request_data)
return user_info.get("leader", [])[0].get("username", "")
except (IndexError, APIRequestError):
return ""
1 change: 1 addition & 0 deletions src/backend/config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"apps.bk_crypto",
"apps.sops",
"apps.itsm",
"apps.user_manage",
"bk_resource",
"rest_framework",
"drf_yasg",
Expand Down
43 changes: 43 additions & 0 deletions src/backend/core/render.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-

import json
import re
from typing import Dict, List, Union

from django.utils import translation
from jinja2 import Environment


def jinja2_environment(*args, **kwargs) -> Environment:
"""创建jinja2的环境执行环境 ."""
env = Environment(extensions=["jinja2.ext.i18n"], *args, **kwargs)
env.install_gettext_translations(translation, newstyle=True)
return env


class Jinja2Renderer:
"""
Jinja2渲染器
"""

def __init__(self, *args, **kwargs):
self.env = jinja2_environment(*args, **kwargs)

def _render(self, template_value: str, context: dict) -> str:
"""
只支持json和re函数
"""
return self.env.from_string(template_value).render({"json": json, "re": re, **context})

def jinja_render(self, template_value: Union[str, dict, list], context: dict) -> Union[str, Dict, List]:
"""使用jinja渲染对象 ."""
if isinstance(template_value, str):
return self._render(template_value, context) or template_value
if isinstance(template_value, dict):
render_value = {}
for key, value in template_value.items():
render_value[key] = self.jinja_render(value, context)
return render_value
if isinstance(template_value, list):
return [self.jinja_render(value, context) for value in template_value]
return template_value
Binary file modified src/backend/locale/en/LC_MESSAGES/django.mo
Binary file not shown.
90 changes: 86 additions & 4 deletions src/backend/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-23 11:58+0800\n"
"POT-Creation-Date: 2024-08-26 10:55+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -1874,6 +1874,12 @@ msgstr "Get Template Detail"
msgid "获取任务状态常量"
msgstr "List Task Status Constants"

msgid "用户管理"
msgstr "User Management"

msgid "获取单个用户的leader信息"
msgstr "Retrieve User Leader"

msgid "审计中心"
msgstr "BK Audit"

Expand Down Expand Up @@ -2934,6 +2940,9 @@ msgstr "Risk Label"
msgid "Last Operate Time"
msgstr "Last Operate Time"

msgid "Risk Title"
msgstr "Risk Title"

msgid "UUID"
msgstr "UUID"

Expand Down Expand Up @@ -3009,6 +3018,10 @@ msgstr "Authorized Time"
msgid "Ticket Permission"
msgstr "Ticket Permission"

#, python-format
msgid "(未获取到变量值:%s)"
msgstr "(Variable value not obtained:%s)"

msgid "创建事件"
msgstr "Create Event"

Expand Down Expand Up @@ -3045,6 +3058,9 @@ msgstr "Approve Build In Fields"
msgid "获取风险详情"
msgstr "Get Risk Detail"

msgid "获取风险策略信息"
msgstr "Obtain Risk Strategy Information"

msgid "获取风险列表"
msgstr "List Risk"

Expand Down Expand Up @@ -3163,6 +3179,9 @@ msgstr "Risk Type"
msgid "Event Content"
msgstr "Event Content"

msgid "Risk Level"
msgstr "Risk Level"

msgid "未配置审批流"
msgstr "Approve Service Not Set"

Expand Down Expand Up @@ -3193,6 +3212,15 @@ msgstr "New Operator"
msgid "不能转单给自己"
msgstr "Not allowed to trans to yourself"

msgid "Event Basic Field Configs"
msgstr "Event Basic Field Configs"

msgid "Event Data Field Configs"
msgstr "Event Data Field Configs"

msgid "Event Evidence Field Configs"
msgstr "Event Evidence Field Configs"

msgid "Sync BKM Alert Failed"
msgstr "Sync BKM Alert Failed"

Expand Down Expand Up @@ -3290,6 +3318,15 @@ msgstr "Public Field"
msgid "Extend Field"
msgstr "Extend Field"

msgid "高"
msgstr "High"

msgid "中"
msgstr "Middle"

msgid "低"
msgstr "Low"

msgid "Control Changed"
msgstr "Control Changed"

Expand Down Expand Up @@ -3324,6 +3361,24 @@ msgstr "Backend Data"
msgid "Notice Groups"
msgstr "Notice Groups"

msgid "Processor"
msgstr "Processor"

msgid "Risk Hazard"
msgstr "Risk Hazard"

msgid "Risk Guidance"
msgstr "Risk Guidance"

msgid "Event Field Configs"
msgstr "Event Field Configs"

msgid "Event Data Configs"
msgstr "Event Data Configs"

msgid "Event Evidence Configs"
msgstr "Event Evidence Configs"

msgid "Strategy"
msgstr "Strategy"

Expand Down Expand Up @@ -3375,6 +3430,30 @@ msgstr "Get RT Fields"
msgid "Get Strategy Status"
msgstr "Get Strategy Status"

msgid "Get Event Info Fields"
msgstr "Get Event Info Fields"

msgid "获取策略展示信息"
msgstr "Get Strategy Display Information"

msgid "Field Name"
msgstr "Field Name"

msgid "Field Display Name"
msgstr "Field Display Name"

msgid "Is Priority"
msgstr "Is Priority"

msgid "Field Description"
msgstr "Field Description"

msgid "Processor Groups"
msgstr "Processor Groups"

msgid "Processor Group"
msgstr "Processor Group"

msgid "Control Version not Exists"
msgstr "Control Version not Exists"

Expand Down Expand Up @@ -3420,9 +3499,6 @@ msgstr "Algorithms"
msgid "Detects"
msgstr "Detects"

msgid "Field Name"
msgstr "Field Name"

msgid "System ID"
msgstr "System ID"

Expand Down Expand Up @@ -3510,6 +3586,12 @@ msgstr "Strategy IDs"
msgid "Strategy ID Invalid"
msgstr "Strategy ID Invalid"

msgid "Display Name"
msgstr "Display Name"

msgid "Example"
msgstr "Example"

msgid "版本日志"
msgstr "Version Log"

Expand Down
Binary file modified src/backend/locale/zh_CN/LC_MESSAGES/django.mo
Binary file not shown.
Loading