Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: update info and statement compare (#19364)
ecmadao2546d140aafd
diff --git a/backend/api/v1/access_grant_service.go b/backend/api/v1/access_grant_service.goindex 85e4f66f9e..510db01678 100644--- a/backend/api/v1/access_grant_service.go+++ b/backend/api/v1/access_grant_service.go@@ -145,6 +145,9 @@ func (s *AccessGrantService) CreateAccessGrant(ctx context.Context, request *conif ag.Query == "" {return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("query is required"))}+ if ag.Reason == "" {+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("reason is required"))+ }// Validate the query is a read-only statement (SELECT).instanceID, _, err := common.GetInstanceDatabaseID(ag.Targets[0])diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.goindex 3c99e933e2..0190784a0a 100644--- a/backend/api/v1/sql_service.go+++ b/backend/api/v1/sql_service.go@@ -216,7 +216,7 @@ func (s *SQLService) preCheckAccess(ctx context.Context, request *v1pb.QueryRequslog.Warn("invalid access grant payload", slog.String("access_grant", accessGrantID))return nil}- if accessGrant.Payload.Query != request.Statement {+ if strings.TrimSpace(accessGrant.Payload.Query) != strings.TrimSpace(request.Statement) {slog.Warn("statement does not match access grant", slog.String("access_grant", accessGrantID))return nil}diff --git a/backend/server/marshaler.go b/backend/server/marshaler.goindex 44f28b9506..1f25de1395 100644--- a/backend/server/marshaler.go+++ b/backend/server/marshaler.go@@ -4,10 +4,11 @@ import ("fmt""io""regexp"- "sort"+ "slices""strings"grpcruntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"+ "github.com/pkg/errors""google.golang.org/protobuf/proto")@@ -63,9 +64,9 @@ func (d *suggestingDecoder) Decode(v any) error {suggestions := findSimilar(unknownField, candidates, 3)if len(suggestions) == 0 {- return fmt.Errorf("%w. Valid fields: %s", err, strings.Join(candidates, ", "))+ return errors.Wrapf(err, "valid fields: %s", strings.Join(candidates, ", "))}- return fmt.Errorf("%w. Did you mean: %s?", err, strings.Join(suggestions, ", "))+ return errors.Wrapf(err, "did you mean: %s?", strings.Join(suggestions, ", "))}// findSimilar returns up to maxResults field names sorted by edit distance.@@ -88,8 +89,8 @@ func findSimilar(input string, candidates []string, maxResults int) []string {results = append(results, scored{name: c, dist: d})}}- sort.Slice(results, func(i, j int) bool {- return results[i].dist < results[j].dist+ slices.SortFunc(results, func(a, b scored) int {+ return a.dist - b.dist})var out []stringfor i := 0; i < len(results) && i < maxResults; i++ {diff --git a/frontend/src/components/Plan/components/IssueReviewView/AccessGrantView/AccessGrantDetailsSection.vue b/frontend/src/components/Plan/components/IssueReviewView/AccessGrantView/AccessGrantDetailsSection.vueindex a8c599beea..d0cbfd7827 100644--- a/frontend/src/components/Plan/components/IssueReviewView/AccessGrantView/AccessGrantDetailsSection.vue+++ b/frontend/src/components/Plan/components/IssueReviewView/AccessGrantView/AccessGrantDetailsSection.vue@@ -46,7 +46,7 @@</div><!-- Expiration -->- <div class="flex flex-col gap-y-2">+ <div class="flex flex-col gap-y-1"><span class="text-sm text-control-light"><template v-if="expirationInfo.type === 'duration'">{{ $t("common.duration") }}diff --git a/frontend/src/layouts/BodyLayout.vue b/frontend/src/layouts/BodyLayout.vueindex c535a47b8c..cb7be68511 100644--- a/frontend/src/layouts/BodyLayout.vue+++ b/frontend/src/layouts/BodyLayout.vue@@ -55,6 +55,7 @@class="md:min-w-0 flex-1 overflow-y-auto"><RoutePermissionGuard+ class="m-4":routes="[...workspaceRoutes,...workspaceSettingRoutes,diff --git a/frontend/src/layouts/ProjectV1Layout.vue b/frontend/src/layouts/ProjectV1Layout.vueindex dd81f7b5fa..a69058561b 100644--- a/frontend/src/layouts/ProjectV1Layout.vue+++ b/frontend/src/layouts/ProjectV1Layout.vue@@ -11,6 +11,7 @@</template><RoutePermissionGuard+ class="m-4":project="project":routes="projectRoutes">diff --git a/frontend/src/views/project/ProjectAccessGrantDashboard.vue b/frontend/src/views/project/ProjectAccessGrantDashboard.vueindex 6c9596c400..80003d1e5e 100644--- a/frontend/src/views/project/ProjectAccessGrantDashboard.vue+++ b/frontend/src/views/project/ProjectAccessGrantDashboard.vue@@ -4,6 +4,7 @@<ComponentPermissionGuard:project="project"+ class="mx-4":permissions="['bb.accessGrants.list']"><div class="px-4 pb-2 flex items-center gap-x-2">@@ -42,7 +43,7 @@</PagedTable></ComponentPermissionGuard>- <NAlert v-if="!canList" type="info" class="mx-4 mt-2">+ <BBAttention v-if="!canList" type="info" class="mx-4 mt-2"><i18n-t keypath="sql-editor.access-grants-redirect-hint" tag="span"><template #link><router-link@@ -57,14 +58,13 @@</router-link></template></i18n-t>- </NAlert>+ </BBAttention></div></template><script setup lang="ts">import type { DataTableColumn, DataTableSortState } from "naive-ui";import {- NAlert,NButton,NDataTable,NEmpty,@@ -75,6 +75,7 @@ import {import { computed, h, ref, type VNode, watch } from "vue";import type { ComponentExposed } from "vue-component-type-helpers";import { useI18n } from "vue-i18n";+import { BBAttention } from "@/bbkit";import BBAvatar from "@/bbkit/BBAvatar.vue";import AdvancedSearch from "@/components/AdvancedSearch";import type {diff --git a/frontend/src/views/project/ProjectDatabaseLayout.vue b/frontend/src/views/project/ProjectDatabaseLayout.vueindex d6fe598e95..f7a9a527ad 100644--- a/frontend/src/views/project/ProjectDatabaseLayout.vue+++ b/frontend/src/views/project/ProjectDatabaseLayout.vue@@ -1,5 +1,6 @@<template><router-view+ class="p-4":project-id="projectId":instance-id="instanceId":database-name="databaseName"diff --git a/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessGrantRequestDrawer.vue b/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessGrantRequestDrawer.vueindex 25eb6f39bf..77d597f87c 100644--- a/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessGrantRequestDrawer.vue+++ b/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessGrantRequestDrawer.vue@@ -30,6 +30,9 @@{{ $t("common.statement") }}<RequiredStar class="ml-0.5" /></div>+ <BBAttention type="info">+ {{ $t("sql-editor.only-select-allowed") }}+ </BBAttention><MonacoEditorclass="border rounded-[3px] h-40":content="form.query"@@ -71,6 +74,7 @@<div class="flex flex-col gap-y-2"><div class="text-sm font-medium text-control">{{ $t("common.reason") }}+ <RequiredStar class="ml-0.5" /></div><NInputv-model:value="form.reason"@@ -107,6 +111,7 @@ import { NButton, NCheckbox, NDatePicker, NInput, NSelect } from "naive-ui";import { computed, reactive, ref } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";+import { BBAttention } from "@/bbkit";import { MonacoEditor } from "@/components/MonacoEditor";import RequiredStar from "@/components/RequiredStar.vue";import { DatabaseSelect, Drawer, DrawerContent } from "@/components/v2";@@ -197,6 +202,7 @@ const isDateDisabled = (ts: number) => {const allowSubmit = computed(() => {if (form.targets.length === 0) return false;if (!form.query.trim()) return false;+ if (!form.reason) return false;if (form.duration === -1 && !form.customExpireTime) return false;return true;});diff --git a/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessPane.vue b/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessPane.vueindex c74f8ce88b..4cd004664c 100644--- a/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessPane.vue+++ b/frontend/src/views/sql-editor/AsidePanel/AccessPane/AccessPane.vue@@ -15,21 +15,29 @@:cache-query="false"@update:params="searchParams = $event"/>- <NButton- ghost- size="small"- type="primary"- :style="{- width: useSmallLayout ? '100%' : 'auto'- }"- :disabled="!hasJITFeature"- @click="showDrawer = true"+ <PermissionGuardWrapper+ v-slot="slotProps"+ :project="project"+ :permissions="[+ 'bb.accessGrants.create'+ ]">- <template v-if="!hasJITFeature" #icon>- <FeatureBadge :clickable="false" :feature="PlanFeature.FEATURE_JIT" />- </template>- {{ $t("sql-editor.request-access") }}- </NButton>+ <NButton+ ghost+ size="small"+ type="primary"+ :style="{+ width: useSmallLayout ? '100%' : 'auto'+ }"+ :disabled="!hasJITFeature || slotProps.disabled"+ @click="showDrawer = true"+ >+ <template v-if="!hasJITFeature" #icon>+ <FeatureBadge :clickable="false" :feature="PlanFeature.FEATURE_JIT" />+ </template>+ {{ $t("sql-editor.request-access") }}+ </NButton>+ </PermissionGuardWrapper></div><div class="w-full flex flex-col justify-start items-start overflow-y-auto"><AccessGrantItem@@ -85,6 +93,7 @@ import type {} from "@/components/AdvancedSearch/types";import { FeatureBadge } from "@/components/FeatureGuard";import MaskSpinner from "@/components/misc/MaskSpinner.vue";+import PermissionGuardWrapper from "@/components/Permission/PermissionGuardWrapper.vue";import { RichDatabaseName } from "@/components/v2";import { useExecuteSQL } from "@/composables/useExecuteSQL";import {@@ -93,6 +102,7 @@ import {useAccessGrantStore,useConnectionOfCurrentSQLEditorTab,useDatabaseV1Store,+ useProjectV1Store,useSQLEditorStore,useSQLEditorTabStore,} from "@/store";@@ -117,6 +127,7 @@ import AccessGrantRequestDrawer from "./AccessGrantRequestDrawer.vue";const PAGE_SIZE = getDefaultPagination();const { t } = useI18n();+const projectStore = useProjectV1Store();const editorStore = useSQLEditorStore();const tabStore = useSQLEditorTabStore();const databaseStore = useDatabaseV1Store();@@ -137,6 +148,10 @@ const useSmallLayout = computed(const hasJITFeature = computed(() => hasFeature(PlanFeature.FEATURE_JIT));+const project = computed(() =>+ projectStore.getProjectByName(editorStore.project)+);+const searchParams = ref<SearchParams>({query: "",scopes: [],