Skip to content

Commit

Permalink
Merge pull request #589 from nanasikeai/feat_rule_audit
Browse files Browse the repository at this point in the history
Feat rule audit
  • Loading branch information
viouse authored Feb 20, 2025
2 parents e65b9e1 + 57372bd commit 7528fab
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 38 deletions.
1 change: 1 addition & 0 deletions src/frontend/src/views/link-data-manage/language/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ export default {
'操作记录数据源需保持一致,请修改第一个操作记录数据源': 'The operation record data source needs to be consistent. Please modify the first operation record data source.',
只能选择前面已选数据: 'Only previously selected data can be selected',
只能选择前面未选数据: 'Only previously unselected data can be selected',
查看关联策略: 'View association strategy',
},
};
1 change: 1 addition & 0 deletions src/frontend/src/views/link-data-manage/language/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ export default {
'操作记录数据源需保持一致,请修改第一个操作记录数据源': '操作记录数据源需保持一致,请修改第一个操作记录数据源',
只能选择前面已选数据: '只能选择前面已选数据',
只能选择前面未选数据: '只能选择前面未选数据',
查看关联策略: '查看关联策略',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,37 @@
<template #content>
<div
v-for="type in joinTypeList"
:key="type"
:key="type.value"
class="join-type-list"
:class="[type === joinType ? 'active' : '']"
@click="() => handleSelectJoinType(type)">
:class="[type.value === joinType ? 'active' : '']"
@click="() => handleSelectJoinType(type.value)">
<relation-ship
:active="type === joinType"
:active="type.value === joinType"
:height="10"
:join-type="type"
:join-type="type.value"
style="margin-right: 5px;"
type="gray"
:width="10" />
<span>{{ type }}</span>
<span>{{ type.label }}</span>
</div>
</template>
</bk-popover>
</template>
<script setup lang="ts">
import { ref } from 'vue';

interface Props {
joinTypeList: Array<Record<string, any>>
}

defineProps<Props>();

const joinType = defineModel<string>('joinType', {
default: 'left_join',
});

const isShow = ref(false);

const joinTypeList = ['left_join', 'right_join', 'inner_join', 'full_outer_join'];

const handleSelectJoinType = (type: string) => {
joinType.value = type;
isShow.value = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@
</select-verify>
</div>
<!-- 关联关系 -->
<join-type v-model:joinType="link.join_type" />
<join-type
v-model:joinType="link.join_type"
:join-type-list="joinTypeList" />
<!-- 右表 -->
<div class="right-name">
<bk-form-item
Expand Down Expand Up @@ -201,6 +203,7 @@
});
const linkTableTableTypeList = ref<Array<Record<string, any>>>([]);
const oldFirstLefType = ref('');
const joinTypeList = ref<Array<Record<string, any>>>([]);

