Skip to content

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

address review

x039e55c4eed3
diff --git a/backend/src/ee/services/pam-account/pam-account-connection-test.ts b/backend/src/ee/services/pam-account/pam-account-connection-test.ts
index 067367070f..dcc2368af5 100644
--- a/backend/src/ee/services/pam-account/pam-account-connection-test.ts
+++ b/backend/src/ee/services/pam-account/pam-account-connection-test.ts
@@ -1,5 +1,4 @@
import { PamAccountType, PamSshAuthMethod } from "../pam/pam-enums";
-import { isCredentialConfigured } from "./pam-account-schemas";
export enum TestConnectionMode {
Postgres = "postgres",
@@ -36,7 +35,6 @@ type ConnectionTestBuilder = (
// single source of truth for which account types support a connection test and how each is tested
export const PAM_CONNECTION_TEST_BUILDERS: Partial<Record<PamAccountType, ConnectionTestBuilder>> = {
[PamAccountType.Postgres]: (connectionDetails, credentials) => {
- if (!isCredentialConfigured(PamAccountType.Postgres, credentials)) return { mode: TestConnectionMode.Tcp };
const cd = connectionDetails as {
database: string;
sslEnabled?: boolean;
@@ -56,11 +54,7 @@ export const PAM_CONNECTION_TEST_BUILDERS: Partial<Record<PamAccountType, Connec
},
[PamAccountType.SSH]: (_connectionDetails, credentials) => {
const creds = credentials as { authMethod: string; username: string; password?: string; privateKey?: string };
-
- if (creds.authMethod === PamSshAuthMethod.Certificate || !isCredentialConfigured(PamAccountType.SSH, credentials)) {
- return { mode: TestConnectionMode.Tcp };
- }
-
+ if (creds.authMethod === PamSshAuthMethod.Certificate) return { mode: TestConnectionMode.Tcp };
return {
mode: TestConnectionMode.SSH,
authMethod: creds.authMethod,
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.ts
index 8ce851957e..1447cb156f 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -43,7 +43,7 @@ import { TPamAccessRequestServiceFactory } from "../pam-access-request/pam-acces
import { TPamAccountTemplateDALFactory } from "../pam-account-template/pam-account-template-dal";
import { PamTemplateSettingsSchema } from "../pam-account-template/pam-account-template-schemas";
import { TPamFolderDALFactory } from "../pam-folder/pam-folder-dal";
-import { PAM_CONNECTION_TEST_BUILDERS } from "./pam-account-connection-test";
+import { PAM_CONNECTION_TEST_BUILDERS, TestConnectionMode } from "./pam-account-connection-test";
import { TPamAccountDALFactory } from "./pam-account-dal";
import {
getAccountAccessibilityIssues,
@@ -288,7 +288,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
const assertConnectionOk = async (
accountType: PamAccountType,
connectionDetails: Record<string, unknown>,
- credentials: Record<string, unknown>,
+ credentials: Record<string, unknown> | null,
gateway: {
gatewayId?: string | null;
gatewayPoolId?: string | null;
@@ -315,7 +315,10 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
if (!capabilities?.connectionTest) return;
const cd = connectionDetails as { host: string; port: number };
- const request = buildRequest(connectionDetails, credentials);
+ const request =
+ credentials === null || !isCredentialConfigured(accountType, credentials)
+ ? { mode: TestConnectionMode.Tcp }
+ : buildRequest(connectionDetails, credentials);
try {
await testConnectionWithGateway(
@@ -635,7 +638,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
: validateConnectionDetails(accountType, await decrypt(projectId, existing.encryptedConnectionDetails));
// only test with credentials supplied in this request to prevent exfiltration
- const testCredentials = credentials ? validateCredentials(accountType, credentials) : {};
+ const testCredentials = credentials ? validateCredentials(accountType, credentials) : null;
await assertConnectionOk(accountType, effectiveConnectionDetails, testCredentials, {
gatewayId: gatewayId !== undefined ? gatewayId : existing.gatewayId,
gatewayPoolId: gatewayPoolId !== undefined ? gatewayPoolId : existing.gatewayPoolId,