Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
add verification for static rotation, so syncs are not replaced
adilsonc8fbd325af63
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex 68327ec00b..56e6e75b87 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -1695,7 +1695,8 @@ export const registerRoutes = async (resourceMetadataDAL,reminderService,keyStore,- secretValidationRuleService+ secretValidationRuleService,+ secretRotationV2DAL});const secretApprovalRequestService = secretApprovalRequestServiceFactory({diff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.tsindex bbe9bfe066..e14bb70f3a 100644--- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts+++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts@@ -31,6 +31,7 @@ import {InternalMetadataType,TInternalMetadata} from "@app/ee/services/secret-approval-request/secret-approval-request-types";+import { TSecretRotationV2DALFactory } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-dal";import { scanSecretPolicyViolations } from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-fns";import { TSecretSnapshotServiceFactory } from "@app/ee/services/secret-snapshot/secret-snapshot-service";import { KeyStorePrefixes, KeyStoreTtls, TKeyStoreFactory } from "@app/keystore/keystore";@@ -145,6 +146,7 @@ type TSecretV2BridgeServiceFactoryDep = {>;reminderService: Pick<TReminderServiceFactory, "createReminder" | "getReminder">;secretValidationRuleService: Pick<TSecretValidationRuleServiceFactory, "validateSecrets">;+ secretRotationV2DAL: Pick<TSecretRotationV2DALFactory, "find">;};export type TSecretV2BridgeServiceFactory = ReturnType<typeof secretV2BridgeServiceFactory>;@@ -173,7 +175,8 @@ export const secretV2BridgeServiceFactory = ({resourceMetadataDAL,keyStore,reminderService,- secretValidationRuleService+ secretValidationRuleService,+ secretRotationV2DAL}: TSecretV2BridgeServiceFactoryDep) => {const $validateSecretReferences = async (projectId: string,@@ -2983,6 +2986,32 @@ export const secretV2BridgeServiceFactory = ({const destinationSecretsGroupedByKey = groupBy(decryptedDestinationSecrets, (i) => i.key);+ const sourceKeys = decryptedSourceSecrets.map((s) => s.key);++ const conflictingRotationSecretKeys = sourceKeys.filter(+ (key) => destinationSecretsGroupedByKey[key]?.[0]?.isRotatedSecret+ );+ if (conflictingRotationSecretKeys.length > 0) {+ throw new BadRequestError({+ message: `Cannot move secrets to '${destinationFolder.path}' because the following keys are managed by a secret rotation at the destination: ${conflictingRotationSecretKeys.join(", ")}`+ });+ }++ const destinationRotations = await secretRotationV2DAL.find(+ { projectId, folderId: destinationFolder.id },+ undefined,+ tx+ );+ const sourceKeySet = new Set(sourceKeys);+ const conflictingRotationNames = destinationRotations+ .filter((rotation) => sourceKeySet.has(rotation.name))+ .map((rotation) => rotation.name);+ if (conflictingRotationNames.length > 0) {+ throw new BadRequestError({+ message: `Cannot move secrets to '${destinationFolder.path}' because the following keys conflict with existing secret rotation names at the destination: ${conflictingRotationNames.join(", ")}`+ });+ }+const locallyCreatedSecrets = decryptedSourceSecrets.filter(({ key }) => !destinationSecretsGroupedByKey[key]?.[0]).map((el) => ({ ...el, operation: SecretOperations.Create }));