const linksHeight = computed(() => {
const windowHeight = window.innerHeight;
Expand Down Expand Up @@ -348,6 +351,7 @@
manual: true,
onSuccess() {
linkTableTableTypeList.value = commonData.value.link_table_table_type;
joinTypeList.value = commonData.value.link_table_join_type;
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@
onClick() {
emits('showLinkStrategy', editUid.value as string);
},
}, '查看关联策略'),
}, t('查看关联策略')),
]),
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
label-width="135"
property="group_member">
<user-variable-select
allow-create
class="form-item-common"
:collapse-tags="collapseTags"
:model-value="formData.group_member"
Expand Down
9 changes: 5 additions & 4 deletions src/frontend/src/views/strategy-manage/language/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export default {
自定义规则审计: 'Rule',
配置方式: 'Configuration',
'指根据目前审计中可用的日志、资产数据,直接配置规则,得到审计结果的方式。适用于大部分复杂程度不高的场景策略。': 'Refers to the method of directly configuring rules and obtaining audit results based on the logs and asset data currently available in the audit. It is suitable for most scenarios with low complexity.',
'指先通过蓝鲸 bkbaseAIops 内开发场景模型后,在审计中心内配置字段映射生成策略的方式。适用于对 aiops 有数据开发能力,且需要实现的审计方案较复杂的情况。': 'Refers to the method of first developing a scenario model in AIops of Blue Whale bkbase, and then configuring the field mapping generation strategy in the audit center. It is suitable for situations where you have data development capabilities in aiops and need to implement a more complex audit solution.',
'指先通过蓝鲸 BKBaseAIOps 内开发场景模型后,在审计中心内配置字段映射生成策略的方式。适用于对 aiops 有数据开发能力,且需要实现的审计方案较复杂的情况。': 'Refers to the method of first developing a scenario model in AIops of Blue Whale BKBase, and then configuring the field mapping generation strategy in the audit center. It is suitable for situations where you have data development capabilities in AIOps and need to implement a more complex audit solution.',
规则配置: 'Rule Configuration',
预期结果: 'Expected Results',
风险发现规则: 'Risk Discovery Rules',
Expand All @@ -246,9 +246,9 @@ export default {
继续切换: 'Switching',
'刷新后,已配置的数据将被清空。是否继续?': 'After refreshing, the configured data will be cleared. Does it continue?',
请选择配置方式: 'Please select the Strategy_type',
'第1步,此处配置的审计风险数据的数据源,用以后续步骤的处理。一般由“操作记录”与“资产数据”组合合成,但也可以自由组合而成。': 'In step 1, the data source for the audit risk data configured here is used for the subsequent steps. It is usually a combination of “operation records” and “asset data”, but can be freely combined.',
'第2步,可配置聚合规则。若无规则,则结果默认返回所有字段并不做聚合;若有规则,则返回配置字段。': 'In step 2, you can configure the aggregation rules. If there is no rule, the result will return all fields by default without aggregation; if there is a rule, it will return the configured fields.',
'第3步,完成数据处理后,配置对应的字段规则,筛选出我们期望的数据可能是风险数据。': 'In step 3, after completing the data processing, the corresponding field rules are configured to filter out the data we expect, possibly the risk data.',
'审计规则的数据来源,联动后续步骤字段结构。如需组合数据,请提前创建并选择联表数据': 'The data source of the audit rules, linking the field structure of subsequent steps. If you need to combine data, please create and select joint table data in advance',
'需要哪些字段作为结果,每行记录可生成一个风险事件,展示在风险单内;也可用于第2步”单据展示“的字段映射;点击下方”预览“可提前预览风险单展示内容;': 'Which fields are required as results? Each row of records can generate a risk event and display it in the risk form; it can also be used for field mapping in step 2 of "Document Display"; click "Preview" below to preview the risk form display content in advance;',
'配置对应的字段与规则,筛选出我们期望的数据可能是风险数据。': 'Configure the corresponding fields and rules to filter out the data we expect; it may be risk data.',
'找不到合适的数据?': 'Can not find the right data?',
立即新建联表: 'New link table',
前往联表管理: 'Go to link table management',
Expand All @@ -262,5 +262,6 @@ export default {
前往查看详情: 'Go to details',
刷新数据源请注意: 'Pay attention to refresh data sources',
继续刷新: 'Refresh',
'按天则下一调度时间为当天0点;按小时则为下一调度时间为下个小时整点;并作为固定发起时间;': 'By day, the next scheduling time is 0:00 on the day; by hour, the next scheduling time is the hour of the next hour; and it is used as a fixed launch time;',
},
};
9 changes: 5 additions & 4 deletions src/frontend/src/views/strategy-manage/language/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export default {
自定义规则审计: '自定义规则审计',
配置方式: '配置方式',
'指根据目前审计中可用的日志、资产数据,直接配置规则,得到审计结果的方式。适用于大部分复杂程度不高的场景策略。': '指根据目前审计中可用的日志、资产数据,直接配置规则,得到审计结果的方式。适用于大部分复杂程度不高的场景策略。',
'指先通过蓝鲸 bkbaseAIops 内开发场景模型后,在审计中心内配置字段映射生成策略的方式。适用于对 aiops 有数据开发能力,且需要实现的审计方案较复杂的情况。': '指先通过蓝鲸 bkbaseAIops 内开发场景模型后,在审计中心内配置字段映射生成策略的方式。适用于对 aiops 有数据开发能力,且需要实现的审计方案较复杂的情况。',
'指先通过蓝鲸 BKBaseAIOps 内开发场景模型后,在审计中心内配置字段映射生成策略的方式。适用于对 aiops 有数据开发能力,且需要实现的审计方案较复杂的情况。': '指先通过蓝鲸 BKBaseAIOps 内开发场景模型后,在审计中心内配置字段映射生成策略的方式。适用于对 aiops 有数据开发能力,且需要实现的审计方案较复杂的情况。',
规则配置: '规则配置',
预期结果: '预期结果',
风险发现规则: '风险发现规则',
Expand All @@ -253,9 +253,9 @@ export default {
继续切换: '继续切换',
'刷新后,已配置的数据将被清空。是否继续?': '刷新后,已配置的数据将被清空。是否继续?',
请选择配置方式: '请选择配置方式',
'第1步,此处配置的审计风险数据的数据源,用以后续步骤的处理。一般由“操作记录”与“资产数据”组合合成,但也可以自由组合而成。': '第1步,此处配置的审计风险数据的数据源,用以后续步骤的处理。一般由“操作记录”与“资产数据”组合合成,但也可以自由组合而成。',
'第2步,可配置聚合规则。若无规则,则结果默认返回所有字段并不做聚合;若有规则,则返回配置字段。': '第2步,可配置聚合规则。若无规则,则结果默认返回所有字段并不做聚合;若有规则,则返回配置字段。',
'第3步,完成数据处理后,配置对应的字段规则,筛选出我们期望的数据可能是风险数据。': '第3步,完成数据处理后,配置对应的字段规则,筛选出我们期望的数据可能是风险数据。',
'审计规则的数据来源,联动后续步骤字段结构。如需组合数据,请提前创建并选择联表数据': '审计规则的数据来源,联动后续步骤字段结构。如需组合数据,请提前创建并选择联表数据',
'需要哪些字段作为结果,每行记录可生成一个风险事件,展示在风险单内;也可用于第2步”单据展示“的字段映射;点击下方”预览“可提前预览风险单展示内容;': '需要哪些字段作为结果,每行记录可生成一个风险事件,展示在风险单内;也可用于第2步”单据展示“的字段映射;点击下方”预览“可提前预览风险单展示内容;',
'配置对应的字段与规则,筛选出我们期望的数据可能是风险数据。': '配置对应的字段与规则,筛选出我们期望的数据可能是风险数据。',
'找不到合适的数据?': '找不到合适的数据?',
立即新建联表: '立即新建联表',
前往联表管理: '前往联表管理',
Expand All @@ -269,5 +269,6 @@ export default {
前往查看详情: '前往查看详情',
刷新数据源请注意: '刷新数据源请注意',
继续刷新: '继续刷新',
'按天则下一调度时间为当天0点;按小时则为下一调度时间为下个小时整点;并作为固定发起时间;': '按天则下一调度时间为当天0点;按小时则为下一调度时间为下个小时整点;并作为固定发起时间;',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
:description="subItem.description"
:label="subItem.display_name"
:label-width="labelWidth">
{{ t('以实际内容为准') }}
{{ subItem.map_config?.target_value || t('以实际内容为准') }}
</render-info-item>
</render-info-block>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

const getMetricName = (element: DatabaseTableFieldModel) => {
const item = props.aggregateList.find(item => item.value === element.aggregate);
return t(`[${item?.label}] ${element.display_name.replace(/_.*/, '')}`);
return t(`[${item?.label}] ${element.display_name}`);
};

const handleAdd = (item: DatabaseTableFieldModel) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
:key="index"
class="rule-item"
:style="{
paddingLeft: conditions.conditions.length > 1 ? '55px' : '16px',
paddingLeft: getPaddingLeft(index, conditions),
}">
<template v-if="needCondition">
<!-- 二级横线 -->
Expand Down Expand Up @@ -124,6 +124,15 @@
});
const needCondition = computed(() => where.value.conditions.length > 1);

const getPaddingLeft = (index: number, conditions: Where['conditions'][0]) => {
const beforeArr = where.value.conditions.slice(0, index);
const beforeHasCondition = beforeArr.some(item => item.conditions.length > 1);
if (conditions.conditions.length > 1 || beforeHasCondition) {
return '55px';
}
return '16px';
};

const handleDelete = (index: number) => {
where.value.conditions.splice(index, 1);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
{{ item.left_table.rt_id }}
</div>
<div
v-bk-tooltips="item.join_type"
v-bk-tooltips="joinTypeList.find(type => type.value === item.join_type)?.label || item.join_type"
class="join-type">
<relation-ship
:join-type="item.join_type"
Expand Down Expand Up @@ -154,6 +154,7 @@
}
interface Props {
linkDataDetail: LinkDataDetailModel
joinTypeList: Array<Record<string, any>>
}

defineProps<Props>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
required>
<span
v-bk-tooltips="{
content: t('第1步,此处配置的审计风险数据的数据源,用以后续步骤的处理。一般由“操作记录”与“资产数据”组合合成,但也可以自由组合而成。'),
content: t('审计规则的数据来源,联动后续步骤字段结构。如需组合数据,请提前创建并选择联表数据'),
extCls:'strategy-config-type-tooltips'
}"
class="label-is-required"
Expand Down Expand Up @@ -64,6 +64,7 @@
<!-- 联表详情 -->
<link-data-detail-component
v-if="formData.configs.data_source.link_table && formData.configs.data_source.link_table.uid"
:join-type-list="joinTypeList"
:link-data-detail="linkDataDetail"
@refresh-link-data="handleRefreshLinkData" />
</bk-form-item>
Expand All @@ -73,7 +74,7 @@
<template #label>
<span
v-bk-tooltips="{
content: t('第2步,可配置聚合规则。若无规则,则结果默认返回所有字段并不做聚合;若有规则,则返回配置字段。'),
content: t('需要哪些字段作为结果,每行记录可生成一个风险事件,展示在风险单内;也可用于第2步”单据展示“的字段映射;点击下方”预览“可提前预览风险单展示内容;'),
extCls:'strategy-config-type-tooltips'
}"
style="color: #63656e; cursor: pointer; border-bottom: 1px dashed #979ba5;">
Expand All @@ -94,7 +95,7 @@
<template #label>
<span
v-bk-tooltips="{
content: t('第3步,完成数据处理后,配置对应的字段规则,筛选出我们期望的数据可能是风险数据。'),
content: t('配置对应的字段与规则,筛选出我们期望的数据可能是风险数据。'),
extCls:'strategy-config-type-tooltips'
}"
style="color: #63656e; cursor: pointer; border-bottom: 1px dashed #979ba5;">
Expand Down Expand Up @@ -123,7 +124,11 @@
:disabled="isEditMode"
@change="handleSourceTypeChange">
<bk-radio label="batch_join_source">
{{ t('固定周期调度') }}
<span
v-bk-tooltips="t('按天则下一调度时间为当天0点;按小时则为下一调度时间为下个小时整点;并作为固定发起时间;')"
style="color: #63656e; cursor: pointer; border-bottom: 1px dashed #979ba5;">
{{ t('固定周期调度') }}
</span>
</bk-radio>
<bk-radio label="stream_source">
<span
Expand Down Expand Up @@ -302,6 +307,7 @@
const aggregateList = ref<Array<Record<string, any>>>([]);
const configType = ref('');
const tableFields = ref<Array<DatabaseTableFieldModel>>([]);
const joinTypeList = ref<Array<Record<string, any>>>([]);

