Skip to content

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

chore: support description in masking exception (#16004)

ecmadao48595268a2da
diff --git a/frontend/src/components/SensitiveData/GrantAccessForm.vue b/frontend/src/components/SensitiveData/GrantAccessForm.vue
index c6ff663d29..a9b3c2f49a 100644
--- a/frontend/src/components/SensitiveData/GrantAccessForm.vue
+++ b/frontend/src/components/SensitiveData/GrantAccessForm.vue
@@ -42,6 +42,16 @@
</div>
</div>
+ <div class="w-full">
+ <p class="mb-2 text-main">
+ {{ $t("common.reason") }}
+ </p>
+ <NInput
+ v-model:value="state.description"
+ :placeholder="$t('common.description')"
+ />
+ </div>
+
<div class="w-full">
<p class="mb-2 text-main">
{{ $t("common.expiration") }}
@@ -90,7 +100,7 @@
<script lang="tsx" setup>
import { isUndefined } from "lodash-es";
-import { NButton, NCheckbox, NDatePicker } from "naive-ui";
+import { NButton, NCheckbox, NDatePicker, NInput } from "naive-ui";
import { computed, reactive } from "vue";
import { useI18n } from "vue-i18n";
import DatabaseResourceForm from "@/components/GrantRequestPanel/DatabaseResourceForm/index.vue";
@@ -129,6 +139,7 @@ interface LocalState {
processing: boolean;
supportActions: Set<MaskingExceptionPolicy_MaskingException_Action>;
databaseResources?: DatabaseResource[];
+ description: string;
}
const ACTIONS = [
@@ -143,6 +154,7 @@ const state = reactive<LocalState>({
databaseResources: props.columnList.map(
convertSensitiveColumnToDatabaseResource
),
+ description: "",
});
const policyStore = usePolicyV1Store();
@@ -213,28 +225,24 @@ const getPendingUpdatePolicy = async (
for (const action of state.supportActions.values()) {
for (const member of state.memberList) {
- if (!state.databaseResources) {
+ const resourceExpressions = state.databaseResources?.map(
+ getExpressionsForDatabaseResource
+ ) ?? [[""]];
+ for (const expressionList of resourceExpressions) {
+ const resourceExpression = [...expressionList, ...expressions].filter(
+ (e) => e
+ );
maskingExceptions.push({
member,
action,
condition: Expr.fromPartial({
+ description: state.description,
expression:
- expressions.length > 0 ? expressions.join(" && ") : undefined,
+ resourceExpression.length > 0
+ ? resourceExpression.join(" && ")
+ : undefined,
}),
});
- } else {
- for (const databaseResource of state.databaseResources) {
- const resourceExpressions =
- getExpressionsForDatabaseResource(databaseResource);
- resourceExpressions.push(...expressions);
- maskingExceptions.push({
- member,
- action,
- condition: Expr.fromPartial({
- expression: resourceExpressions.join(" && "),
- }),
- });
- }
}
}
}
diff --git a/frontend/src/components/SensitiveData/MaskingExceptionUserTable.vue b/frontend/src/components/SensitiveData/MaskingExceptionUserTable.vue
index f639066b54..5efe7f15cc 100644
--- a/frontend/src/components/SensitiveData/MaskingExceptionUserTable.vue
+++ b/frontend/src/components/SensitiveData/MaskingExceptionUserTable.vue
@@ -187,6 +187,7 @@ const getAccessUsers = async (
): Promise<AccessUser | undefined> => {
let expirationTimestamp: number | undefined;
const expression = exception.condition?.expression ?? "";
+ const description = exception.condition?.description ?? "";
const matches = expirationTimeRegex.exec(expression);
if (matches) {
expirationTimestamp = new Date(matches[1]).getTime();
@@ -194,10 +195,11 @@ const getAccessUsers = async (
const access: AccessUser = {
type: "user",
- key: `${exception.member}:${expression}`,
+ key: `${exception.member}:${expression}.${description}`,
expirationTimestamp,
supportActions: new Set([exception.action]),
rawExpression: expression,
+ description,
databaseResource: condition.databaseResources
? condition.databaseResources[0]
: undefined,
@@ -425,6 +427,13 @@ const accessTableColumns = computed(
);
},
},
+ {
+ key: "reason",
+ title: t("common.reason"),
+ render: (item: AccessUser) => {
+ return item.description;
+ },
+ },
{
key: "operation",
title: "",
@@ -568,6 +577,7 @@ const updateExceptionPolicy = async () => {
action,
member,
condition: Expr.fromPartial({
+ description: accessUser.description,
expression: expressions.join(" && "),
}),
});
diff --git a/frontend/src/components/SensitiveData/types.ts b/frontend/src/components/SensitiveData/types.ts
index 1967505701..1b65890c88 100644
--- a/frontend/src/components/SensitiveData/types.ts
+++ b/frontend/src/components/SensitiveData/types.ts
@@ -32,5 +32,6 @@ export interface AccessUser {
supportActions: Set<MaskingExceptionPolicy_MaskingException_Action>;
expirationTimestamp?: number;
rawExpression: string;
+ description: string;
databaseResource?: DatabaseResource;
}