Skip to content

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

chore: optimize wording for masking config (#21455)

ecmadao91f037c8924c
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 904d0c835c..6e791e1267 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2955,6 +2955,7 @@
"masking-type": "Masking Type"
}
},
+ "apply-masking": "Apply masking",
"classification": {
"empty-classification": "The \"classification\" field is empty",
"guide-classification": "\"classification\" maps each category by ID. Leaf categories must reference a level number; parent categories omit the level.",
@@ -2965,6 +2966,7 @@
"missing-classification": "Missing \"classification\" field",
"missing-levels": "Missing \"levels\" field"
},
+ "columns-to-mask": "Columns to mask",
"global-rules": {
"condition-order": "Condition order",
"delete-rule-tip": "Delete this rule?",
@@ -2977,14 +2979,17 @@
},
"grant-access": "Grant Access",
"mark-sensitive-data": "Mark sensitive data",
+ "mark-sensitive-data-description": "Choose columns whose values should be hidden in query results.",
"never-expires": "Never expires",
"remove-sensitive-column-tips": "Expose this column?",
+ "semantic-type-description": "Semantic types group columns representing the same kind of data so Bytebase can apply consistent masking.",
"semantic-types": {
"error": {
"no-changes-to-save": "No changes to save",
"title-required": "Title is required"
},
"label": "Columns having the same semantic type will use the same masking algorithms.",
+ "masking-effect": "Masking effect: {{effect}}",
"select": "Select semantic type",
"self": "Semantic Types",
"table": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 6970dc5339..2dd55471ac 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2955,6 +2955,7 @@
"masking-type": "Tipo De Enmascaramiento"
}
},
+ "apply-masking": "Aplicar enmascaramiento",
"classification": {
"empty-classification": "El campo \"classification\" está vacío",
"guide-classification": "\"classification\" asigna cada categoría por ID. Las categorías hoja deben referenciar un número de nivel; las categorías padre omiten el nivel.",
@@ -2965,6 +2966,7 @@
"missing-classification": "Falta el campo \"classification\"",
"missing-levels": "Falta el campo \"levels\""
},
+ "columns-to-mask": "Columnas que se enmascararán",
"global-rules": {
"condition-order": "Orden de condición",
"delete-rule-tip": "¿Eliminar esta regla?",
@@ -2977,14 +2979,17 @@
},
"grant-access": "Conceder acceso",
"mark-sensitive-data": "Marcar datos confidenciales",
+ "mark-sensitive-data-description": "Selecciona las columnas cuyos valores deben ocultarse en los resultados de las consultas.",
"never-expires": "Nunca expira",
"remove-sensitive-column-tips": "¿Exponer esta columna?",
+ "semantic-type-description": "Los tipos semánticos agrupan columnas que representan la misma clase de datos para que Bytebase aplique un enmascaramiento coherente.",
"semantic-types": {
"error": {
"no-changes-to-save": "No hay cambios para guardar",
"title-required": "El título es obligatorio"
},
"label": "Las columnas que tengan el mismo tipo semántico utilizarán los mismos algoritmos de enmascaramiento.",
+ "masking-effect": "Efecto de enmascaramiento: {{effect}}",
"select": "Seleccionar tipo semántico",
"self": "Tipos Semánticos",
"table": {
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 31e8d1cb55..065a15a1a7 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -2955,6 +2955,7 @@
"masking-type": "アルゴリズムの種類"
}
},
+ "apply-masking": "マスキングを適用",
"classification": {
"empty-classification": "「classification」フィールドが空です",
"guide-classification": "「classification」は各カテゴリを ID でマッピングします。リーフカテゴリはレベル番号を参照する必要があり、親カテゴリはレベルを省略します。",
@@ -2965,6 +2966,7 @@
"missing-classification": "「classification」フィールドがありません",
"missing-levels": "「levels」フィールドがありません"
},
+ "columns-to-mask": "マスキングするカラム",
"global-rules": {
"condition-order": "条件付きシーケンス",
"delete-rule-tip": "このルールを削除しますか?",
@@ -2977,14 +2979,17 @@
},
"grant-access": "アクセスを許可する",
"mark-sensitive-data": "機密データをマークする",
+ "mark-sensitive-data-description": "クエリ結果で値を非表示にするカラムを選択します。",
"never-expires": "有効期限なし",
"remove-sensitive-column-tips": "このデータ列を表示しますか?",
+ "semantic-type-description": "セマンティックタイプは同じ種類のデータを表すカラムをグループ化し、Bytebase が一貫したマスキングを適用できるようにします。",
"semantic-types": {
"error": {
"no-changes-to-save": "保存する変更はありません",
"title-required": "タイトルは必須です"
},
"label": "同じセマンティック タイプの列は、同じマスキング アルゴリズムを使用します。",
+ "masking-effect": "マスキング効果: {{effect}}",
"select": "セマンティックタイプの選択",
"self": "セマンティックタイプ",
"table": {
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 85ff254b39..859c95d21f 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -2955,6 +2955,7 @@
"masking-type": "Loại che"
}
},
+ "apply-masking": "Áp dụng che dữ liệu",
"classification": {
"empty-classification": "Trường \"classification\" đang trống",
"guide-classification": "\"classification\" ánh xạ mỗi danh mục theo ID. Danh mục lá phải tham chiếu một số cấp độ; danh mục cha bỏ qua cấp độ.",
@@ -2965,6 +2966,7 @@
"missing-classification": "Thiếu trường \"classification\"",
"missing-levels": "Thiếu trường \"levels\""
},
+ "columns-to-mask": "Các cột cần che",
"global-rules": {
"condition-order": "Thứ tự điều kiện",
"delete-rule-tip": "Xóa quy tắc này?",
@@ -2977,14 +2979,17 @@
},
"grant-access": "Cấp Quyền truy cập",
"mark-sensitive-data": "Đánh dấu dữ liệu nhạy cảm",
+ "mark-sensitive-data-description": "Chọn các cột có giá trị cần được ẩn trong kết quả truy vấn.",
"never-expires": "Không bao giờ hết hạn",
"remove-sensitive-column-tips": "Hiển thị cột này?",
+ "semantic-type-description": "Kiểu ngữ nghĩa nhóm các cột biểu thị cùng một loại dữ liệu để Bytebase áp dụng cách che nhất quán.",
"semantic-types": {
"error": {
"no-changes-to-save": "Không có thay đổi để lưu",
"title-required": "Tiêu đề là bắt buộc"
},
"label": "Các cột có cùng loại ngữ nghĩa sẽ sử dụng cùng một thuật toán che.",
+ "masking-effect": "Hiệu ứng che: {{effect}}",
"select": "Chọn loại ngữ nghĩa",
"self": "Loại ngữ nghĩa",
"table": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 2e29cc2b46..fc707fe960 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2955,6 +2955,7 @@
"masking-type": "算法类型"
}
},
+ "apply-masking": "应用脱敏",
"classification": {
"empty-classification": "\"classification\" 字段为空",
"guide-classification": "\"classification\" 以 ID 为键映射各分类。叶子分类必须引用级别编号,父分类省略级别。",
@@ -2965,6 +2966,7 @@
"missing-classification": "缺少 \"classification\" 字段",
"missing-levels": "缺少 \"levels\" 字段"
},
+ "columns-to-mask": "要脱敏的列",
"global-rules": {
"condition-order": "条件序列",
"delete-rule-tip": "删除这条规则?",
@@ -2977,14 +2979,17 @@
},
"grant-access": "授予访问权限",
"mark-sensitive-data": "标记敏感数据",
+ "mark-sensitive-data-description": "选择要在查询结果中隐藏其值的列。",
"never-expires": "无过期时间",
"remove-sensitive-column-tips": "不再对此列数据脱敏?",
+ "semantic-type-description": "语义类型对含义相同的列进行分组,以便 Bytebase 应用一致的脱敏方式。",
"semantic-types": {
"error": {
"no-changes-to-save": "没有需要保存的更改",
"title-required": "标题为必填项"
},
"label": "具有相同语义类型的列会使用相同的脱敏算法。",
+ "masking-effect": "脱敏效果:{{effect}}",
"select": "选择语义类型",
"self": "语义类型",
"table": {
diff --git a/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.test.tsx b/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.test.tsx
index 2bc7a318e8..86ca0be9b0 100644
--- a/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.test.tsx
+++ b/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.test.tsx
@@ -5,6 +5,11 @@ import {
DatabaseMetadataSchema,
DatabaseSchema$,
} from "@/types/proto-es/v1/database_service_pb";
+import {
+ AlgorithmSchema,
+ SemanticTypeSetting_SemanticTypeSchema,
+} from "@/types/proto-es/v1/setting_service_pb";
+import { getSemanticTemplateList } from "@/types/semanticTypes";
import { MarkSensitiveDataSheet } from "./MarkSensitiveDataSheet";
const mocks = vi.hoisted(() => ({
@@ -13,7 +18,11 @@ const mocks = vi.hoisted(() => ({
}));
vi.mock("react-i18next", () => ({
- useTranslation: () => ({ t: (key: string) => key }),
+ initReactI18next: { type: "3rdParty", init: () => {} },
+ useTranslation: () => ({
+ t: (key: string, options?: { effect?: string }) =>
+ options?.effect ? `${key}: ${options.effect}` : key,
+ }),
}));
vi.mock("@/hooks/useAppDatabaseMetadata", () => ({
@@ -65,7 +74,7 @@ test("applies the semantic type to multiple selected columns in one save", async
});
render(<MarkSensitiveDataSheet {...props} />);
await selectOption("common.table", "customers");
- await selectOption("common.column", "email");
+ await selectOption("settings.sensitive-data.columns-to-mask", "email");
const phone = await screen.findByRole("option", { name: "phone" });
fireEvent.pointerDown(phone, { pointerType: "mouse" });
fireEvent.click(phone);
@@ -75,7 +84,11 @@ test("applies the semantic type to multiple selected columns in one save", async
);
expect(phone).toHaveAttribute("aria-selected", "true");
fireEvent.keyDown(phone, { key: "Escape" });
- fireEvent.click(screen.getByRole("button", { name: "common.save" }));
+ fireEvent.click(
+ screen.getByRole("button", {
+ name: "settings.sensitive-data.apply-masking",
+ })
+ );
expect(mocks.updateColumnCatalog).toHaveBeenCalledExactlyOnceWith({
database: props.database.name,
schema: "public",
@@ -100,13 +113,21 @@ test("clears selected columns when switching tables", async () => {
});
render(<MarkSensitiveDataSheet {...props} />);
await selectOption("common.table", "customers");
- await selectOption("common.column", "email");
- fireEvent.keyDown(screen.getByLabelText("common.column"), { key: "Escape" });
- await selectOption("common.table", "orders");
- expect(screen.getByLabelText("common.column").textContent).toBe(
- "common.select"
+ await selectOption("settings.sensitive-data.columns-to-mask", "email");
+ fireEvent.keyDown(
+ screen.getByLabelText("settings.sensitive-data.columns-to-mask"),
+ { key: "Escape" }
);
- expect(screen.getByRole("button", { name: "common.save" })).toBeDisabled();
+ await selectOption("common.table", "orders");
+ expect(
+ screen.getByLabelText("settings.sensitive-data.columns-to-mask")
+ .textContent
+ ).toBe("common.select");
+ expect(
+ screen.getByRole("button", {
+ name: "settings.sensitive-data.apply-masking",
+ })
+ ).toBeDisabled();
});
test("defaults to the first schema without selecting a table or column", () => {
@@ -117,9 +138,99 @@ test("defaults to the first schema without selecting a table or column", () => {
false
);
expect(screen.getByLabelText("common.table").textContent).toBe("common.select");
- expect(screen.getByLabelText("common.column")).toHaveAttribute(
- "aria-disabled", "true"
+ expect(
+ screen.getByLabelText("settings.sensitive-data.columns-to-mask")
+ ).toHaveAttribute("aria-disabled", "true");
+});
+
+test("describes the masking task with outcome-specific labels", () => {
+ render(<MarkSensitiveDataSheet {...props} />);
+
+ expect(
+ screen.getByText("settings.sensitive-data.mark-sensitive-data-description")
+ ).toBeTruthy();
+ expect(
+ screen.getByLabelText("settings.sensitive-data.columns-to-mask")
+ ).toBeTruthy();
+ expect(
+ screen.getByText("settings.sensitive-data.semantic-type-description")
+ ).toBeTruthy();
+ expect(
+ screen.getByRole("button", {
+ name: "settings.sensitive-data.apply-masking",
+ })
+ ).toBeTruthy();
+});
+
+test("renders the semantic type title and explains a custom masking effect", async () => {
+ const semanticType = create(SemanticTypeSetting_SemanticTypeSchema, {
+ id: "email",
+ title: "Email",
+ algorithm: create(AlgorithmSchema, {
+ mask: {
+ case: "fullMask",
+ value: { substitution: "*" },
+ },
+ }),
+ });
+ render(
+ <MarkSensitiveDataSheet
+ {...props}
+ semanticTypeList={[
+ ...getSemanticTemplateList(((key: string) => key) as never),
+ semanticType,
+ ]}
+ />
+ );
+
+ const select = screen.getByLabelText(
+ "settings.sensitive-data.semantic-types.table.semantic-type"
+ );
+ expect(select.textContent).toContain(
+ "dynamic.settings.sensitive-data.semantic-types.template.bb-default.title"
+ );
+ expect(select.textContent).not.toContain("bb.default");
+
+ fireEvent.click(select);
+ const option = await screen.findByRole("option", { name: /Email/ });
+ expect(option.textContent).toContain(
+ "settings.sensitive-data.semantic-types.masking-effect"
+ );
+ expect(option.textContent).toContain(
+ "settings.sensitive-data.algorithms.full-mask.self"
+ );
+});
+
+test("explains the masking effect for built-in semantic types", async () => {
+ const semanticTypeList = getSemanticTemplateList(
+ ((key: string) => key) as never
+ );
+ render(
+ <MarkSensitiveDataSheet
+ {...props}
+ semanticTypeList={semanticTypeList}
+ />
+ );
+
+ const select = screen.getByLabelText(
+ "settings.sensitive-data.semantic-types.table.semantic-type"
+ );
+ fireEvent.click(select);
+
+ const defaultOption = await screen.findByRole("option", {
+ name: /dynamic\.settings\.sensitive-data\.semantic-types\.template\.bb-default\.title/,
+ });
+ expect(defaultOption.textContent).toContain(
+ "dynamic.settings.sensitive-data.semantic-types.template.bb-default.algorithm.description"
+ );
+ const partialOption = await screen.findByRole("option", {
+ name: /dynamic\.settings\.sensitive-data\.semantic-types\.template\.bb-default-partial\.title/,
+ });
+ const partialDescription = screen.getByText(
+ "dynamic.settings.sensitive-data.semantic-types.template.bb-default-partial.algorithm.description"
);
+ expect(partialDescription).toHaveClass("max-w-prose", "whitespace-normal");
+ expect(partialOption).toContainElement(partialDescription);
});
test("defaults when metadata arrives and preserves a manual selection until reopened", async () => {
diff --git a/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.tsx b/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.tsx
index b1169cad72..7cb1861f08 100644
--- a/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.tsx
+++ b/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.tsx
@@ -20,8 +20,10 @@ import {
} from "@/components/ui/sheet";
import { useAppDatabaseMetadata } from "@/hooks/useAppDatabaseMetadata";
import { updateColumnCatalog } from "@/lib/column-data-table/utils";
+import { getMaskingType } from "@/lib/sensitive-data/components-utils";
import type { Database } from "@/types/proto-es/v1/database_service_pb";
import type { SemanticTypeSetting_SemanticType } from "@/types/proto-es/v1/setting_service_pb";
+import { isBuiltinSemanticTypeId } from "@/types/semanticTypes";
interface MarkSensitiveDataSheetProps {
database: Database;
@@ -48,6 +50,9 @@ export function MarkSensitiveDataSheet({
schemaIndex === "" ? undefined : metadata.schemas[Number(schemaIndex)];
const selectedTable =
tableIndex === "" ? undefined : selectedSchema?.tables[Number(tableIndex)];
+ const selectedSemanticType = semanticTypeList.find(
+ (semanticType) => semanticType.id === semanticTypeId
+ );
const canSave =
!!selectedSchema &&
!!selectedTable &&
@@ -97,7 +102,7 @@ export function MarkSensitiveDataSheet({
{t("settings.sensitive-data.mark-sensitive-data")}
</SheetTitle>
<SheetDescription>
- {t("settings.sensitive-data.semantic-types.label")}
+ {t("settings.sensitive-data.mark-sensitive-data-description")}
</SheetDescription>
</SheetHeader>
<SheetBody>
@@ -175,7 +180,7 @@ export function MarkSensitiveDataSheet({
id="mark-sensitive-data-column-label"
htmlFor="mark-sensitive-data-column"
>
- {t("common.column")}
+ {t("settings.sensitive-data.columns-to-mask")}
</FormLabel>
<Select
multiple
@@ -200,12 +205,18 @@ export function MarkSensitiveDataSheet({
</Select>
</FormField>
- <FormField>
- <FormLabel htmlFor="mark-sensitive-data-semantic-type">
- {t(
- "settings.sensitive-data.semantic-types.table.semantic-type"
- )}
- </FormLabel>
+ <FormField
+ title={
+ <FormLabel htmlFor="mark-sensitive-data-semantic-type">
+ {t(
+ "settings.sensitive-data.semantic-types.table.semantic-type"
+ )}
+ </FormLabel>
+ }
+ description={t(
+ "settings.sensitive-data.semantic-type-description"
+ )}
+ >
<Select
value={semanticTypeId}
onValueChange={(value) => setSemanticTypeId(value ?? "")}
@@ -214,18 +225,43 @@ export function MarkSensitiveDataSheet({
id="mark-sensitive-data-semantic-type"
className="w-full"
>
- <SelectValue
- placeholder={t(
- "settings.sensitive-data.semantic-types.select"
- )}
- />
+ <SelectValue>
+ {selectedSemanticType?.title ||
+ t("settings.sensitive-data.semantic-types.select")}
+ </SelectValue>
</SelectTrigger>
<SelectContent>
- {semanticTypeList.map((semanticType) => (
- <SelectItem key={semanticType.id} value={semanticType.id}>
- {semanticType.title || semanticType.id}
- </SelectItem>
- ))}
+ {semanticTypeList.map((semanticType) => {
+ const maskingType = getMaskingType(semanticType.algorithm);
+ const maskingEffect = isBuiltinSemanticTypeId(
+ semanticType.id
+ )
+ ? t(
+ `dynamic.settings.sensitive-data.semantic-types.template.${semanticType.id.split(".").join("-")}.algorithm.description`
+ )
+ : maskingType
+ ? t(
+ "settings.sensitive-data.semantic-types.masking-effect",
+ {
+ effect: t(
+ `settings.sensitive-data.algorithms.${maskingType}.self`
+ ),
+ }
+ )
+ : undefined;
+ return (
+ <SelectItem key={semanticType.id} value={semanticType.id}>
+ <div className="flex min-w-0 flex-col">
+ <span className="truncate">{semanticType.title}</span>
+ {maskingEffect && (
+ <span className="max-w-prose whitespace-normal text-xs leading-5 text-control-light">
+ {maskingEffect}
+ </span>
+ )}
+ </div>
+ </SelectItem>
+ );
+ })}
</SelectContent>
</Select>
</FormField>
@@ -240,7 +276,7 @@ export function MarkSensitiveDataSheet({
{t("common.cancel")}
</Button>
<Button type="button" disabled={!canSave} onClick={handleSave}>
- {t("common.save")}
+ {t("settings.sensitive-data.apply-masking")}
</Button>
</SheetFooter>
</SheetContent>
diff --git a/frontend/src/routes/project/database-detail/panels/DatabaseCatalogPanel.test.tsx b/frontend/src/routes/project/database-detail/panels/DatabaseCatalogPanel.test.tsx
index 88e188571e..3ba8843097 100644
--- a/frontend/src/routes/project/database-detail/panels/DatabaseCatalogPanel.test.tsx
+++ b/frontend/src/routes/project/database-detail/panels/DatabaseCatalogPanel.test.tsx
@@ -883,7 +883,12 @@ describe("DatabaseCatalogPanel", () => {
).toEqual(expect.arrayContaining(["bb.default", "bb.default-partial"]));
await changeSelect(selects[3] as HTMLSelectElement, "bb.default");
- click(getButton(sheet as HTMLElement, "common.save") as HTMLElement);
+ click(
+ getButton(
+ sheet as HTMLElement,
+ "settings.sensitive-data.apply-masking"
+ ) as HTMLElement
+ );
await flush();
expect(mocks.updateColumnCatalog).toHaveBeenCalledWith({