Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix: check connection id to define if sync is duplicated or not

Matheus Nogueirae4d0740c105a
diff --git a/backend/src/services/secret-sync/secret-sync-maps.ts b/backend/src/services/secret-sync/secret-sync-maps.ts
index 6330cc1c90..6e11643a48 100644
--- a/backend/src/services/secret-sync/secret-sync-maps.ts
+++ b/backend/src/services/secret-sync/secret-sync-maps.ts
@@ -215,7 +215,13 @@ const defaultDuplicateCheck: DestinationDuplicateCheckFn = () => true;
export const DESTINATION_DUPLICATE_CHECK_MAP: Record<SecretSync, DestinationDuplicateCheckFn> = {
[SecretSync.AWSParameterStore]: defaultDuplicateCheck,
- [SecretSync.AWSSecretsManager]: defaultDuplicateCheck,
+ [SecretSync.AWSSecretsManager]: (_existingConfig, _newConfig, existingConnectionId, newConnectionId) => {
+ // TODO: we should also check the AWS account id here, otherwise
+ // two connections to the same account would cause issues.
+ // If assume role: get account id from ARN
+ // If credentials, use AWS_ACCESS_ID to infer the account id
+ return existingConnectionId === newConnectionId;
+ },
[SecretSync.GitHub]: defaultDuplicateCheck,
[SecretSync.GCPSecretManager]: defaultDuplicateCheck,
[SecretSync.AzureKeyVault]: defaultDuplicateCheck,
diff --git a/backend/src/services/secret-sync/secret-sync-service.ts b/backend/src/services/secret-sync/secret-sync-service.ts
index e312f4ab1e..50a135d067 100644
--- a/backend/src/services/secret-sync/secret-sync-service.ts
+++ b/backend/src/services/secret-sync/secret-sync-service.ts
@@ -255,7 +255,7 @@ export const secretSyncServiceFactory = ({
};
const checkDuplicateDestination = async (
- { destination, destinationConfig, excludeSyncId, projectId }: TCheckDuplicateDestinationDTO,
+ { destination, destinationConfig, connectionId, excludeSyncId, projectId }: TCheckDuplicateDestinationDTO,
actor: OrgServiceActor
) => {
const skipFields = SECRET_SYNC_SKIP_FIELDS_MAP[destination];
@@ -290,7 +290,9 @@ export const secretSyncServiceFactory = ({
if (baseFieldsMatch) {
return DESTINATION_DUPLICATE_CHECK_MAP[destination](
sync.destinationConfig as Record<string, unknown>,
- destinationConfig
+ destinationConfig,
+ sync.connectionId,
+ connectionId ?? null
);
}
return false;
@@ -369,6 +371,7 @@ export const secretSyncServiceFactory = ({
{
destination: params.destination,
destinationConfig: params.destinationConfig,
+ connectionId: params.connectionId,
projectId
},
actor
@@ -503,6 +506,7 @@ export const secretSyncServiceFactory = ({
{
destination,
destinationConfig: params.destinationConfig,
+ connectionId: connectionId ?? secretSync.connectionId,
projectId: secretSync.projectId,
excludeSyncId: secretSync.id
},
diff --git a/backend/src/services/secret-sync/secret-sync-types.ts b/backend/src/services/secret-sync/secret-sync-types.ts
index f915bcafd4..2709ddfa4c 100644
--- a/backend/src/services/secret-sync/secret-sync-types.ts
+++ b/backend/src/services/secret-sync/secret-sync-types.ts
@@ -473,6 +473,7 @@ export type TDeleteSecretSyncDTO = {
export type TCheckDuplicateDestinationDTO = {
destination: SecretSync;
destinationConfig: Record<string, unknown>;
+ connectionId?: string | null;
excludeSyncId?: string;
projectId: string;
};
@@ -571,7 +572,9 @@ export type TSecretMap = Record<
export type DestinationDuplicateCheckFn = (
existingConfig: Record<string, unknown>,
- newConfig: Record<string, unknown>
+ newConfig: Record<string, unknown>,
+ existingConnectionId: string | null,
+ newConnectionId: string | null
) => boolean;
export type TPreSaveTransformDeps = {