From 847c2c67ecbfdec969cdaf9a8d92bca1aae08616 Mon Sep 17 00:00:00 2001 From: Sheen Capadngan Date: Sat, 8 Jun 2024 00:30:30 +0800 Subject: [PATCH] adjustment: made secret-deletion opt in --- backend/src/lib/api-docs/constants.ts | 3 ++- backend/src/server/routes/v1/integration-router.ts | 3 ++- .../integration-auth/integration-sync-secret.ts | 2 +- .../src/services/integration/integration-types.ts | 2 ++ frontend/src/hooks/api/integrations/queries.tsx | 1 + frontend/src/pages/integrations/github/create.tsx | 14 +++++++------- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts index da82016f1..18db346dc 100644 --- a/backend/src/lib/api-docs/constants.ts +++ b/backend/src/lib/api-docs/constants.ts @@ -674,7 +674,8 @@ export const INTEGRATION = { secretGCPLabel: "The label for GCP secrets.", secretAWSTag: "The tags for AWS secrets.", kmsKeyId: "The ID of the encryption key from AWS KMS.", - shouldDisableDelete: "The flag to disable deletion of secrets in AWS Parameter Store." + shouldDisableDelete: "The flag to disable deletion of secrets in AWS Parameter Store.", + shouldEnableDelete: "The flag to enable deletion of secrets" } }, UPDATE: { diff --git a/backend/src/server/routes/v1/integration-router.ts b/backend/src/server/routes/v1/integration-router.ts index bdb58aa8b..70f59d558 100644 --- a/backend/src/server/routes/v1/integration-router.ts +++ b/backend/src/server/routes/v1/integration-router.ts @@ -73,7 +73,8 @@ export const registerIntegrationRouter = async (server: FastifyZodProvider) => { .optional() .describe(INTEGRATION.CREATE.metadata.secretAWSTag), kmsKeyId: z.string().optional().describe(INTEGRATION.CREATE.metadata.kmsKeyId), - shouldDisableDelete: z.boolean().optional().describe(INTEGRATION.CREATE.metadata.shouldDisableDelete) + shouldDisableDelete: z.boolean().optional().describe(INTEGRATION.CREATE.metadata.shouldDisableDelete), + shouldEnableDelete: z.boolean().optional().describe(INTEGRATION.CREATE.metadata.shouldEnableDelete) }) .default({}) }), diff --git a/backend/src/services/integration-auth/integration-sync-secret.ts b/backend/src/services/integration-auth/integration-sync-secret.ts index 123578e70..16016a0c0 100644 --- a/backend/src/services/integration-auth/integration-sync-secret.ts +++ b/backend/src/services/integration-auth/integration-sync-secret.ts @@ -1364,7 +1364,7 @@ const syncSecretsGitHub = async ({ } const metadata = z.record(z.any()).parse(integration.metadata); - if (!metadata.shouldDisableDelete) { + if (metadata.shouldEnableDelete) { for await (const encryptedSecret of encryptedSecrets) { if ( !(encryptedSecret.name in secrets) && diff --git a/backend/src/services/integration/integration-types.ts b/backend/src/services/integration/integration-types.ts index 9c75cad2d..db136c1ed 100644 --- a/backend/src/services/integration/integration-types.ts +++ b/backend/src/services/integration/integration-types.ts @@ -29,6 +29,7 @@ export type TCreateIntegrationDTO = { }[]; kmsKeyId?: string; shouldDisableDelete?: boolean; + shouldEnableDelete?: boolean; }; } & Omit; @@ -54,6 +55,7 @@ export type TUpdateIntegrationDTO = { }[]; kmsKeyId?: string; shouldDisableDelete?: boolean; + shouldEnableDelete?: boolean; }; } & Omit; diff --git a/frontend/src/hooks/api/integrations/queries.tsx b/frontend/src/hooks/api/integrations/queries.tsx index 3aa8f3ed1..e561280c6 100644 --- a/frontend/src/hooks/api/integrations/queries.tsx +++ b/frontend/src/hooks/api/integrations/queries.tsx @@ -73,6 +73,7 @@ export const useCreateIntegration = () => { }[]; kmsKeyId?: string; shouldDisableDelete?: boolean; + shouldEnableDelete?: boolean; }; }) => { const { diff --git a/frontend/src/pages/integrations/github/create.tsx b/frontend/src/pages/integrations/github/create.tsx index 2a92b07e6..1348f2e04 100644 --- a/frontend/src/pages/integrations/github/create.tsx +++ b/frontend/src/pages/integrations/github/create.tsx @@ -60,7 +60,7 @@ const schema = yup.object({ selectedSourceEnvironment: yup.string().trim().required("Project Environment is required"), secretPath: yup.string().trim().required("Secrets Path is required"), secretSuffix: yup.string().trim().optional(), - shouldDisableDelete: yup.boolean().optional(), + shouldEnableDelete: yup.boolean().optional(), scope: yup.mixed().oneOf(targetEnv.slice()).required(), repoIds: yup.mixed().when("scope", { @@ -121,7 +121,7 @@ export default function GitHubCreateIntegrationPage() { secretPath: "/", scope: "github-repo", repoIds: [], - shouldDisableDelete: false + shouldEnableDelete: false } }); @@ -179,7 +179,7 @@ export default function GitHubCreateIntegrationPage() { owner: targetApp.owner, // repo owner metadata: { secretSuffix: data.secretSuffix, - shouldDisableDelete: data.shouldDisableDelete + shouldEnableDelete: data.shouldEnableDelete } }); }) @@ -197,7 +197,7 @@ export default function GitHubCreateIntegrationPage() { owner: integrationAuthOrgs?.find((e) => e.orgId === data.orgId)?.name, metadata: { secretSuffix: data.secretSuffix, - shouldDisableDelete: data.shouldDisableDelete + shouldEnableDelete: data.shouldEnableDelete } }); break; @@ -215,7 +215,7 @@ export default function GitHubCreateIntegrationPage() { targetEnvironmentId: data.envId, metadata: { secretSuffix: data.secretSuffix, - shouldDisableDelete: data.shouldDisableDelete + shouldEnableDelete: data.shouldEnableDelete } }); break; @@ -553,14 +553,14 @@ export default function GitHubCreateIntegrationPage() {
( onChange(isChecked)} isChecked={value} > - Disable secrets deletion on Github + Delete secrets not in Infisical )} />