Skip to content

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

chore: support instance_id in risk condition (#17427)

ecmadaoe5d1af5913f1
diff --git a/backend/api/v1/release_service_check.go b/backend/api/v1/release_service_check.go
index dc585c67d4..1c3563e29f 100644
--- a/backend/api/v1/release_service_check.go
+++ b/backend/api/v1/release_service_check.go
@@ -244,6 +244,7 @@ loop:
commonArgs := map[string]any{
"environment_id": "",
"project_id": database.ProjectID,
+ "instance_id": instance.ResourceID,
"database_name": database.DatabaseName,
// convert to string type otherwise cel-go will complain that storepb.Engine is not string type.
"db_engine": engine.String(),
diff --git a/backend/common/cel.go b/backend/common/cel.go
index ed4558492e..3cd60e09d8 100644
--- a/backend/common/cel.go
+++ b/backend/common/cel.go
@@ -18,6 +18,7 @@ const celLimit = 1024 * 1024
var RiskFactors = []cel.EnvOption{
cel.Variable("environment_id", cel.StringType), // use environment.resource_id
cel.Variable("project_id", cel.StringType), // use project.resource_id
+ cel.Variable("instance_id", cel.StringType), // use instance.resource_id
cel.Variable("db_engine", cel.StringType),
cel.Variable("database_name", cel.StringType),
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index cea6e7b74a..dcb533989a 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -465,6 +465,7 @@ func (r *Runner) getDatabaseGeneralIssueRisk(ctx context.Context, issue *store.I
commonArgs := map[string]any{
"environment_id": environmentID,
"project_id": issue.Project.ResourceID,
+ "instance_id": instance.ResourceID,
"database_name": databaseName,
// convert to string type otherwise cel-go will complain that storepb.Engine is not string type.
"db_engine": instance.Metadata.GetEngine().String(),
@@ -588,6 +589,7 @@ func (r *Runner) getDatabaseDataExportIssueRisk(ctx context.Context, issue *stor
args := map[string]any{
"environment_id": "",
"project_id": issue.Project.ResourceID,
+ "instance_id": instance.ResourceID,
"database_name": databaseName,
"db_engine": instance.Metadata.GetEngine().String(),
}
diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/RuleDialog.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/RuleDialog.vue
index 0d00129fc6..955912caaf 100644
--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/RuleDialog.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/RuleDialog.vue
@@ -4,6 +4,7 @@
:title="title"
:close-on-esc="false"
:before-close="beforeClose"
+ style="width: 50rem; max-width: calc(100vw - 5rem)"
@close="dialog = undefined"
>
<RuleForm
diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/RuleForm.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/RuleForm.vue
index 79a9060527..9c59a3f254 100644
--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/RuleForm.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RuleDialog/RuleForm.vue
@@ -1,7 +1,5 @@
<template>
- <div
- class="w-[calc(100vw-8rem)] lg:max-w-[35vw] max-h-[calc(100vh-10rem)] flex flex-col gap-y-4 text-sm"
- >
+ <div class="max-h-[calc(100vh-10rem)] flex flex-col gap-y-4 text-sm">
<div class="flex-1 flex flex-col px-0.5 overflow-hidden space-y-4">
<div class="space-y-1">
<label class="block font-medium text-control space-x-1">
@@ -41,7 +39,7 @@
<div class="text-control-light">
{{ $t("custom-approval.approval-flow.node.description") }}
</div>
- <div class="py-1 w-[30rem] space-y-2">
+ <div class="py-1 space-y-2">
<StepsTable
v-if="state.rule.template.flow"
:flow="state.rule.template.flow"
diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/common/StepsTable.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/common/StepsTable.vue
index dce8975e44..8c19be928a 100644
--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/common/StepsTable.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/common/StepsTable.vue
@@ -74,6 +74,8 @@ const columns = computed((): DataTableColumn<ApprovalStep>[] => {
{
title: t("custom-approval.approval-flow.node.approver"),
key: "approver",
+ minWidth: 200,
+ resizable: true,
render: (step) => {
if (props.editable) {
return (
@@ -101,7 +103,6 @@ const columns = computed((): DataTableColumn<ApprovalStep>[] => {
cols.push({
title: t("common.operations"),
key: "operations",
- width: 200,
render: (step, index) => (
<div class="flex gap-x-1">
<NButton
@@ -124,7 +125,7 @@ const columns = computed((): DataTableColumn<ApprovalStep>[] => {
tooltip={t("custom-approval.approval-flow.node.delete")}
onConfirm={() => removeStep(step, index)}
>
- <TrashIcon class={"w-4"} />
+ <TrashIcon class={"w-3"} />
</SpinnerButton>
)}
</div>
diff --git a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts b/frontend/src/components/CustomApproval/Settings/components/common/utils.ts
index b38f387127..10ac70317d 100644
--- a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts
+++ b/frontend/src/components/CustomApproval/Settings/components/common/utils.ts
@@ -3,6 +3,7 @@ import type { SelectOption } from "naive-ui";
import { h } from "vue";
import type { VNode } from "vue";
import { type OptionConfig } from "@/components/ExprEditor/context";
+import { getInstanceIdOptions } from "@/components/SensitiveData/components/utils";
import { EnvironmentV1Name } from "@/components/v2";
import { SQLTypeList, type Factor } from "@/plugins/cel";
import { t } from "@/plugins/i18n";
@@ -10,6 +11,7 @@ import {
environmentNamePrefix,
useEnvironmentV1Store,
useProjectV1Store,
+ useInstanceV1Store,
useRoleStore,
} from "@/store";
import {
@@ -73,6 +75,7 @@ export const orderByLevelDesc = (a: Risk, b: Risk): number => {
const commonFactorList = [
"environment_id", // use `environment.resource_id` instead.
"project_id", // use `project.resource_id` instead.
+ "instance_id", // use `instance.resource_id` instead.
"db_engine",
] as const;
@@ -257,6 +260,23 @@ export const getOptionConfigMap = (source: Risk_Source) => {
},
});
return map;
+ case "instance_id":
+ const store = useInstanceV1Store();
+ map.set(factor, {
+ remote: true,
+ options: [],
+ search: async (keyword: string) => {
+ return store
+ .fetchInstanceList({
+ pageSize: getDefaultPagination(),
+ filter: {
+ query: keyword,
+ },
+ })
+ .then((resp) => getInstanceIdOptions(resp.instances));
+ },
+ });
+ return map;
case "db_engine":
options = getDBEndingOptions();
break;
@@ -284,6 +304,7 @@ export const getOptionConfigMap = (source: Risk_Source) => {
export const factorSupportDropdown: Factor[] = [
"environment_id",
"project_id",
+ "instance_id",
"db_engine",
"sql_type",
"level",