Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: set semantic type for global masking rule (#14866)

ecmadao01fb8058d863
diff --git a/frontend/src/components/SensitiveData/components/MaskingActionDropdown.vue b/frontend/src/components/SensitiveData/components/MaskingActionDropdown.vue
index 19880a5e83..7191bb4f48 100644
--- a/frontend/src/components/SensitiveData/components/MaskingActionDropdown.vue
+++ b/frontend/src/components/SensitiveData/components/MaskingActionDropdown.vue
@@ -4,7 +4,7 @@
:options="options"
:disabled="disabled"
:clearable="clearable"
- :placeholder="$t('settings.sensitive-data.action.selet-action')"
+ :placeholder="$t('settings.sensitive-data.action.select-action')"
@update:value="$emit('update:action', $event)"
/>
</template>
diff --git a/frontend/src/components/SensitiveData/components/MaskingLevelDropdown.vue b/frontend/src/components/SensitiveData/components/MaskingLevelDropdown.vue
index a6a91c543c..61b6247849 100644
--- a/frontend/src/components/SensitiveData/components/MaskingLevelDropdown.vue
+++ b/frontend/src/components/SensitiveData/components/MaskingLevelDropdown.vue
@@ -4,7 +4,7 @@
:options="options"
:disabled="disabled"
:clearable="clearable"
- :placeholder="$t('settings.sensitive-data.masking-level.selet-level')"
+ :placeholder="$t('settings.sensitive-data.masking-level.select-level')"
@update:value="$emit('update:level', $event)"
/>
</template>
diff --git a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
index 4b5aaa4b76..c30dc9b743 100644
--- a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
+++ b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
@@ -31,13 +31,15 @@
</div>
<div>
<h3 class="font-medium text-sm text-main py-2">
- {{ $t("settings.sensitive-data.masking-level.self") }}
+ {{ $t("settings.sensitive-data.semantic-types.table.semantic-type") }}
</h3>
<NSelect
v-model:value="state.semanticType"
style="min-width: 10rem"
+ :filterable="true"
:options="options"
- :placeholder="$t('settings.sensitive-data.masking-level.selet-level')"
+ :filter="filterByTitle"
+ :placeholder="$t('settings.sensitive-data.semantic-types.select')"
:consistent-menu-width="false"
:disabled="disabled || readonly"
@update:value="state.dirty = true"
@@ -96,15 +98,21 @@ import {
validateSimpleExpr,
emptySimpleExpr,
} from "@/plugins/cel";
+import { useSettingV1Store } from "@/store";
import { Expr } from "@/types/proto/google/type/expr";
-import { MaskingLevel, maskingLevelToJSON } from "@/types/proto/v1/common";
import type { MaskingRulePolicy_MaskingRule } from "@/types/proto/v1/org_policy_service";
+import type { SemanticTypeSetting_SemanticType as SemanticType } from "@/types/proto/v1/setting_service";
import {
batchConvertCELStringToParsedExpr,
batchConvertParsedExprToCELString,
} from "@/utils";
import { factorSupportDropdown, factorOperatorOverrideMap } from "./utils";
+export interface SemanticTypeSelectOption extends SelectOption {
+ value: string;
+ semanticType: SemanticType;
+}
+
const props = defineProps<{
index: number;
readonly: boolean;
@@ -124,7 +132,7 @@ const emit = defineEmits<{
type LocalState = {
title: string;
expr: ConditionGroupExpr;
- semanticType: string;
+ semanticType?: string;
dirty: boolean;
};
@@ -132,9 +140,32 @@ const { t } = useI18n();
const state = reactive<LocalState>({
title: "",
expr: wrapAsGroup(emptySimpleExpr()),
- semanticType: "default",
dirty: false,
});
+const settingStore = useSettingV1Store();
+
+const semanticTypeSettingValue = computed(() => {
+ const semanticTypeSetting = settingStore.getSettingByName(
+ "bb.workspace.semantic-types"
+ );
+ return semanticTypeSetting?.value?.semanticTypeSettingValue?.types ?? [];
+});
+
+const options = computed(() => {
+ return semanticTypeSettingValue.value.map<SemanticTypeSelectOption>(
+ (semanticType) => ({
+ value: semanticType.id,
+ label: semanticType.title,
+ semanticType,
+ })
+ );
+});
+
+const filterByTitle = (pattern: string, option: SelectOption) => {
+ const { semanticType } = option as SemanticTypeSelectOption;
+ pattern = pattern.toLowerCase();
+ return semanticType.title.toLowerCase().includes(pattern);
+};
const resetLocalState = async (rule: MaskingRulePolicy_MaskingRule) => {
let expr: SimpleExpr = emptySimpleExpr();
@@ -151,7 +182,7 @@ const resetLocalState = async (rule: MaskingRulePolicy_MaskingRule) => {
state.dirty = false;
state.title = rule.condition?.title ?? "";
state.expr = wrapAsGroup(expr);
- state.semanticType = rule.semanticType;
+ state.semanticType = rule.semanticType ? rule.semanticType : undefined;
};
onMounted(async () => {
@@ -164,21 +195,6 @@ const defaultTitle = computed(() => {
}`;
});
-const options = computed(() => {
- return [
- MaskingLevel.FULL,
- MaskingLevel.PARTIAL,
- MaskingLevel.NONE,
- ].map<SelectOption>((level) => ({
- label: t(
- `settings.sensitive-data.masking-level.${maskingLevelToJSON(
- level
- ).toLowerCase()}`
- ),
- value: level,
- }));
-});
-
const onCancel = async () => {
await resetLocalState(props.maskingRule);
emit("cancel");
@@ -186,8 +202,8 @@ const onCancel = async () => {
};
const isValid = computed(() => {
- const { expr } = state;
- if (!expr) return false;
+ const { expr, semanticType } = state;
+ if (!expr || !semanticType) return false;
return validateSimpleExpr(expr);
});
@@ -199,7 +215,7 @@ const onConfirm = async () => {
const expressions = await batchConvertParsedExprToCELString([celexpr]);
emit("confirm", {
...props.maskingRule,
- semanticType: state.semanticType,
+ semanticType: state.semanticType!,
condition: Expr.fromJSON({
expression: expressions[0],
title: state.title,
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index bfac9463fb..051f3a59d2 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -877,7 +877,8 @@
"title": "Phone number",
"description": ""
}
- }
+ },
+ "select": "Select semantic type"
},
"column-detail": {
"masking-setting-for-column": "Masking Setting for \"{column}\"",
@@ -948,7 +949,7 @@
},
"masking-level": {
"self": "Masking Level",
- "selet-level": "Select masking level",
+ "select-level": "Select masking level",
"masking_level_unspecified": "Follow global rules",
"none": "None",
"partial": "Partial",
@@ -956,7 +957,7 @@
},
"action": {
"self": "Action",
- "selet-action": "Select action",
+ "select-action": "Select action",
"query": "Query",
"export": "Export"
},
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 477bb825da..2d218d885c 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -877,7 +877,8 @@
"title": "Número de teléfono",
"description": ""
}
- }
+ },
+ "select": "Seleccionar tipo semántico"
},
"column-detail": {
"masking-setting-for-column": "Configuración de enmascaramiento para \"{columna}\"",
@@ -948,7 +949,7 @@
},
"masking-level": {
"self": "Nivel de enmascaramiento",
- "selet-level": "Seleccionar el nivel de enmascaramiento",
+ "select-level": "Seleccionar el nivel de enmascaramiento",
"masking_level_unspecified": "Sigue las reglas globales",
"none": "Ninguna",
"partial": "Parcial",
@@ -956,7 +957,7 @@
},
"action": {
"self": "Acción",
- "selet-action": "Seleccionar acción",
+ "select-action": "Seleccionar acción",
"query": "Consulta",
"export": "Exportar"
},
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index b9bc5c3b2c..d7e1f9a854 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -877,7 +877,8 @@
"title": "電話番号",
"description": ""
}
- }
+ },
+ "select": "セマンティックタイプの選択"
},
"column-detail": {
"masking-setting-for-column": "「{column}」の感度解除設定",
@@ -948,7 +949,7 @@
},
"masking-level": {
"self": "マスキングレベル",
- "selet-level": "マスキングレベルを選択",
+ "select-level": "マスキングレベルを選択",
"masking_level_unspecified": "全体像に従ってください",
"none": "マスクなし",
"partial": "部分マスク",
@@ -956,7 +957,7 @@
},
"action": {
"self": "操作の種類",
- "selet-action": "アクションを選択",
+ "select-action": "アクションを選択",
"query": "クエリ",
"export": "出力"
},
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index afc79e2ae8..b5e3bf6ba0 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -877,7 +877,8 @@
"title": "电话号码",
"description": ""
}
- }
+ },
+ "select": "选择语义类型"
},
"column-detail": {
"masking-setting-for-column": "\"{column}\" 脱敏设置",
@@ -948,7 +949,7 @@
},
"masking-level": {
"self": "脱敏程度",
- "selet-level": "选择掩蔽级别",
+ "select-level": "选择掩蔽级别",
"masking_level_unspecified": "遵循全局",
"none": "明文",
"partial": "半脱敏",
@@ -956,7 +957,7 @@
},
"action": {
"self": "操作类型",
- "selet-action": "选择操作",
+ "select-action": "选择操作",
"query": "查询",
"export": "导出"
},