Skip to content

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

Address greptile comments

Carlos Monastyrskie91795e6c4fd
diff --git a/backend/src/lib/gateway-v2/ssh-rpc.ts b/backend/src/lib/gateway-v2/ssh-rpc.ts
index c1f1129814..40253b720a 100644
--- a/backend/src/lib/gateway-v2/ssh-rpc.ts
+++ b/backend/src/lib/gateway-v2/ssh-rpc.ts
@@ -11,6 +11,7 @@ export type SshExecCredentials = {
username: string;
password?: string;
privateKey?: string;
+ passphrase?: string;
certificate?: string;
};
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 7b18f3a79e..e23b544dcf 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -3660,7 +3660,6 @@ export const registerRoutes = async (
certificateDAL,
certificateSyncDAL,
pkiSubscriberDAL,
- appConnectionDAL,
appConnectionService,
permissionService,
licenseService,
diff --git a/backend/src/services/app-connection/ssh/ssh-connection-fns.ts b/backend/src/services/app-connection/ssh/ssh-connection-fns.ts
index b7b53cd21f..800d551b6c 100644
--- a/backend/src/services/app-connection/ssh/ssh-connection-fns.ts
+++ b/backend/src/services/app-connection/ssh/ssh-connection-fns.ts
@@ -254,7 +254,8 @@ const toSshExecCredentials = (config: TSshConnectionConfig): SshExecCredentials
return {
authMethod: SshExecAuthMethod.PublicKey,
username: config.credentials.username,
- privateKey: config.credentials.privateKey
+ privateKey: config.credentials.privateKey,
+ passphrase: config.credentials.passphrase
};
default:
throw new InternalServerError({
diff --git a/backend/src/services/pki-sync/pki-sync-service.ts b/backend/src/services/pki-sync/pki-sync-service.ts
index 9fb9ec387f..17fcc39853 100644
--- a/backend/src/services/pki-sync/pki-sync-service.ts
+++ b/backend/src/services/pki-sync/pki-sync-service.ts
@@ -11,7 +11,6 @@ import {
import { getProcessedPermissionRules } from "@app/lib/casl/permission-filter-utils";
import { BadRequestError, DatabaseError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
import { OrgServiceActor } from "@app/lib/types";
-import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
import { TAppConnectionServiceFactory } from "@app/services/app-connection/app-connection-service";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
@@ -86,7 +85,6 @@ type TPkiSyncServiceFactoryDep = {
| "clearSyncMetadataFlag"
>;
pkiSubscriberDAL: Pick<TPkiSubscriberDALFactory, "findById">;
- appConnectionDAL: Pick<TAppConnectionDALFactory, "findById">;
appConnectionService: Pick<TAppConnectionServiceFactory, "connectAppConnectionById">;
permissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getResourcePermission">;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
@@ -104,7 +102,6 @@ export const pkiSyncServiceFactory = ({
certificateDAL,
certificateSyncDAL,
pkiSubscriberDAL,
- appConnectionDAL,
appConnectionService,
permissionService,
licenseService,
@@ -485,7 +482,12 @@ export const pkiSyncServiceFactory = ({
$assertPostSyncCommandIsSupported(
pkiSync.destination,
effectiveSyncOptions,
- effectiveConnection ?? (await appConnectionDAL.findById(pkiSync.connectionId))
+ effectiveConnection ??
+ (await appConnectionService.connectAppConnectionById(
+ getDestinationAppType(pkiSync.destination),
+ pkiSync.connectionId,
+ actor
+ ))
);
}
@@ -830,16 +832,20 @@ export const pkiSyncServiceFactory = ({
await validateCertificatesForSync(certificateIds, pkiSync.projectId, pkiSync.applicationId);
- const existingCount = (await certificateSyncDAL.findByPkiSyncId(pkiSyncId)).length;
assertSyncOptionsAllowCertificateCount(
pkiSync.syncOptions as Record<string, unknown> | undefined,
- existingCount + certificateIds.length
+ prospectiveCount
);
- const addedCertificates = await certificateSyncDAL.addCertificates(
- pkiSyncId,
- certificateIds.map((id) => ({ certificateId: id }))
- );
+ const alreadyLinked = new Set(existingCertificateIds);
+ const certificateIdsToAdd = certificateIds.filter((id) => !alreadyLinked.has(id));
+
+ const addedCertificates = certificateIdsToAdd.length
+ ? await certificateSyncDAL.addCertificates(
+ pkiSyncId,
+ certificateIdsToAdd.map((id) => ({ certificateId: id }))
+ )
+ : [];
if (pkiSync.isAutoSyncEnabled) {
await pkiSyncQueue.queuePkiSyncSyncCertificatesById({ syncId: pkiSyncId });
diff --git a/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx b/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx
index 90785f990d..17509e5ea2 100644
--- a/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx
+++ b/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx
@@ -186,7 +186,7 @@ export const CreatePkiSyncForm = ({
canRemoveCertificates: false,
preserveArn: true,
certificateNameSchema: syncOption?.defaultCertificateNameSchema,
- ...(syncOption?.canRunPostSyncCommand && {
+ ...((destination === PkiSync.LinuxServer || destination === PkiSync.WindowsServer) && {
exportFormat:
destination === PkiSync.WindowsServer
? PkiSyncExportFormat.Pkcs12