// eslint-disable-next-line max-len
const hasData = computed(() => formData.value.configs.select.length || formData.value.configs.where.conditions.length);
Expand All @@ -318,6 +324,7 @@
label: t('不聚和'),
value: null,
}]);
joinTypeList.value = commonData.value.link_table_join_type;
},
});

Expand Down Expand Up @@ -523,13 +530,11 @@
expectedResultsRef.value.resetFormData();
};

const handleSourceTypeChange = (type: string) => {
if (type === 'stream_source') {
formData.value.configs.schedule_config = {
count_freq: '',
schedule_period: 'hour',
};
}
const handleSourceTypeChange = () => {
formData.value.configs.schedule_config = {
count_freq: '',
schedule_period: 'hour',
};
};

// 编辑
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@
label: t('引入模型审计'),
value: 'model',
config: {
tips: t('指先通过蓝鲸 bkbaseAIops 内开发场景模型后,在审计中心内配置字段映射生成策略的方式。适用于对 aiops 有数据开发能力,且需要实现的审计方案较复杂的情况。'),
tips: t('指先通过蓝鲸 BKBaseAIOps 内开发场景模型后,在审计中心内配置字段映射生成策略的方式。适用于对 aiops 有数据开发能力,且需要实现的审计方案较复杂的情况。'),
},
}];
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
<bk-select
v-else-if="optionalField.includes(config.field_name) && !config.prefix"
v-model="config.map_config.source_field"
style="width: 100%;">
style="width: 100%;"
@select="(value: string) => handlerSelect(value, config)">
<bk-option
v-for="(selectItem, index) in localSelect"
:key="index"
Expand All @@ -99,7 +100,8 @@
<bk-input
v-model="countValue"
autofocus
:placeholder="t('请输入')" />
:placeholder="t('请输入')"
@enter="confirmAddCount" />
<audit-icon
style=" padding: 0 5px;font-size: 15px; color: #2caf5e;cursor: pointer;"
type="check-line"
Expand All @@ -113,7 +115,9 @@
</bk-select>
<!-- 无需配置 -->
<template v-else>
{{ t('无需配置') }}
<span style="padding-left: 8px;">
{{ t('无需配置') }}
</span>
</template>
</template>

Expand Down

0 comments on commit 7528fab

Please sign in to comment.