Skip to content

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

chore: update masking algorithm (#13168)

ecmadao9516be5401b7
diff --git a/frontend/src/components/ColumnDataTable/SemanticTypeCell.vue b/frontend/src/components/ColumnDataTable/SemanticTypeCell.vue
index d9e185be66..f31acece9a 100644
--- a/frontend/src/components/ColumnDataTable/SemanticTypeCell.vue
+++ b/frontend/src/components/ColumnDataTable/SemanticTypeCell.vue
@@ -1,8 +1,8 @@
<template>
<div class="flex items-center">
- {{ columnSemanticType?.title }}
+ {{ semanticType?.title }}
<button
- v-if="!readonly && columnSemanticType"
+ v-if="!readonly && semanticType"
class="w-5 h-5 p-0.5 hover:bg-gray-300 rounded cursor-pointer"
@click.prevent="onSemanticTypeApply('')"
>
@@ -36,11 +36,8 @@
<script lang="ts" setup>
import { computed } from "vue";
import { reactive } from "vue";
-import {
- useDBSchemaV1Store,
- useSettingV1Store,
- useSubscriptionV1Store,
-} from "@/store";
+import { useSemanticType } from "@/components/SensitiveData/useSemanticType";
+import { useSubscriptionV1Store } from "@/store";
import type { ComposedDatabase } from "@/types";
import type {
ColumnMetadata,
@@ -68,8 +65,12 @@ const state = reactive<LocalState>({
showSemanticTypesDrawer: false,
});
const subscriptionV1Store = useSubscriptionV1Store();
-const settingV1Store = useSettingV1Store();
-const dbSchemaV1Store = useDBSchemaV1Store();
+const { semanticType, semanticTypeList } = useSemanticType({
+ database: props.database.name,
+ schema: props.schema,
+ table: props.table.name,
+ column: props.column.name,
+});
const hasSensitiveDataFeature = computed(() => {
return subscriptionV1Store.hasFeature("bb.feature.sensitive-data");
@@ -82,28 +83,6 @@ const instanceMissingLicense = computed(() => {
);
});
-const semanticTypeList = computed(() => {
- return (
- settingV1Store.getSettingByName("bb.workspace.semantic-types")?.value
- ?.semanticTypeSettingValue?.types ?? []
- );
-});
-
-const columnSemanticType = computed(() => {
- const config = dbSchemaV1Store.getColumnConfig(
- props.database.name,
- props.schema,
- props.table.name,
- props.column.name
- );
- if (!config.semanticTypeId) {
- return;
- }
- return semanticTypeList.value.find(
- (data) => data.id === config.semanticTypeId
- );
-});
-
const openSemanticTypeDrawer = () => {
if (!hasSensitiveDataFeature.value || instanceMissingLicense.value) {
state.showFeatureModal = true;
diff --git a/frontend/src/components/ColumnDataTable/index.vue b/frontend/src/components/ColumnDataTable/index.vue
index 18a06d549b..6e0851fb7f 100644
--- a/frontend/src/components/ColumnDataTable/index.vue
+++ b/frontend/src/components/ColumnDataTable/index.vue
@@ -206,12 +206,12 @@ const columns = computed(() => {
width: 140,
resizable: true,
render: (column) => {
- const columnConfig = dbSchemaStore.getColumnConfig(
- props.database.name,
- props.schema,
- props.table.name,
- column.name
- );
+ const columnConfig = dbSchemaStore.getColumnConfig({
+ database: props.database.name,
+ schema: props.schema,
+ table: props.table.name,
+ column: column.name,
+ });
return h(ClassificationCell, {
classification: columnConfig.classificationId,
classificationConfig:
diff --git a/frontend/src/components/EnvironmentForm/AccessControlConfigure.vue b/frontend/src/components/EnvironmentForm/AccessControlConfigure.vue
index 65cd267766..cd693115b1 100644
--- a/frontend/src/components/EnvironmentForm/AccessControlConfigure.vue
+++ b/frontend/src/components/EnvironmentForm/AccessControlConfigure.vue
@@ -65,7 +65,7 @@
<script setup lang="ts">
import { NRadioGroup, NRadio } from "naive-ui";
-import { computed } from "vue";
+import { computed, watchEffect } from "vue";
import { useI18n } from "vue-i18n";
import {
hasFeature,
@@ -90,6 +90,19 @@ const policyStore = usePolicyV1Store();
const me = useCurrentUserV1();
const { t } = useI18n();
+watchEffect(async () => {
+ await Promise.all([
+ policyStore.getOrFetchPolicyByParentAndType({
+ parentPath: props.resource,
+ policyType: PolicyType.DISABLE_COPY_DATA,
+ }),
+ policyStore.getOrFetchPolicyByParentAndType({
+ parentPath: props.resource,
+ policyType: PolicyType.DATA_SOURCE_QUERY,
+ }),
+ ]);
+});
+
const disableCopyDataPolicy = computed(() => {
return policyStore.getPolicyByParentAndType({
parentPath: props.resource,
diff --git a/frontend/src/components/EnvironmentForm/Form.vue b/frontend/src/components/EnvironmentForm/Form.vue
index 1721584ff1..750c447499 100644
--- a/frontend/src/components/EnvironmentForm/Form.vue
+++ b/frontend/src/components/EnvironmentForm/Form.vue
@@ -135,22 +135,14 @@
<script lang="ts" setup>
import { NCheckbox, NInput } from "naive-ui";
import { Status } from "nice-grpc-common";
-import { computed, onMounted } from "vue";
+import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { BBButtonConfirm } from "@/bbkit";
-import {
- useEnvironmentV1List,
- useEnvironmentV1Store,
- usePolicyV1Store,
-} from "@/store";
+import { useEnvironmentV1List, useEnvironmentV1Store } from "@/store";
import { environmentNamePrefix } from "@/store/modules/v1/common";
import type { ResourceId, ValidatedMessage } from "@/types";
import { State } from "@/types/proto/v1/common";
import { EnvironmentTier } from "@/types/proto/v1/environment_service";
-import {
- PolicyResourceType,
- PolicyType,
-} from "@/types/proto/v1/org_policy_service";
import { extractEnvironmentResourceName } from "@/utils";
import { getErrorCode } from "@/utils/grpcweb";
import { FeatureBadge } from "../FeatureGuard";
@@ -176,7 +168,6 @@ const {
events,
resourceIdField,
} = useEnvironmentFormContext();
-const policyStore = usePolicyV1Store();
const environmentList = useEnvironmentV1List();
const allowArchive = computed(() => {
@@ -189,13 +180,6 @@ const allowRestore = computed(() => {
return hasPermission("bb.environments.undelete");
});
-const prepareEnvironmentDisableCopyDataPolicy = async () => {
- await policyStore.fetchPolicies({
- resourceType: PolicyResourceType.ENVIRONMENT,
- policyType: PolicyType.DISABLE_COPY_DATA,
- });
-};
-
const validateResourceId = async (
resourceId: ResourceId
): Promise<ValidatedMessage[]> => {
@@ -233,8 +217,4 @@ const archiveEnvironment = () => {
const restoreEnvironment = () => {
events.emit("restore", state.value.environment);
};
-
-onMounted(() => {
- prepareEnvironmentDisableCopyDataPolicy();
-});
</script>
diff --git a/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vue b/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vue
index 443b31255a..c542507845 100644
--- a/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vue
+++ b/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vue
@@ -43,10 +43,10 @@
v-model:value="state.fullMaskingAlgorithmId"
:options="algorithmList"
:consistent-menu-width="false"
- :placeholder="$t('settings.sensitive-data.algorithms.default')"
+ :placeholder="columnDefaultMaskingAlgorithm"
:fallback-option="
(_: string) => ({
- label: $t('settings.sensitive-data.algorithms.default'),
+ label: columnDefaultMaskingAlgorithm,
value: '',
})
"
@@ -77,10 +77,10 @@
v-model:value="state.partialMaskingAlgorithmId"
:options="algorithmList"
:consistent-menu-width="false"
- :placeholder="$t('settings.sensitive-data.algorithms.default')"
+ :placeholder="columnDefaultMaskingAlgorithm"
:fallback-option="
(_: string) => ({
- label: $t('settings.sensitive-data.algorithms.default'),
+ label: columnDefaultMaskingAlgorithm,
value: '',
})
"
@@ -272,6 +272,7 @@ import { computed, reactive, watch, ref } from "vue";
import { useI18n } from "vue-i18n";
import { BBGrid } from "@/bbkit";
import type { BBGridColumn, BBGridRow } from "@/bbkit/types";
+import { useSemanticType } from "@/components/SensitiveData/useSemanticType";
import GroupNameCell from "@/components/User/Settings/UserDataTableByGroup/cells/GroupNameCell.vue";
import { Drawer, DrawerContent, MiniActionButton } from "@/components/v2";
import { WORKSPACE_ROUTE_USER_PROFILE } from "@/router/dashboard/workspaceRoutes";
@@ -294,6 +295,7 @@ import {
} from "@/types";
import { Expr } from "@/types/proto/google/type/expr";
import { MaskingLevel, maskingLevelToJSON } from "@/types/proto/v1/common";
+import type { Group } from "@/types/proto/v1/group";
import type {
Policy,
MaskData,
@@ -304,7 +306,6 @@ import {
PolicyResourceType,
MaskingExceptionPolicy_MaskingException_Action,
} from "@/types/proto/v1/org_policy_service";
-import type { Group } from "@/types/proto/v1/group";
import { hasWorkspacePermissionV2 } from "@/utils";
import UserAvatar from "../User/UserAvatar.vue";
import GrantAccessDrawer from "./GrantAccessDrawer.vue";
@@ -365,6 +366,19 @@ const accessUserList = ref<AccessUser[]>([]);
const policyStore = usePolicyV1Store();
const dbSchemaStore = useDBSchemaV1Store();
const settingStore = useSettingV1Store();
+const { semanticType } = useSemanticType({
+ database: props.column.database.name,
+ schema: props.column.maskData.schema,
+ table: props.column.maskData.table,
+ column: props.column.maskData.column,
+});
+
+const columnDefaultMaskingAlgorithm = computed(() => {
+ if (semanticType.value) {
+ return t("settings.sensitive-data.algorithms.default-with-semantic-type");
+ }
+ return t("settings.sensitive-data.algorithms.default");
+});
const policy = usePolicyByParentAndType(
computed(() => ({
@@ -730,7 +744,7 @@ const algorithmList = computed((): SelectOption[] => {
}));
list.unshift({
- label: t("settings.sensitive-data.algorithms.default"),
+ label: columnDefaultMaskingAlgorithm.value,
value: "",
});
diff --git a/frontend/src/components/SensitiveData/useSemanticType.ts b/frontend/src/components/SensitiveData/useSemanticType.ts
new file mode 100644
index 0000000000..f6fdcbd868
--- /dev/null
+++ b/frontend/src/components/SensitiveData/useSemanticType.ts
@@ -0,0 +1,44 @@
+import { computed } from "vue";
+import { useDBSchemaV1Store, useSettingV1Store } from "@/store";
+
+export const useSemanticType = ({
+ database,
+ schema,
+ table,
+ column,
+}: {
+ database: string;
+ schema: string;
+ table: string;
+ column: string;
+}) => {
+ const settingV1Store = useSettingV1Store();
+ const dbSchemaV1Store = useDBSchemaV1Store();
+
+ const semanticTypeList = computed(() => {
+ return (
+ settingV1Store.getSettingByName("bb.workspace.semantic-types")?.value
+ ?.semanticTypeSettingValue?.types ?? []
+ );
+ });
+
+ const semanticType = computed(() => {
+ const config = dbSchemaV1Store.getColumnConfig({
+ database,
+ schema,
+ table,
+ column,
+ });
+ if (!config.semanticTypeId) {
+ return;
+ }
+ return semanticTypeList.value.find(
+ (data) => data.id === config.semanticTypeId
+ );
+ });
+
+ return {
+ semanticTypeList,
+ semanticType,
+ };
+};
diff --git a/frontend/src/components/v2/TabFilter/EnvironmentTabFilter.vue b/frontend/src/components/v2/TabFilter/EnvironmentTabFilter.vue
index 0dcdf8584b..0b2f616d4b 100644
--- a/frontend/src/components/v2/TabFilter/EnvironmentTabFilter.vue
+++ b/frontend/src/components/v2/TabFilter/EnvironmentTabFilter.vue
@@ -2,7 +2,7 @@
<TabFilter
:value="environment"
:items="items"
- @update:value="$emit('update:environment-name', $event as string)"
+ @update:value="$emit('update:environment', $event as string)"
>
<template #label="{ item }">
<template v-if="item.value === UNKNOWN_ENVIRONMENT_NAME">{{
@@ -43,7 +43,7 @@ const props = withDefaults(
);
defineEmits<{
- (event: "update:environment-name", id: string): void;
+ (event: "update:environment", name: string): void;
}>();
const { t } = useI18n();
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 8a8a128ed1..cf8cfc19e3 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -811,7 +811,8 @@
"override-desc": "Existed algorithms will be overridden, you have to re-configure the algorithm for semantic types.",
"override-confirm": "Still upload",
"default": "Default",
- "default-desc": "Use *** as data mask",
+ "default-with-semantic-type": "Default (Follow semantic type)",
+ "default-desc": "Use * to cover full or partial text depending on the masking level",
"table": {
"title": "Title",
"description": "Description",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index a33995298b..45ed9263ef 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -811,7 +811,8 @@
"override-desc": "Los algoritmos existentes se anularán; deberá volver a configurar el algoritmo para tipos semánticos.",
"override-confirm": "Aún subiendo",
"default": "Por defecto",
- "default-desc": "Utilice *** como máscara de datos",
+ "default-with-semantic-type": "Predeterminado (Seguir tipo semántico)",
+ "default-desc": "Utilice * para cubrir texto completo o parcial según el nivel de enmascaramiento",
"table": {
"title": "Título",
"description": "Descripción",
@@ -3633,4 +3634,4 @@
"self": "Última actualización"
}
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 6b04e57542..a5df399fa7 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -811,7 +811,8 @@
"override-desc": "既存のアルゴリズムは上書きされるため、セマンティック タイプに合わせてアルゴリズムを再構成する必要があります。",
"override-confirm": "インポートを続行する",
"default": "デフォルト",
- "default-desc": "*** を使用してデータをマスクする",
+ "default-with-semantic-type": "デフォルト(セマンティックタイプに従う)",
+ "default-desc": "* を使用して、感度解除のレベルに応じてデータのすべてまたは一部をブロックします。",
"table": {
"title": "名前",
"description": "説明する",
@@ -3633,4 +3634,4 @@
"self": "最後の更新"
}
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index d317d2ea23..4515da5913 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -811,7 +811,8 @@
"override-desc": "现有的算法将被覆盖,您必须重新配置语义类型的算法。",
"override-confirm": "继续导入",
"default": "默认",
- "default-desc": "使用 *** 为数据遮挡",
+ "default-with-semantic-type": "默认(遵循语义类型)",
+ "default-desc": "根据脱敏程度使用 * 遮挡所有或者部分数据",
"table": {
"title": "名称",
"description": "描述",
@@ -3633,4 +3634,4 @@
"self": "最后更新"
}
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/store/modules/v1/dbSchema.ts b/frontend/src/store/modules/v1/dbSchema.ts
index c8ce7161b0..1604fab764 100644
--- a/frontend/src/store/modules/v1/dbSchema.ts
+++ b/frontend/src/store/modules/v1/dbSchema.ts
@@ -224,12 +224,17 @@ export const useDBSchemaV1Store = defineStore("dbSchema_v1", () => {
);
};
- const getColumnConfig = (
- database: string,
- schema: string,
- table: string,
- column: string
- ) => {
+ const getColumnConfig = ({
+ database,
+ schema,
+ table,
+ column,
+ }: {
+ database: string;
+ schema: string;
+ table: string;
+ column: string;
+ }) => {
const tableConfig = getTableConfig(database, schema, table);
return (