Skip to content

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

chore: data masking ui update (#9459)

ecmadao66d6b2517ca8
diff --git a/backend/api/v1/setting_service.go b/backend/api/v1/setting_service.go
index 4e2308ca20..29ed25588e 100644
--- a/backend/api/v1/setting_service.go
+++ b/backend/api/v1/setting_service.go
@@ -1113,8 +1113,20 @@ func validateMaskingAlgorithm(algorithm *v1pb.MaskingAlgorithmSetting_Algorithm)
}
switch m := algorithm.Mask.(type) {
case *v1pb.MaskingAlgorithmSetting_Algorithm_FullMask_:
+ if m.FullMask.Substitution == "" {
+ return status.Errorf(codes.InvalidArgument, "the substitution for full mask is required")
+ }
+ if len(m.FullMask.Substitution) > 16 {
+ return status.Errorf(codes.InvalidArgument, "the substitution should less than 16 bytes")
+ }
case *v1pb.MaskingAlgorithmSetting_Algorithm_RangeMask_:
for i, slice := range m.RangeMask.Slices {
+ if slice.Substitution == "" {
+ return status.Errorf(codes.InvalidArgument, "the substitution for slice is required")
+ }
+ if len(slice.Substitution) > 16 {
+ return status.Errorf(codes.InvalidArgument, "the substitution should less than 16 bytes")
+ }
if slice.Start >= slice.End {
return status.Errorf(codes.InvalidArgument, "the slice end must smaller than the start: [%d,%d)", slice.Start, slice.End)
}
diff --git a/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue b/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue
index f9310a5cf4..f881fad4e3 100644
--- a/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue
+++ b/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue
@@ -1,6 +1,8 @@
<template>
- <div class="w-full mt-4 space-y-4">
- <div class="flex items-center justify-between">
+ <div class="w-full space-y-4">
+ <div
+ class="flex flex-col lg:flex-row items-start lg:items-center justify-between space-y-2"
+ >
<div class="textinfolabel">
{{ $t("settings.sensitive-data.global-rules.description") }}
<a
diff --git a/frontend/src/components/SensitiveData/MaskingAlgorithmsView.vue b/frontend/src/components/SensitiveData/MaskingAlgorithmsView.vue
index 44e5cbac25..61467d8d13 100644
--- a/frontend/src/components/SensitiveData/MaskingAlgorithmsView.vue
+++ b/frontend/src/components/SensitiveData/MaskingAlgorithmsView.vue
@@ -1,6 +1,6 @@
<template>
- <div class="w-full mt-4 space-y-4">
- <div class="flex items-center justify-end">
+ <div class="w-full space-y-4">
+ <div class="flex items-center justify-end mt-2">
<NButton
type="primary"
:disabled="!hasPermission || !hasSensitiveDataFeature"
diff --git a/frontend/src/components/SensitiveData/SemanticTypesView.vue b/frontend/src/components/SensitiveData/SemanticTypesView.vue
index 8bd47b53a0..09c3c7e0b8 100644
--- a/frontend/src/components/SensitiveData/SemanticTypesView.vue
+++ b/frontend/src/components/SensitiveData/SemanticTypesView.vue
@@ -1,19 +1,26 @@
<template>
- <div class="w-full mt-4 space-y-4">
- <div class="flex items-center justify-end space-x-2">
- <NButton
- type="primary"
- :disabled="!hasPermission || !hasSensitiveDataFeature"
- @click="onAdd"
- >
- {{ $t("settings.sensitive-data.semantic-types.add-type") }}
- </NButton>
- <NButton
- :disabled="!hasPermission || !hasSensitiveDataFeature"
- @click="state.showTemplateDrawer = true"
- >
- {{ $t("settings.sensitive-data.semantic-types.add-from-template") }}
- </NButton>
+ <div class="w-full space-y-4">
+ <div
+ class="flex flex-col lg:flex-row items-start lg:items-center justify-between space-y-2 lg:space-x-2"
+ >
+ <div class="textinfolabel">
+ {{ $t("settings.sensitive-data.semantic-types.label") }}
+ </div>
+ <div class="flex items-center justify-end space-x-2">
+ <NButton
+ :disabled="!hasPermission || !hasSensitiveDataFeature"
+ @click="state.showTemplateDrawer = true"
+ >
+ {{ $t("settings.sensitive-data.semantic-types.add-from-template") }}
+ </NButton>
+ <NButton
+ type="primary"
+ :disabled="!hasPermission || !hasSensitiveDataFeature"
+ @click="onAdd"
+ >
+ {{ $t("settings.sensitive-data.semantic-types.add-type") }}
+ </NButton>
+ </div>
</div>
<div class="space-y-5 divide-y-2 pb-10 divide-gray-100">
<SemanticTypesTable
diff --git a/frontend/src/components/SensitiveData/components/MaskingAlgorithmsCreateDrawer.vue b/frontend/src/components/SensitiveData/components/MaskingAlgorithmsCreateDrawer.vue
index 58d857226b..788912bf77 100644
--- a/frontend/src/components/SensitiveData/components/MaskingAlgorithmsCreateDrawer.vue
+++ b/frontend/src/components/SensitiveData/components/MaskingAlgorithmsCreateDrawer.vue
@@ -15,7 +15,7 @@
required
name="title"
type="text"
- placeholder="algorithm title"
+ :placeholder="t('settings.sensitive-data.algorithms.table.title')"
class="textfield mt-1 w-full"
:disabled="state.processing || readonly"
/>
@@ -29,7 +29,9 @@
required
name="title"
type="text"
- placeholder="algorithm description"
+ :placeholder="
+ t('settings.sensitive-data.algorithms.table.description')
+ "
class="textfield mt-1 w-full"
:disabled="state.processing || readonly"
/>
@@ -91,7 +93,9 @@
required
name="title"
type="text"
- placeholder="substitution"
+ :placeholder="
+ t('settings.sensitive-data.algorithms.full-mask.substitution')
+ "
class="textfield mt-2 w-full"
:disabled="state.processing || readonly"
/>
@@ -121,7 +125,11 @@
name="slice-start"
type="number"
min="0"
- placeholder="slice start"
+ :placeholder="
+ t(
+ 'settings.sensitive-data.algorithms.range-mask.slice-start'
+ )
+ "
class="textfield mt-1 w-20"
:disabled="state.processing || readonly"
@input="(e: any) => onSliceStartChange(i, Number(e.target.value))"
@@ -142,7 +150,9 @@
name="slice-end"
type="number"
min="1"
- placeholder="slice end"
+ :placeholder="
+ t('settings.sensitive-data.algorithms.range-mask.slice-end')
+ "
class="textfield mt-1 w-20"
:disabled="state.processing || readonly"
@input="(e: any) => onSliceEndChange(i, Number(e.target.value))"
@@ -162,7 +172,11 @@
required
name="substitution"
type="text"
- placeholder="substitution"
+ :placeholder="
+ t(
+ 'settings.sensitive-data.algorithms.range-mask.substitution'
+ )
+ "
class="textfield mt-1 w-full"
:disabled="state.processing || readonly"
/>
@@ -177,6 +191,9 @@
</button>
</div>
</div>
+ <div v-if="rangeMaskErrorMessage" class="text-red-600">
+ {{ rangeMaskErrorMessage }}
+ </div>
<NButton
class="ml-auto"
:disabled="state.processing || readonly"
@@ -201,7 +218,9 @@
required
name="title"
type="text"
- placeholder="salt"
+ :placeholder="
+ t('settings.sensitive-data.algorithms.md5-mask.salt')
+ "
class="textfield mt-2 w-full"
:disabled="state.processing || readonly"
/>
@@ -280,6 +299,7 @@ const defaultRangeMask = computed(() =>
MaskingAlgorithmSetting_Algorithm_RangeMask_Slice.fromPartial({
start: 0,
end: 1,
+ substitution: "*",
}),
],
})
@@ -358,51 +378,69 @@ const maskingAlgorithm = computed((): MaskingAlgorithmSetting_Algorithm => {
return result;
});
+const rangeMaskErrorMessage = computed(() => {
+ if (state.rangeMask.slices.length === 0) {
+ return t("settings.sensitive-data.algorithms.error.slice-required");
+ }
+ for (let i = 0; i < state.rangeMask.slices.length; i++) {
+ const slice = state.rangeMask.slices[i];
+ if (
+ Number.isNaN(slice.start) ||
+ Number.isNaN(slice.end) ||
+ slice.start < 0 ||
+ slice.end <= 0
+ ) {
+ return t("settings.sensitive-data.algorithms.error.slice-invalid-number");
+ }
+ if (slice.start >= slice.end) {
+ return t("settings.sensitive-data.algorithms.error.slice-number-range");
+ }
+
+ for (let j = 0; j < i; j++) {
+ const pre = state.rangeMask.slices[j];
+ if (slice.start >= pre.end || pre.start >= slice.end) {
+ continue;
+ }
+ return t("settings.sensitive-data.algorithms.error.slice-overlap");
+ }
+
+ if (!slice.substitution) {
+ return t(
+ "settings.sensitive-data.algorithms.error.substitution-required"
+ );
+ }
+ if (slice.substitution.length > 16) {
+ return t("settings.sensitive-data.algorithms.error.substitution-length");
+ }
+ }
+ return "";
+});
+
const errorMessage = computed(() => {
if (!state.title) {
- return "Title is required";
+ return t("settings.sensitive-data.algorithms.error.title-required");
}
switch (state.maskingType) {
case "full-mask":
if (!state.fullMask.substitution) {
- return "Substitution is required";
+ return t(
+ "settings.sensitive-data.algorithms.error.substitution-required"
+ );
+ }
+ if (state.fullMask.substitution.length > 16) {
+ return t(
+ "settings.sensitive-data.algorithms.error.substitution-length"
+ );
}
return "";
case "md5-mask":
if (!state.md5Mask.salt) {
- return "Salt is required";
+ return t("settings.sensitive-data.algorithms.error.salt-required");
}
return "";
case "range-mask":
- if (state.rangeMask.slices.length === 0) {
- return "Slices is required";
- }
- for (let i = 0; i < state.rangeMask.slices.length; i++) {
- const slice = state.rangeMask.slices[i];
- if (!slice.substitution) {
- return "Slice substitution is required";
- }
- if (
- Number.isNaN(slice.start) ||
- Number.isNaN(slice.end) ||
- slice.start < 0 ||
- slice.end <= 0
- ) {
- return "Slice start or end is not valid number";
- }
- if (slice.start >= slice.end) {
- return "The slice end must smaller than the start";
- }
-
- for (let j = 0; j < i; j++) {
- const pre = state.rangeMask.slices[j];
- if (slice.start >= pre.end || pre.start >= slice.end) {
- continue;
- }
- return "The slice range cannot overlap";
- }
- }
+ return rangeMaskErrorMessage.value;
}
return "";
});
@@ -474,10 +512,12 @@ const onMaskingTypeChange = (maskingType: MaskingType) => {
};
const addSlice = () => {
+ const last = state.rangeMask.slices[state.rangeMask.slices.length - 1];
state.rangeMask.slices.push(
MaskingAlgorithmSetting_Algorithm_RangeMask_Slice.fromPartial({
- start: 0,
- end: 1,
+ start: (last?.start ?? -1) + 1,
+ end: (last?.end ?? 0) + 1,
+ substitution: "*",
})
);
};
diff --git a/frontend/src/components/SensitiveData/components/SemanticTemplateDrawer.vue b/frontend/src/components/SensitiveData/components/SemanticTemplateDrawer.vue
index d7f09b1e87..3a07d1de7a 100644
--- a/frontend/src/components/SensitiveData/components/SemanticTemplateDrawer.vue
+++ b/frontend/src/components/SensitiveData/components/SemanticTemplateDrawer.vue
@@ -3,12 +3,14 @@
<DrawerContent
:title="$t('settings.sensitive-data.semantic-types.add-from-template')"
>
- <SemanticTypesTable
- :readonly="true"
- :row-clickable="true"
- :semantic-item-list="semanticTemplateList"
- @on-select="onApply($event)"
- />
+ <div class="w-[40rem]">
+ <SemanticTypesTable
+ :readonly="true"
+ :row-clickable="true"
+ :semantic-item-list="semanticTemplateList"
+ @on-select="onApply($event)"
+ />
+ </div>
<template #footer>
<div class="w-full flex justify-between items-center">
<div class="w-full flex justify-end items-center gap-x-3">
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index aa6ac69824..9781c08fb3 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -684,6 +684,7 @@
"semantic-types": {
"self": "Semantic Types",
"add-type": "Add type",
+ "label": "Columns having the same semantic type will use the same masking algorithms.",
"add-from-template": "Add from template",
"table": {
"semantic-type": "Semantic Type",
@@ -754,6 +755,16 @@
"masking-type": "Masking Type",
"delete": "Delete this algorithm?"
},
+ "error": {
+ "title-required": "Title is required",
+ "substitution-required": "Substitution is required",
+ "substitution-length": "Substitution should be less than 16 bytes",
+ "salt-required": "Salt is required",
+ "slice-required": "Slice is required",
+ "slice-invalid-number": "Slice start or end is not a valid number",
+ "slice-number-range": "The slice end must be smaller than the start",
+ "slice-overlap": "The slice range cannot overlap"
+ },
"mask": "Mask",
"hash": "Hash",
"full-mask": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index a97cf32622..7c346b940c 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -683,6 +683,7 @@
"semantic-types": {
"self": "Tipos Semánticos",
"add-type": "Agregar tipo",
+ "label": "Las columnas que tengan el mismo tipo semántico utilizarán los mismos algoritmos de enmascaramiento.",
"add-from-template": "Agregar desde plantilla",
"table": {
"semantic-type": "Tipo Semántico",
@@ -753,6 +754,16 @@
"masking-type": "Tipo De Enmascaramiento",
"delete": "¿Eliminar este algoritmo?"
},
+ "error": {
+ "title-required": "Se requiere título",
+ "substitution-required": "Se requiere sustitución",
+ "substitution-length": "La sustitución debe ser inferior a 16 bytes",
+ "salt-required": "Se requiere sal",
+ "slice-required": "Se requiere rebanada",
+ "slice-invalid-number": "El inicio o el final del segmento no es un número válido",
+ "slice-number-range": "El final del corte debe ser más pequeño que el inicio",
+ "slice-overlap": "El rango de corte no puede superponerse"
+ },
"mask": "Máscara",
"hash": "Picadillo",
"full-mask": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index c00319aae5..f82d8d9071 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -682,6 +682,7 @@
"semantic-types": {
"self": "语义类型",
"add-type": "新增类型",
+ "label": "具有相同语义类型的列会使用相同的脱敏算法。",
"add-from-template": "从模板添加",
"table": {
"semantic-type": "语义类型",
@@ -752,12 +753,22 @@
"masking-type": "算法类型",
"delete": "删除该算法?"
},
+ "error": {
+ "title-required": "请填写算法名称",
+ "substitution-required": "请填写遮掩字符串",
+ "substitution-length": "遮掩字符串长度不能超过 16 个字符",
+ "salt-required": "请填写盐值",
+ "slice-required": "遮掩范围不能为空",
+ "slice-invalid-number": "遮掩范围起始值和结束值必须是数字",
+ "slice-number-range": "遮掩范围结束值必须小于起始值",
+ "slice-overlap": "遮掩范围不能有重叠"
+ },
"mask": "遮掩",
"hash": "哈希",
"full-mask": {
"self": "全遮掩",
"substitution": "遮掩字符串",
- "substitution-label": "遮掩字符串是用来替换原始值的字符串,最大长度不能超过16字节。"
+ "substitution-label": "遮掩字符串是用来替换原始值的字符串,最大长度不能超过 16 个字符。"
},
"range-mask": {
"self": "范围遮掩",