From 6a156371c0680c076b9267ee191405a25ce26247 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 24 Jul 2024 19:42:29 +0530 Subject: [PATCH] feat: resolved bug reported on search and integration failing due to typo in integration field --- .../integration-auth-service.ts | 2 +- .../services/integration/integration-dal.ts | 6 +++--- backend/src/services/secret/secret-queue.ts | 4 ++-- frontend/src/hooks/api/secrets/queries.tsx | 2 +- frontend/src/hooks/api/secrets/types.ts | 4 ++-- .../SecretImportListView/SecretImportItem.tsx | 20 +++++++++---------- .../SecretImportListView.tsx | 2 +- .../SecretListView/SecretDetaiSidebar.tsx | 7 ++++++- .../SecretListView/SecretListView.tsx | 2 +- .../SecretListView/SecretListView.utils.ts | 5 ++++- 10 files changed, 30 insertions(+), 24 deletions(-) diff --git a/backend/src/services/integration-auth/integration-auth-service.ts b/backend/src/services/integration-auth/integration-auth-service.ts index 41bb929c5..5ffed26d2 100644 --- a/backend/src/services/integration-auth/integration-auth-service.ts +++ b/backend/src/services/integration-auth/integration-auth-service.ts @@ -329,7 +329,7 @@ export const integrationAuthServiceFactory = ({ if ( integrationAuth.integration === Integrations.AWS_SECRET_MANAGER && (shouldUseSecretV2Bridge - ? integrationAuth.encryptedAwsIamAssumRole + ? integrationAuth.encryptedAwsAssumeIamRoleArn : integrationAuth.awsAssumeIamRoleArnCipherText) ) { return { accessToken: "", accessId: "" }; diff --git a/backend/src/services/integration/integration-dal.ts b/backend/src/services/integration/integration-dal.ts index 66a124a29..0c365eb06 100644 --- a/backend/src/services/integration/integration-dal.ts +++ b/backend/src/services/integration/integration-dal.ts @@ -127,7 +127,7 @@ export const integrationDALFactory = (db: TDbClient) => { db.ref("encryptedRefresh").withSchema(TableName.IntegrationAuth), db.ref("encryptedAccess").withSchema(TableName.IntegrationAuth), db.ref("encryptedAccessId").withSchema(TableName.IntegrationAuth), - db.ref("encryptedAwsIamAssumRole").withSchema(TableName.IntegrationAuth) + db.ref("encryptedAwsAssumeIamRoleArn").withSchema(TableName.IntegrationAuth) ); return docs.map( ({ @@ -159,7 +159,7 @@ export const integrationDALFactory = (db: TDbClient) => { encryptedAccess, encryptedRefresh, encryptedAccessId, - encryptedAwsIamAssumRole, + encryptedAwsAssumeIamRoleArn, ...el }) => ({ ...el, @@ -195,7 +195,7 @@ export const integrationDALFactory = (db: TDbClient) => { encryptedAccess, encryptedRefresh, encryptedAccessId, - encryptedAwsIamAssumRole + encryptedAwsAssumeIamRoleArn } }) ); diff --git a/backend/src/services/secret/secret-queue.ts b/backend/src/services/secret/secret-queue.ts index 01bbc8c36..e1c13496b 100644 --- a/backend/src/services/secret/secret-queue.ts +++ b/backend/src/services/secret/secret-queue.ts @@ -635,9 +635,9 @@ export const secretQueueFactory = ({ ); let awsAssumeRoleArn = null; if (shouldUseSecretV2Bridge) { - if (integrationAuth.encryptedAwsIamAssumRole) { + if (integrationAuth.encryptedAwsAssumeIamRoleArn) { awsAssumeRoleArn = secretManagerDecryptor({ - cipherTextBlob: Buffer.from(integrationAuth.encryptedAwsIamAssumRole) + cipherTextBlob: Buffer.from(integrationAuth.encryptedAwsAssumeIamRoleArn) }).toString(); } } else if ( diff --git a/frontend/src/hooks/api/secrets/queries.tsx b/frontend/src/hooks/api/secrets/queries.tsx index 1ad710db4..192a3befb 100644 --- a/frontend/src/hooks/api/secrets/queries.tsx +++ b/frontend/src/hooks/api/secrets/queries.tsx @@ -44,7 +44,7 @@ export const fetchProjectSecrets = async ({ }; export const mergePersonalSecrets = (rawSecrets: SecretV3Raw[]) => { - const personalSecrets: Record = {}; + const personalSecrets: Record = {}; const secrets: SecretV3RawSanitized[] = []; rawSecrets.forEach((el) => { const decryptedSecret: SecretV3RawSanitized = { diff --git a/frontend/src/hooks/api/secrets/types.ts b/frontend/src/hooks/api/secrets/types.ts index fbc67b92e..ff87a363a 100644 --- a/frontend/src/hooks/api/secrets/types.ts +++ b/frontend/src/hooks/api/secrets/types.ts @@ -34,7 +34,7 @@ export type SecretV3RawSanitized = { id: string; version: number; key: string; - value: string; + value?: string; comment?: string; reminderRepeatDays?: number | null; reminderNote?: string | null; @@ -57,7 +57,7 @@ export type SecretV3Raw = { version: number; type: string; secretKey: string; - secretValue: string; + secretValue?: string; secretComment?: string; secretReminderNote?: string; secretReminderRepeatDays?: number; diff --git a/frontend/src/views/SecretMainPage/components/SecretImportListView/SecretImportItem.tsx b/frontend/src/views/SecretMainPage/components/SecretImportListView/SecretImportItem.tsx index fee86bc14..9be3cf03b 100644 --- a/frontend/src/views/SecretMainPage/components/SecretImportListView/SecretImportItem.tsx +++ b/frontend/src/views/SecretMainPage/components/SecretImportListView/SecretImportItem.tsx @@ -19,13 +19,7 @@ import { twMerge } from "tailwind-merge"; import { createNotification } from "@app/components/notifications"; import { ProjectPermissionCan } from "@app/components/permissions"; -import { - EmptyState, - IconButton, - SecretInput, - TableContainer, - Tooltip -} from "@app/components/v2"; +import { EmptyState, IconButton, SecretInput, TableContainer, Tooltip } from "@app/components/v2"; import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context"; import { useToggle } from "@app/hooks"; import { useResyncSecretReplication } from "@app/hooks/api"; @@ -37,7 +31,11 @@ type Props = { secretPath?: string; secretImport?: TSecretImport; isReplicationExpand?: boolean; - importedSecrets: { key: string; value: string; overriden: { env: string; secretPath: string } }[]; + importedSecrets: { + key: string; + value?: string; + overriden: { env: string; secretPath: string }; + }[]; searchTerm: string; onExpandReplicateSecrets: (id: string) => void; }; @@ -45,9 +43,9 @@ type Props = { // to show the environment and folder icon export const EnvFolderIcon = ({ env, - secretPath, - // isReplication -}: { + secretPath +}: // isReplication +{ env: string; secretPath: string; // isReplication?: boolean; diff --git a/frontend/src/views/SecretMainPage/components/SecretImportListView/SecretImportListView.tsx b/frontend/src/views/SecretMainPage/components/SecretImportListView/SecretImportListView.tsx index 7846639d7..db2627dd6 100644 --- a/frontend/src/views/SecretMainPage/components/SecretImportListView/SecretImportListView.tsx +++ b/frontend/src/views/SecretMainPage/components/SecretImportListView/SecretImportListView.tsx @@ -63,7 +63,7 @@ export const computeImportedSecretRows = ( const importedEntry: Record = {}; const importedSecretEntries: { key: string; - value: string; + value?: string; overriden: { env: string; secretPath: string; diff --git a/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetaiSidebar.tsx b/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetaiSidebar.tsx index ae1a3d851..2e983bda6 100644 --- a/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetaiSidebar.tsx +++ b/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetaiSidebar.tsx @@ -417,7 +417,12 @@ export const SecretDetailSidebar = ({ className="px-2 py-1" variant="outline_bg" leftIcon={} - onClick={() => handleSecretShare(secret.valueOverride ?? secret.value)} + onClick={() => { + const value = secret?.valueOverride ?? secret?.value; + if (value) { + handleSecretShare(value); + } + }} > Share Secret diff --git a/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.tsx b/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.tsx index a9597e214..0e58be0c3 100644 --- a/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.tsx +++ b/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.tsx @@ -79,7 +79,7 @@ export const filterSecrets = (secrets: SecretV3RawSanitized[], filter: Filter) = const searchTerm = filter.searchFilter.toLowerCase(); return ( (!isTagFilterActive || tags?.some(({ id }) => filter.tags?.[id])) && - (key.toLowerCase().includes(searchTerm) || value.toLowerCase().includes(searchTerm)) + (key.toLowerCase().includes(searchTerm) || value?.toLowerCase().includes(searchTerm)) ); }); diff --git a/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.utils.ts b/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.utils.ts index 0a3d22c8e..a3040b43c 100644 --- a/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.utils.ts +++ b/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.utils.ts @@ -23,7 +23,10 @@ export enum SecretActionType { export const formSchema = z.object({ key: z.string().trim().min(1, { message: "Secret key is required" }), - value: z.string().transform((val) => (val.at(-1) === "\n" ? `${val.trim()}\n` : val.trim())), + value: z + .string() + .transform((val) => (val.at(-1) === "\n" ? `${val.trim()}\n` : val.trim())) + .optional(), idOverride: z.string().trim().optional(), valueOverride: z .string()