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
chore(clickhouse): trim comments
bernie-g1bce7ddf8471
diff --git a/backend/src/ee/services/gateway-v2/gateway-v2-fns.ts b/backend/src/ee/services/gateway-v2/gateway-v2-fns.tsindex 43630ffab1..33ccd35a31 100644--- a/backend/src/ee/services/gateway-v2/gateway-v2-fns.ts+++ b/backend/src/ee/services/gateway-v2/gateway-v2-fns.ts@@ -18,7 +18,6 @@ export const testConnectionWithGateway = async (request: Record<string, unknown>,timeoutMs: number,signal?: AbortSignal,- // Ports beyond the primary one that this test is allowed to probe, signed into the client certificate.additionalTargetPorts?: number[]): Promise<TestConnectionResponse | null> => {const [host] = await verifyHostInputValidity({ host: targetHost, isGateway: true, isDynamicSecret: false });diff --git a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts b/backend/src/ee/services/gateway-v2/gateway-v2-service.tsindex 25f33e78b8..e333c441dc 100644--- a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts+++ b/backend/src/ee/services/gateway-v2/gateway-v2-service.ts@@ -351,8 +351,7 @@ export const gatewayV2ServiceFactory = ({gatewayId,targetHost,targetPort,- // Some account types reach one host on more than one port. Naming them all in the signed cert keeps the- // gateway from having to trust a port out of the request body.+ // Named in the signed cert so the gateway need not trust a port out of the request body.additionalTargetPorts,transport}: {@@ -434,7 +433,7 @@ export const gatewayV2ServiceFactory = ({const routingInfo = {targetHost,targetPort,- // A gateway too old to read this ignores it and keeps using targetPort, so adding it is additive.+ // A gateway too old to read this keeps using targetPort, so adding it is additive....(allowedPorts.length > 1 ? { targetPorts: allowedPorts } : {})};diff --git a/backend/src/ee/services/pam-account/pam-account-connection-test.test.ts b/backend/src/ee/services/pam-account/pam-account-connection-test.test.tsindex bb30811e72..d35721dc14 100644--- a/backend/src/ee/services/pam-account/pam-account-connection-test.test.ts+++ b/backend/src/ee/services/pam-account/pam-account-connection-test.test.ts@@ -9,8 +9,7 @@ import {const ORG_ID = "11111111-1111-1111-1111-111111111111";-// The keys that survive serialization, which is what the gateway actually decodes. An `undefined` property-// is still a present key in JS, so checking the object directly would not prove the field was omitted.+// An `undefined` property is still a present key in JS, so only the wire form proves a field was omitted.const wireKeys = (request: unknown): string[] => Object.keys(JSON.parse(JSON.stringify(request)) as object);describe("buildGatewayConnectionTest: MSSQL Windows authentication", () => {@@ -292,7 +291,6 @@ describe("buildGatewayConnectionTest: ClickHouse", () => {expect(result?.request.mode).toBe(TestConnectionMode.ClickHouse);expect(result?.port).toBe(9440);expect(result?.request).toMatchObject({ nativePort: 9440, sslEnabled: true });- // toMatchObject treats an absent key as undefined, so the wire form is what gets asserted.expect(wireKeys(result!.request)).not.toContain("httpPort");});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.tsindex 0f115fbcfb..0856a5d43a 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@@ -109,7 +109,6 @@ export type TestConnectionRequest =username: string;password?: string;database: string;- // Either interface can be absent, so each is named rather than inferred from the gateway target.httpPort?: number;nativePort?: number;sslEnabled?: boolean;@@ -147,7 +146,6 @@ export const buildGatewayConnectionTest = async (host: string;port: number;request: TestConnectionRequest;- // Ports the gateway may probe beyond the primary one, so they can be signed into its certificate.additionalPorts?: number[];} | null> => {const creds = credentials && isCredentialConfigured(accountType, credentials) ? credentials : null;diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.test.ts b/backend/src/ee/services/pam-account/pam-account-schemas.test.tsindex 99f9afa02f..b7413a9160 100644--- a/backend/src/ee/services/pam-account/pam-account-schemas.test.ts+++ b/backend/src/ee/services/pam-account/pam-account-schemas.test.ts@@ -197,17 +197,13 @@ describe("buildPamAccountTypeMetadata", () => {required: false,defaultValue: 8123});- // The native port must NOT carry a default: the edit form spreads defaults under the stored details,- // so a default would add a native port to every existing HTTP-only account on the next save.+ // A default would add a native port to every existing HTTP-only account on its next save.expect(fieldByKey(clickhouse!.connectionFields, "nativePort")?.defaultValue).toBeUndefined();- // A native port is offered by default so clickhouse-client works without anyone choosing a protocol,- // and stays optional for a server that only serves HTTP.expect(fieldByKey(clickhouse!.connectionFields, "nativePort")).toMatchObject({label: "Native Port",widget: "number",required: false});- // Both ports are plain always-visible fields: neither is hidden behind a condition on the other.expect(fieldByKey(clickhouse!.connectionFields, "port")?.showWhen).toBeUndefined();expect(fieldByKey(clickhouse!.connectionFields, "nativePort")?.showWhen).toBeUndefined();expect(fieldByKey(clickhouse!.connectionFields, "database")).toMatchObject({@@ -236,12 +232,10 @@ describe("buildPamAccountTypeMetadata", () => {sslRejectUnauthorized: true};- // HTTP disabled on the server: clickhouse-client works, and Web Access is bridged by the gateway.expect(validateConnectionDetails(PamAccountType.ClickHouse, { ...base, nativePort: 9000 })).toMatchObject({nativePort: 9000});- // Native disabled: JDBC and Web Access work, native drivers are turned away.expect(validateConnectionDetails(PamAccountType.ClickHouse, { ...base, port: 8123 })).toMatchObject({port: 8123});@@ -276,10 +270,8 @@ describe("buildPamAccountTypeMetadata", () => {expect(requiresClickHouseNative(PamAccountType.ClickHouse, withNative)).toBe(true);expect(requiresClickHouseNative(PamAccountType.ClickHouse, httpOnly)).toBe(false);- // Only ClickHouse has two interfaces; no other type should be gated on this.expect(requiresClickHouseNative(PamAccountType.Postgres, withNative)).toBe(false);- // An absent flag means a gateway too old to report it, which is exactly what must be refused.expect(gatewaySupportsClickHouseNative(null)).toBe(false);expect(gatewaySupportsClickHouseNative({})).toBe(false);expect(gatewaySupportsClickHouseNative({ clickhouseNativeProtocol: false })).toBe(false);diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.ts b/backend/src/ee/services/pam-account/pam-account-schemas.tsindex e7b9a649d0..d5d456ebcf 100644--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts@@ -47,8 +47,7 @@ const boundedOptionalString = (max: number) =>.transform((v) => v || undefined).optional();-// Clearing a number input submits an empty string rather than undefined, which a bare .optional() rejects-// and coercion would read as port 0.+// Clearing a number input submits "" rather than undefined, which coercion would read as port 0.const optionalPort = () =>z.preprocess((v) => (v === null || (typeof v === "string" && v.trim() === "") ? undefined : v),@@ -614,7 +613,6 @@ export const ACCOUNT_TYPE_CONFIGS = {sslRejectUnauthorized: z.boolean(),sslCertificate: boundedOptionalString(16384)})- // Either interface can be turned off on the server, but a session needs at least one of them..refine((v) => v.port !== undefined || v.nativePort !== undefined, {message: "Set the HTTP port, the native port, or both",path: ["port"]@@ -633,8 +631,8 @@ export const ACCOUNT_TYPE_CONFIGS = {},nativePort: {label: "Native Port",- // Deliberately no default: the edit form seeds defaults over stored details, so an existing- // HTTP-only account would silently gain a native port the next time anyone edited it.+ // No default: the edit form seeds defaults over stored details, so every existing HTTP-only+ // account would silently gain a native port on its next save.tooltip:"The native TCP port, usually 9000 for plain TCP or 9440 with SSL. clickhouse-client and other native drivers need it. Leave it empty if the server only serves HTTP."},@@ -1082,7 +1080,6 @@ export const extractGatewayTarget = async (port: (validated as { host: string; port: number }).port};case PamAccountType.ClickHouse: {- // Either interface can be absent, so the target is whichever one the account actually has.const { host, port, nativePort } = validated as { host: string; port?: number; nativePort?: number };return { host, port: port ?? nativePort };}@@ -1167,13 +1164,10 @@ export const gatewaySupportsAccountType = (supportedTypes: string[] | undefined): boolean => !supportedTypes || supportedTypes.includes(resolveGatewayAccountType(accountType));-// A gateway can support ClickHouse accounts and still predate the native protocol, so the account type on-// its own does not say whether a native port can be served. An absent flag means a gateway too old to-// report it, which is exactly the case this guards.+// An absent flag means a gateway too old to report it, which is exactly the case this guards.export const gatewaySupportsClickHouseNative = (capabilities: { clickhouseNativeProtocol?: boolean } | null) =>Boolean(capabilities?.clickhouseNativeProtocol);-// The connection details name a native port the gateway would have to speak.export const requiresClickHouseNative = (accountType: PamAccountType,connectionDetails: Record<string, unknown>diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.tsindex 4cb823c2e2..80f7791fe4 100644--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@ -640,8 +640,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>});}- // Saving a native port against a gateway that cannot speak it would pass this test over HTTP and then- // fail every native client at session time, with nothing to point at.+ // Otherwise this passes over HTTP and every native client fails at session time, with nothing to point at.if (requiresClickHouseNative(accountType, connectionDetails) && !gatewaySupportsClickHouseNative(capabilities)) {throw new BadRequestError({message: `Gateway '${attachedGateway?.name ?? gatewayId}' does not support ClickHouse's native protocol. Update the gateway, or clear the native port to use this account over HTTP only.`@@ -992,8 +991,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>nativePort?: number;};const newConn = effectiveConnectionDetails as { host?: string; port?: number; nativePort?: number };- // nativePort is part of the target too: re-pointing it sends the stored credential somewhere new on- // the next heartbeat, which is exactly what this flag exists to catch.+ // Re-pointing nativePort sends the stored credential somewhere new on the next heartbeat.if (oldConn.host !== newConn.host || oldConn.port !== newConn.port || oldConn.nativePort !== newConn.nativePort)connectionTargetChanged = true;