Skip to content

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

fix(pki-discovery): address review feedback

bernie-g9a9f2a48637d
diff --git a/backend/src/ee/services/pki-discovery/CLAUDE.md b/backend/src/ee/services/pki-discovery/CLAUDE.md
index 3681ffd27c..93e61e2bd8 100644
--- a/backend/src/ee/services/pki-discovery/CLAUDE.md
+++ b/backend/src/ee/services/pki-discovery/CLAUDE.md
@@ -13,8 +13,9 @@ Invariants for `pki-discovery-*` and `pki-installation-*` that the code doesn't
WinRM ALPN, capability `windowsCertificateScan`. The gateway always reads `CA` and `Root` to build chains, but
only returns certificates from the requested stores. Installations are `os_store`, keyed on
`Cert:\LocalMachine\<store>\<thumbprint>` instead of a file path, and never take a password.
-- Both host types share `executeHostScan` in `pki-discovery-host-scan-fns.ts`; a new host type supplies a
- `THostScanDefinition` and an entry in the service's `HOST_DISCOVERY_TYPES`.
+- Both host types share `executeHostScan`, `resolveHostConnection` and `runGatewayScan` in
+ `pki-discovery-host-scan-fns.ts`; a new host type supplies one `THostScanDefinition` (label, app, capability,
+ schema, per-connection scan) and adds it to the service's `HOST_DISCOVERY_TYPES` and the queue.
- Host scans take a per-connection slot (`tryAdmitAppConnectionConcurrency`), shared with PKI syncs.
- Nothing raw reaches users: gateway, transport and file errors map to product messages; raw text is logged.
- Installation identity is `hostIdentifier` (connection host, plus `:port` unless it is the protocol default: 22 for SSH, 5985 or 5986 for WinRM over HTTP or HTTPS) + real path + gateway or
diff --git a/backend/src/ee/services/pki-discovery/pki-discovery-host-fns.ts b/backend/src/ee/services/pki-discovery/pki-discovery-host-fns.ts
index 95dd33f213..2750d6151e 100644
--- a/backend/src/ee/services/pki-discovery/pki-discovery-host-fns.ts
+++ b/backend/src/ee/services/pki-discovery/pki-discovery-host-fns.ts
@@ -2,6 +2,8 @@ import net from "net";
import { z } from "zod";
import { CertificateScanRpcStatus, TCertificateScanRpcFailure } from "@app/lib/gateway-v2/certificate-scan-rpc";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+import { APP_CONNECTION_NAME_MAP } from "@app/services/app-connection/app-connection-maps";
import { DB_SHORT_VARCHAR_LIMIT, truncateString } from "./pki-discovery-scan-run-fns";
import {
@@ -108,11 +110,11 @@ export const planHostFileImport = (
}
};
-export const sshConnectionWithoutGatewayMessage = (connectionName: string) =>
- `SSH connection '${connectionName}' does not use a gateway. Linux Server discovery runs on the gateway, so assign one to the connection.`;
-
-export const windowsConnectionWithoutGatewayMessage = (connectionName: string) =>
- `Windows (WinRM) connection '${connectionName}' does not use a gateway. Windows Server discovery runs on the gateway, so assign one to the connection.`;
+export const hostConnectionWithoutGatewayMessage = (
+ type: { label: string; app: AppConnection },
+ connectionName: string
+) =>
+ `${APP_CONNECTION_NAME_MAP[type.app]} connection '${connectionName}' does not use a gateway. ${type.label} discovery runs on the gateway, so assign one to the connection.`;
export const buildHostInstallationName = (hostIdentifier: string, hostname: string | undefined, filePath: string) =>
truncateString(`${hostname?.trim() || hostIdentifier}:${filePath}`, DB_SHORT_VARCHAR_LIMIT);
@@ -143,7 +145,8 @@ const TRUNCATION_MESSAGES: Record<string, string | undefined> = {
[HostScanTruncationReason.FileList]: "found too many files to list, so some files were not checked",
[HostScanTruncationReason.ResponseSize]:
"found more certificate data than one scan can return, so some files were not checked",
- [HostScanTruncationReason.TimeLimit]: "ran out of time, so some files were not checked"
+ [HostScanTruncationReason.TimeLimit]: "ran out of time, so some files were not checked",
+ [HostScanTruncationReason.Incomplete]: "could not list every folder, so some files were not checked"
};
export const summarizeHostScanIssues = (hostIdentifier: string, response: TCertificateScanResponse): string[] => {
diff --git a/backend/src/ee/services/pki-discovery/pki-discovery-host-scan-fns.ts b/backend/src/ee/services/pki-discovery/pki-discovery-host-scan-fns.ts
index f680bd5a45..88adc73766 100644
--- a/backend/src/ee/services/pki-discovery/pki-discovery-host-scan-fns.ts
+++ b/backend/src/ee/services/pki-discovery/pki-discovery-host-scan-fns.ts
@@ -2,6 +2,7 @@ import * as x509 from "@peculiar/x509";
import { Knex } from "knex";
import net from "net";
import pLimit from "p-limit";
+import { z } from "zod";
import { verifyHostInputValidity } from "@app/ee/services/dynamic-secret/dynamic-secret-fns";
import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";
@@ -15,6 +16,7 @@ import { hasPostgresErrorCode } from "@app/lib/errors/postgres";
import { callCertificateScan, TCertificateScanRequest } from "@app/lib/gateway-v2/certificate-scan-rpc";
import { getMissingGatewayMessage } from "@app/lib/gateway-v2/gateway-errors";
import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";
+import { GatewayFailureKind } from "@app/lib/gateway-v2/test-connection-rpc";
import { GatewayProxyProtocol } from "@app/lib/gateway-v2/types";
import { logger } from "@app/lib/logger";
import {
@@ -22,7 +24,9 @@ import {
tryAdmitAppConnectionConcurrency
} from "@app/services/app-connection/app-connection-concurrency-fns";
import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
import { decryptAppConnectionCredentials } from "@app/services/app-connection/app-connection-fns";
+import { APP_CONNECTION_NAME_MAP } from "@app/services/app-connection/app-connection-maps";
import { toSshExecCredentials } from "@app/services/app-connection/ssh/ssh-connection-fns";
import { TSshConnectionConfig } from "@app/services/app-connection/ssh/ssh-connection-types";
import { TCertificateBodyDALFactory } from "@app/services/certificate/certificate-body-dal";
@@ -41,9 +45,9 @@ import {
buildHostInstallationName,
CertificateScanResponseSchema,
describeCertificateScanFailure,
+ hostConnectionWithoutGatewayMessage,
normalizeHostIdentifier,
planHostFileImport,
- sshConnectionWithoutGatewayMessage,
summarizeHostScanIssues,
TCertificateScanFile,
TCertificateScanResponse
@@ -58,6 +62,7 @@ import {
sendScanCompletedTelemetry,
startScanRun
} from "./pki-discovery-scan-run-fns";
+import { LinuxServerTargetConfigSchema } from "./pki-discovery-schemas";
import {
HostFileImportAction,
PkiDiscoveryScanStatus,
@@ -136,16 +141,24 @@ export type TAppConnectionRow = Awaited<ReturnType<THostScanDeps["appConnectionD
export type TScanGateway = { gatewayId: string; gatewayName: string; fingerprintGatewayKey: string };
-export const selectScanGateway = async (
+export type THostScanType = {
+ discoveryType: PkiDiscoveryType;
+ label: string;
+ app: AppConnection;
+ capability: HostScanCapability;
+};
+
+const connectionKindOf = (app: AppConnection) => APP_CONNECTION_NAME_MAP[app];
+
+const selectScanGateway = async (
connection: NonNullable<TAppConnectionRow>,
- capability: HostScanCapability,
- connectionKind: string,
+ type: THostScanType,
deps: THostScanDeps
): Promise<TScanGateway> => {
if (connection.gatewayPoolId) {
const selected = await deps.gatewayPoolService.selectGatewayFromPool({
poolId: connection.gatewayPoolId,
- filter: (gateway) => hasCapability(gateway.capabilities, capability),
+ filter: (gateway) => hasCapability(gateway.capabilities, type.capability),
unavailableMessage:
"No healthy gateway in the connection's pool supports certificate scanning. Update the pool's gateways to the latest version."
});
@@ -154,10 +167,10 @@ export const selectScanGateway = async (
const gateway = await deps.gatewayV2DAL.findById(connection.gatewayId as string);
if (!gateway) {
throw new BadRequestError({
- message: `The gateway of ${connectionKind} connection '${connection.name}' no longer exists`
+ message: `The gateway of ${connectionKindOf(type.app)} connection '${connection.name}' no longer exists`
});
}
- if (!hasCapability(gateway.capabilities, capability)) {
+ if (!hasCapability(gateway.capabilities, type.capability)) {
throw new BadRequestError({
message: `Gateway '${gateway.name}' is too old for certificate scanning. Update it to the latest version.`
});
@@ -165,12 +178,17 @@ export const selectScanGateway = async (
return { gatewayId: gateway.id, gatewayName: gateway.name, fingerprintGatewayKey: gateway.id };
};
-export const resolveHost = async (connection: TAppConnectionRow | undefined, orgId: string, deps: THostScanDeps) => {
- if (!connection || connection.orgId !== orgId) {
- throw new BadRequestError({ message: "The SSH connection no longer exists" });
+export const resolveHostConnection = async <TCredentials extends { host: string }>(
+ connection: TAppConnectionRow | undefined,
+ orgId: string,
+ type: THostScanType,
+ deps: THostScanDeps
+) => {
+ if (!connection || connection.orgId !== orgId || connection.app !== type.app) {
+ throw new BadRequestError({ message: `The ${connectionKindOf(type.app)} connection no longer exists` });
}
if (!connection.gatewayId && !connection.gatewayPoolId) {
- throw new BadRequestError({ message: sshConnectionWithoutGatewayMessage(connection.name) });
+ throw new BadRequestError({ message: hostConnectionWithoutGatewayMessage(type, connection.name) });
}
const credentials = (await decryptAppConnectionCredentials({
@@ -178,23 +196,9 @@ export const resolveHost = async (connection: TAppConnectionRow | undefined, org
encryptedCredentials: connection.encryptedCredentials,
kmsService: deps.kmsService,
projectId: connection.projectId
- })) as TSshConnectionConfig["credentials"];
+ })) as unknown as TCredentials;
- const config = {
- method: connection.method,
- app: connection.app,
- credentials,
- gatewayId: connection.gatewayId,
- gatewayPoolId: connection.gatewayPoolId,
- orgId: connection.orgId
- } as TSshConnectionConfig;
-
- const { gatewayId, gatewayName, fingerprintGatewayKey } = await selectScanGateway(
- connection,
- HostScanCapability.CertificateScan,
- "SSH",
- deps
- );
+ const gateway = await selectScanGateway(connection, type, deps);
const [targetHost] = await verifyHostInputValidity({
host: credentials.host,
@@ -202,15 +206,41 @@ export const resolveHost = async (connection: TAppConnectionRow | undefined, org
isDynamicSecret: false
});
+ return { connection, credentials, gateway, targetHost };
+};
+
+const LINUX_SERVER_SCAN_TYPE: THostScanType = {
+ discoveryType: PkiDiscoveryType.LinuxServer,
+ label: "Linux Server",
+ app: AppConnection.SSH,
+ capability: HostScanCapability.CertificateScan
+};
+
+export const resolveHost = async (connection: TAppConnectionRow | undefined, orgId: string, deps: THostScanDeps) => {
+ const resolved = await resolveHostConnection<TSshConnectionConfig["credentials"]>(
+ connection,
+ orgId,
+ LINUX_SERVER_SCAN_TYPE,
+ deps
+ );
+ const { credentials } = resolved;
+
+ const config = {
+ method: resolved.connection.method,
+ app: resolved.connection.app,
+ credentials,
+ gatewayId: resolved.connection.gatewayId,
+ gatewayPoolId: resolved.connection.gatewayPoolId,
+ orgId: resolved.connection.orgId
+ } as TSshConnectionConfig;
+
return {
- connectionId: connection.id,
+ ...resolved.gateway,
+ connectionId: resolved.connection.id,
hostIdentifier: normalizeHostIdentifier(credentials.host, credentials.port),
hostAddress: credentials.host.trim().toLowerCase(),
- targetHost,
+ targetHost: resolved.targetHost,
targetPort: credentials.port,
- gatewayId,
- gatewayName,
- fingerprintGatewayKey,
credentials: toSshExecCredentials(config)
} satisfies TResolvedHost;
};
@@ -256,11 +286,27 @@ const admitConnectionScanSlot = async (connectionId: string, deps: THostScanDeps
return false;
};
-const runCertificateScan = async (
- host: TResolvedHost,
- request: TCertificateScanRequest,
+type TGatewayScanTarget = TScanGateway & { connectionId: string; targetHost: string; targetPort: number };
+
+type TGatewayScanFailure = { ok: false; status: number; kind?: GatewayFailureKind | null };
+
+export const runGatewayScan = async <TFailure extends TGatewayScanFailure, TResult>(
+ host: TGatewayScanTarget,
+ {
+ protocol,
+ call,
+ describeFailure,
+ schema,
+ logLabel
+ }: {
+ protocol: GatewayProxyProtocol;
+ call: (port: number) => Promise<{ ok: true; result: unknown } | TFailure>;
+ describeFailure: (failure: TFailure) => string;
+ schema: z.ZodType<TResult, z.ZodTypeDef, unknown>;
+ logLabel: string;
+ },
deps: THostScanDeps
-): Promise<TCertificateScanResponse> => {
+): Promise<TResult> => {
const connectionDetails = await deps.gatewayV2Service.getPlatformConnectionDetailsByGatewayId({
gatewayId: host.gatewayId,
targetHost: host.targetHost,
@@ -270,16 +316,13 @@ const runCertificateScan = async (
throw new NotFoundError({ message: getMissingGatewayMessage(host.gatewayId) });
}
- let response: Awaited<ReturnType<typeof callCertificateScan>>;
+ let response: { ok: true; result: unknown } | TFailure;
try {
- response = await withGatewayV2Proxy(
- (proxyPort) => callCertificateScan({ port: proxyPort, credentials: host.credentials, request }),
- { protocol: GatewayProxyProtocol.Discovery, longLived: true, ...connectionDetails }
- );
+ response = await withGatewayV2Proxy(call, { protocol, longLived: true, ...connectionDetails });
} catch (error) {
if (error instanceof GatewayTransportError) throw error;
logger.warn(
- `Certificate scan transport failed [connectionId=${host.connectionId}] [gatewayId=${host.gatewayId}] [error=${error instanceof Error ? error.message : String(error)}]`
+ `${logLabel} transport failed [connectionId=${host.connectionId}] [gatewayId=${host.gatewayId}] [error=${error instanceof Error ? error.message : String(error)}]`
);
throw new BadRequestError({
message:
@@ -289,32 +332,48 @@ const runCertificateScan = async (
if (!response.ok) {
logger.warn(
- `Certificate scan RPC failed [connectionId=${host.connectionId}] [gatewayId=${host.gatewayId}] [status=${response.status}] [kind=${response.kind ?? "none"}] [detail=${response.detail}]`
+ { failure: response },
+ `${logLabel} RPC failed [connectionId=${host.connectionId}] [gatewayId=${host.gatewayId}] [status=${response.status}] [kind=${response.kind ?? "none"}]`
);
- throw new BadRequestError({
- message: describeCertificateScanFailure(response, host.gatewayName)
- });
+ throw new BadRequestError({ message: describeFailure(response) });
}
- const parsed = CertificateScanResponseSchema.safeParse(response.result);
+ const parsed = schema.safeParse(response.result);
if (!parsed.success) {
logger.warn(
{ issues: parsed.error.issues },
- `Certificate scan result did not match the expected shape [connectionId=${host.connectionId}] [gatewayId=${host.gatewayId}]`
+ `${logLabel} result did not match the expected shape [connectionId=${host.connectionId}] [gatewayId=${host.gatewayId}]`
);
throw new BadRequestError({ message: "The gateway returned a scan result that could not be read" });
}
return parsed.data;
};
+const runCertificateScan = (
+ host: TResolvedHost,
+ request: TCertificateScanRequest,
+ deps: THostScanDeps
+): Promise<TCertificateScanResponse> =>
+ runGatewayScan(
+ host,
+ {
+ protocol: GatewayProxyProtocol.Discovery,
+ call: (port) => callCertificateScan({ port, credentials: host.credentials, request }),
+ describeFailure: (failure) => describeCertificateScanFailure(failure, host.gatewayName),
+ schema: CertificateScanResponseSchema,
+ logLabel: "Certificate scan"
+ },
+ deps
+ );
+
export const withConnectionScanSlot = async <T>(
connectionId: string,
- connectionKind: string,
+ app: AppConnection,
deps: THostScanDeps,
fn: () => Promise<T>
): Promise<T> => {
if (!(await admitConnectionScanSlot(connectionId, deps))) {
throw new BadRequestError({
- message: `The ${connectionKind} connection is busy with other jobs. Try again later.`
+ message: `The ${connectionKindOf(app)} connection is busy with other jobs. Try again later.`
});
}
try {
@@ -331,7 +390,7 @@ export const scanHost = (
request: TCertificateScanRequest,
deps: THostScanDeps
): Promise<TCertificateScanResponse> =>
- withConnectionScanSlot(host.connectionId, "SSH", deps, () => runCertificateScan(host, request, deps));
+ withConnectionScanSlot(host.connectionId, AppConnection.SSH, deps, () => runCertificateScan(host, request, deps));
export type TWriteContext = {
projectId: string;
@@ -567,9 +626,8 @@ export type THostScanOutcome = { issues: string[]; failure?: { label: string; me
type THostScanTargetConfig = { connectionIds: string[]; importStandaloneCaCertificates: boolean };
-export type THostScanDefinition<TConfig extends THostScanTargetConfig> = {
- discoveryType: PkiDiscoveryType;
- label: string;
+export type THostScanDefinition<TConfig extends THostScanTargetConfig = THostScanTargetConfig> = THostScanType & {
+ schema: z.ZodTypeAny;
scanConnection: (
connection: TAppConnectionRow | undefined,
label: string,
@@ -737,9 +795,8 @@ export const executeHostScan = async <TConfig extends THostScanTargetConfig>(
}
};
-export const executeLinuxServerScan = (discoveryId: string, deps: THostScanDeps): Promise<void> =>
- executeHostScan<TLinuxServerTargetConfig>(
- discoveryId,
- { discoveryType: PkiDiscoveryType.LinuxServer, label: "Linux Server", scanConnection: scanLinuxConnection },
- deps
- );
+export const LINUX_SERVER_SCAN: THostScanDefinition<TLinuxServerTargetConfig> = {
+ ...LINUX_SERVER_SCAN_TYPE,
+ schema: LinuxServerTargetConfigSchema,
+ scanConnection: scanLinuxConnection
+};
diff --git a/backend/src/ee/services/pki-discovery/pki-discovery-queue.ts b/backend/src/ee/services/pki-discovery/pki-discovery-queue.ts
index 7545ae6533..1b7c16c9be 100644
--- a/backend/src/ee/services/pki-discovery/pki-discovery-queue.ts
+++ b/backend/src/ee/services/pki-discovery/pki-discovery-queue.ts
@@ -15,13 +15,13 @@ import { TTelemetryServiceFactory } from "@app/services/telemetry/telemetry-serv
import { TPkiCertificateInstallationCertDALFactory } from "./pki-certificate-installation-cert-dal";
import { TPkiCertificateInstallationDALFactory } from "./pki-certificate-installation-dal";
import { TPkiDiscoveryConfigDALFactory } from "./pki-discovery-config-dal";
-import { executeLinuxServerScan } from "./pki-discovery-host-scan-fns";
+import { executeHostScan, LINUX_SERVER_SCAN } from "./pki-discovery-host-scan-fns";
import { TPkiDiscoveryInstallationDALFactory } from "./pki-discovery-installation-dal";
import { rescanInstallation } from "./pki-discovery-rescan-fns";
import { executeScan } from "./pki-discovery-scan-fns";
import { TPkiDiscoveryScanHistoryDALFactory } from "./pki-discovery-scan-history-dal";
import { PkiDiscoveryType } from "./pki-discovery-types";
-import { executeWindowsServerScan } from "./pki-discovery-windows-scan-fns";
+import { WINDOWS_SERVER_SCAN } from "./pki-discovery-windows-scan-fns";
type TPkiDiscoveryQueueFactoryDep = {
pkiDiscoveryConfigDAL: TPkiDiscoveryConfigDALFactory;
@@ -106,10 +106,10 @@ export const pkiDiscoveryQueueFactory = ({
await executeScan(discoveryId, scanDeps);
break;
case PkiDiscoveryType.LinuxServer:
- await executeLinuxServerScan(discoveryId, scanDeps);
+ await executeHostScan(discoveryId, LINUX_SERVER_SCAN, scanDeps);
break;
case PkiDiscoveryType.WindowsServer:
- await executeWindowsServerScan(discoveryId, scanDeps);
+ await executeHostScan(discoveryId, WINDOWS_SERVER_SCAN, scanDeps);
break;
default:
throw new Error(`Unsupported discovery type: ${discoveryType as string}`);
diff --git a/backend/src/ee/services/pki-discovery/pki-discovery-schemas.ts b/backend/src/ee/services/pki-discovery/pki-discovery-schemas.ts
index 069a831eae..7aa37d0171 100644
--- a/backend/src/ee/services/pki-discovery/pki-discovery-schemas.ts
+++ b/backend/src/ee/services/pki-discovery/pki-discovery-schemas.ts
@@ -94,12 +94,11 @@ export const WindowsServerTargetConfigSchema = z
importStandaloneCaCertificates: z
.boolean()
.default(false)
- .describe("Also import CA certificates on their own. Leaf certificates always bring their chain.")
+ .describe("Also import CA certificates found on their own. Leaf certificates always bring their chain.")
})
.strict();
-// The type-specific schema re-validates on the service; this only keeps the router's shared fields neutral.
-const CA_ONLY_WINDOWS_STORES: string[] = [
+export const CA_ONLY_WINDOWS_STORES: readonly WindowsCertificateStore[] = [
WindowsCertificateStore.IntermediateCertificationAuthorities,
WindowsCertificateStore.TrustedRootCertificationAuthorities
];
@@ -111,6 +110,7 @@ export const importsNothingFromWindowsStores = (config: {
!config.importStandaloneCaCertificates &&
config.certificateStores.every((store) => CA_ONLY_WINDOWS_STORES.includes(store));
+// The type-specific schema re-validates on the service; this only keeps the router's shared fields neutral.
export const DiscoveryTargetConfigInputSchema = NetworkTargetConfigSchema.partial()
.merge(LinuxServerTargetConfigSchema.partial())
.merge(WindowsServerTargetConfigSchema.partial())
diff --git a/backend/src/ee/services/pki-discovery/pki-discovery-service.ts b/backend/src/ee/services/pki-discovery/pki-discovery-service.ts
index 9128c3470c..a57cc4515b 100644
--- a/backend/src/ee/services/pki-discovery/pki-discovery-service.ts
+++ b/backend/src/ee/services/pki-discovery/pki-discovery-service.ts
@@ -18,20 +18,20 @@ import { BadRequestError, DatabaseError, ForbiddenRequestError, NotFoundError }
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 { APP_CONNECTION_NAME_MAP } from "@app/services/app-connection/app-connection-maps";
import { TAppConnectionServiceFactory } from "@app/services/app-connection/app-connection-service";
import { TOrgDALFactory } from "@app/services/org/org-dal";
import { TGatewayV2DALFactory } from "../gateway-v2/gateway-v2-dal";
import { TPkiDiscoveryConfigDALFactory } from "./pki-discovery-config-dal";
import { validateTargetConfig } from "./pki-discovery-fns";
-import { sshConnectionWithoutGatewayMessage, windowsConnectionWithoutGatewayMessage } from "./pki-discovery-host-fns";
+import { hostConnectionWithoutGatewayMessage } from "./pki-discovery-host-fns";
+import { LINUX_SERVER_SCAN } from "./pki-discovery-host-scan-fns";
import { TPkiDiscoveryScanHistoryDALFactory } from "./pki-discovery-scan-history-dal";
import {
formatTargetConfigIssue,
importsNothingFromWindowsStores,
- LinuxServerTargetConfigSchema,
- NetworkTargetConfigSchema,
- WindowsServerTargetConfigSchema
+ NetworkTargetConfigSchema
} from "./pki-discovery-schemas";
import {
PkiDiscoveryScanStatus,
@@ -49,26 +49,15 @@ import {
TUpdatePkiDiscoveryDTO,
TWindowsServerTargetConfig
} from "./pki-discovery-types";
+import { WINDOWS_SERVER_SCAN } from "./pki-discovery-windows-scan-fns";
const MAX_CLOUD_DISCOVERIES = 10;
const SCAN_RATE_LIMIT_HOURS = 24;
const CONNECTION_VALIDATION_CONCURRENCY = 5;
const HOST_DISCOVERY_TYPES = {
- [PkiDiscoveryType.LinuxServer]: {
- label: "Linux Server",
- app: AppConnection.SSH,
- connectionKind: "SSH",
- schema: LinuxServerTargetConfigSchema,
- withoutGatewayMessage: sshConnectionWithoutGatewayMessage
- },
- [PkiDiscoveryType.WindowsServer]: {
- label: "Windows Server",
- app: AppConnection.WinRM,
- connectionKind: "Windows (WinRM)",
- schema: WindowsServerTargetConfigSchema,
- withoutGatewayMessage: windowsConnectionWithoutGatewayMessage
- }
+ [PkiDiscoveryType.LinuxServer]: LINUX_SERVER_SCAN,
+ [PkiDiscoveryType.WindowsServer]: WINDOWS_SERVER_SCAN
} as const;
type THostDiscoveryType = keyof typeof HOST_DISCOVERY_TYPES;
@@ -175,7 +164,9 @@ export const pkiDiscoveryServiceFactory = ({
(connection) => !connection.gatewayId && !connection.gatewayPoolId
);
if (connectionWithoutGateway) {
- throw new BadRequestError({ message: hostType.withoutGatewayMessage(connectionWithoutGateway.name) });
+ throw new BadRequestError({
+ message: hostConnectionWithoutGatewayMessage(hostType, connectionWithoutGateway.name)
+ });
}
return config;
};
@@ -184,7 +175,7 @@ export const pkiDiscoveryServiceFactory = ({
if (isHostDiscoveryType(discoveryType) && hasJobGateway) {
const hostType = HOST_DISCOVERY_TYPES[discoveryType];
throw new BadRequestError({
- message: `${hostType.label} discovery uses the gateway of each ${hostType.connectionKind} connection, so a gateway or gateway pool cannot be set on the job`
+ message: `${hostType.label} discovery uses the gateway of each ${APP_CONNECTION_NAME_MAP[hostType.app]} connection, so a gateway or gateway pool cannot be set on the job`
});
}
};
diff --git a/backend/src/ee/services/pki-discovery/pki-discovery-windows-scan-fns.test.ts b/backend/src/ee/services/pki-discovery/pki-discovery-windows-scan-fns.test.ts
index 62b4461f26..ac52a8e3e7 100644
--- a/backend/src/ee/services/pki-discovery/pki-discovery-windows-scan-fns.test.ts
+++ b/backend/src/ee/services/pki-discovery/pki-discovery-windows-scan-fns.test.ts
@@ -137,7 +137,7 @@ describe("Windows store installation identity", () => {
});
describe("summarizeWindowsScanIssues", () => {
- test("names denied stores, unreadable certificates and truncation", () => {
+ test("names denied stores, unreadable server certificates and truncation", () => {
const issues = summarizeWindowsScanIssues("web-01", {
host: { hostname: "web-01" },
deniedStores: [WindowsCertificateStore.WebHosting],
@@ -155,12 +155,19 @@ describe("summarizeWindowsScanIssues", () => {
hasPrivateKey: false,
status: HostCertificateFileStatus.Ok,
chains: [{ kind: HostCertificateChainKind.Leaf, indexes: [0] }]
+ },
+ {
+ store: WindowsCertificateStore.IntermediateCertificationAuthorities,
+ thumbprint: "CC",
+ hasPrivateKey: false,
+ status: HostCertificateFileStatus.ParseError,
+ chains: []
}
],
truncatedReason: HostScanTruncationReason.MaxFiles
});
expect(issues).toEqual([
- "web-01: The connection's user can't open these certificate stores: Web Hosting",
+ "web-01: The connection's account can't open these certificate stores: Web Hosting",
"web-01: These certificates could not be read: Personal (AA)",
"web-01: The scan stopped after 5,000 certificates"
]);
@@ -185,7 +192,7 @@ describe("summarizeWindowsScanIssues", () => {
truncatedReason: HostScanTruncationReason.TimeLimit
})
).toEqual([
- "web-01: The connection's user can't open Trusted Root Certification Authorities, so some certificate chains may be incomplete",
+ "web-01: The connection's account can't open Trusted Root Certification Authorities, so some certificate chains may be incomplete",
"web-01: The scan ran out of time, so some certificates were not checked. Select fewer certificate stores."
]);
});
diff --git a/backend/src/ee/services/pki-discovery/pki-discovery-windows-scan-fns.ts b/backend/src/ee/services/pki-discovery/pki-discovery-windows-scan-fns.ts
index 73fb20215c..172820d76c 100644
--- a/backend/src/ee/services/pki-discovery/pki-discovery-windows-scan-fns.ts
+++ b/backend/src/ee/services/pki-discovery/pki-discovery-windows-scan-fns.ts
@@ -1,43 +1,32 @@
+import { HttpStatusCode } from "axios";
import net from "net";
import { z } from "zod";
-import { verifyHostInputValidity } from "@app/ee/services/dynamic-secret/dynamic-secret-fns";
-import { BadRequestError, GatewayTransportError, NotFoundError } from "@app/lib/errors";
-import { getMissingGatewayMessage } from "@app/lib/gateway-v2/gateway-errors";
-import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";
import { GatewayProxyProtocol } from "@app/lib/gateway-v2/types";
-import {
- callWinRmEndpoint,
- WINRM_RPC_RESPONSE_TOO_LARGE_STATUS,
- WinRmRpcEndpoint,
- WinRmRpcResponse
-} from "@app/lib/gateway-v2/winrm-rpc";
-import { logger } from "@app/lib/logger";
+import { callWinRmEndpoint, WinRmRpcEndpoint, WinRmRpcFailure } from "@app/lib/gateway-v2/winrm-rpc";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
-import { decryptAppConnectionCredentials } from "@app/services/app-connection/app-connection-fns";
import { TWinRMCredentials } from "@app/services/app-connection/winrm/winrm-connection-fns";
import { computeLocationFingerprint } from "./pki-discovery-fns";
+import { buildHostInstallationName, normalizeHostIdentifier } from "./pki-discovery-host-fns";
import {
- buildHostInstallationName,
- normalizeHostIdentifier,
- windowsConnectionWithoutGatewayMessage
-} from "./pki-discovery-host-fns";
-import {
- executeHostScan,
HostScanCapability,
importCertificateChains,
- selectScanGateway,
+ resolveHostConnection,
+ runGatewayScan,
TAppConnectionRow,
+ THostScanDefinition,
THostScanDeps,
THostScanOutcome,
THostScanRun,
+ THostScanType,
toHostScanErrorMessage,
TScanGateway,
TWriteContext,
upsertInstallationWithLinks,
withConnectionScanSlot
} from "./pki-discovery-host-scan-fns";
+import { CA_ONLY_WINDOWS_STORES, WindowsServerTargetConfigSchema } from "./pki-discovery-schemas";
import {
HostCertificateChainKind,
HostCertificateFileStatus,
@@ -50,7 +39,6 @@ import {
} from "./pki-discovery-types";
const WINDOWS_STORE_LOCATION = "LocalMachine";
-const WINDOWS_CONNECTION_KIND = "Windows (WinRM)";
const MAX_WINDOWS_SCAN_RESPONSE_BYTES = 24 * 1024 * 1024;
const DEFAULT_WINRM_HTTP_PORT = 5985;
const DEFAULT_WINRM_HTTPS_PORT = 5986;
@@ -95,64 +83,43 @@ type TResolvedWindowsHost = TScanGateway & {
type TScannedWindowsHost = TResolvedWindowsHost & { hostname: string };
+const WINDOWS_SERVER_SCAN_TYPE: THostScanType = {
+ discoveryType: PkiDiscoveryType.WindowsServer,
+ label: "Windows Server",
+ app: AppConnection.WinRM,
+ capability: HostScanCapability.WindowsCertificateScan
+};
+
export const resolveWindowsHost = async (
connection: TAppConnectionRow | undefined,
orgId: string,
deps: THostScanDeps
): Promise<TResolvedWindowsHost> => {
- if (!connection || connection.orgId !== orgId || connection.app !== AppConnection.WinRM) {
- throw new BadRequestError({ message: "The Windows (WinRM) connection no longer exists" });
- }
- if (!connection.gatewayId && !connection.gatewayPoolId) {
- throw new BadRequestError({ message: windowsConnectionWithoutGatewayMessage(connection.name) });
- }
-
- const credentials = (await decryptAppConnectionCredentials({
- orgId: connection.orgId,
- encryptedCredentials: connection.encryptedCredentials,
- kmsService: deps.kmsService,
- projectId: connection.projectId
- })) as TWinRMCredentials;
-
- const gateway = await selectScanGateway(
- connection,
- HostScanCapability.WindowsCertificateScan,
- WINDOWS_CONNECTION_KIND,
- deps
- );
-
- const [targetHost] = await verifyHostInputValidity({
- host: credentials.host,
- isGateway: true,
- isDynamicSecret: false
- });
-
+ const resolved = await resolveHostConnection<TWinRMCredentials>(connection, orgId, WINDOWS_SERVER_SCAN_TYPE, deps);
+ const { credentials } = resolved;
return {
- ...gateway,
- connectionId: connection.id,
+ ...resolved.gateway,
+ connectionId: resolved.connection.id,
hostIdentifier: normalizeHostIdentifier(
credentials.host,
credentials.port,
credentials.sslEnabled ? DEFAULT_WINRM_HTTPS_PORT : DEFAULT_WINRM_HTTP_PORT
),
hostAddress: credentials.host.trim().toLowerCase(),
- targetHost,
+ targetHost: resolved.targetHost,
targetPort: credentials.port,
credentials
};
};
-const describeWindowsScanFailure = (
- failure: Extract<WinRmRpcResponse<unknown>, { ok: false }>,
- gatewayName: string
-): string => {
- if (failure.status === 404) {
+const describeWindowsScanFailure = (failure: WinRmRpcFailure, gatewayName: string): string => {
+ if (failure.status === HttpStatusCode.NotFound) {
return `Gateway '${gatewayName}' is too old for certificate scanning. Update it to the latest version.`;
}
- if (failure.status === WINRM_RPC_RESPONSE_TOO_LARGE_STATUS) {
- return "The scan returned more certificates than one scan can hold. Select fewer certificate stores.";
+ if (failure.status === HttpStatusCode.PayloadTooLarge) {
+ return "The scan found more certificates than one scan can return. Select fewer certificate stores.";
}
- if (failure.status === 503) {
+ if (failure.status === HttpStatusCode.ServiceUnavailable) {
return "The gateway is busy with other certificate scans. Try again later.";
}
if (failure.kind === "auth") {
@@ -164,25 +131,17 @@ const describeWindowsScanFailure = (
return "The gateway could not read the certificate stores on the Windows host. Check the gateway logs for details.";
};
-const runWindowsCertificateScan = async (
+const runWindowsCertificateScan = (
host: TResolvedWindowsHost,
stores: WindowsCertificateStore[],
deps: THostScanDeps
): Promise<TWindowsCertificateScanResponse> => {
- const connectionDetails = await deps.gatewayV2Service.getPlatformConnectionDetailsByGatewayId({
- gatewayId: host.gatewayId,
- targetHost: host.targetHost,
- targetPort: host.targetPort
- });
- if (!connectionDetails) {
- throw new NotFoundError({ message: getMissingGatewayMessage(host.gatewayId) });
- }
-
const { credentials } = host;
- let response: WinRmRpcResponse<unknown>;
- try {
- response = await withGatewayV2Proxy(
- (port) =>
+ return runGatewayScan<WinRmRpcFailure, TWindowsCertificateScanResponse>(
+ host,
+ {
+ protocol: GatewayProxyProtocol.WinRm,
+ call: (port) =>
callWinRmEndpoint<unknown>({
port,
endpoint: WinRmRpcEndpoint.ScanCertificates,
@@ -201,37 +160,12 @@ const runWindowsCertificateScan = async (
}
}
}),
- { protocol: GatewayProxyProtocol.WinRm, longLived: true, ...connectionDetails }
- );
- } catch (error) {
- if (error instanceof GatewayTransportError) throw error;
- const message = error instanceof Error ? error.message : String(error);
- logger.warn(
- `Windows certificate scan transport failed [connectionId=${host.connectionId}] [gatewayId=${host.gatewayId}] [error=${message}]`
- );
- throw new BadRequestError({
- message:
- "The connection to the gateway dropped during the scan. Check that the gateway and its relay are running, then try again."
- });
- }
-
- if (!response.ok) {
- logger.warn(
- { errorMessage: response.errorMessage },
- `Windows certificate scan RPC failed [connectionId=${host.connectionId}] [gatewayId=${host.gatewayId}] [status=${response.status}] [kind=${response.kind ?? "none"}]`
- );
- throw new BadRequestError({ message: describeWindowsScanFailure(response, host.gatewayName) });
- }
-
- const parsed = WindowsCertificateScanResponseSchema.safeParse(response.result);
- if (!parsed.success) {
- logger.warn(
- { issues: parsed.error.issues },
- `Windows certificate scan result did not match the expected shape [connectionId=${host.connectionId}]`
- );
- throw new BadRequestError({ message: "The gateway returned a scan result that could not be read" });
- }
- return parsed.data;
+ describeFailure: (failure) => describeWindowsScanFailure(failure, host.gatewayName),
+ schema: WindowsCertificateScanResponseSchema,
+ logLabel: "Windows certificate scan"
+ },
+ deps
+ );
};
export const storeCertificatePath = (store: string, thumbprint: string) =>
@@ -328,12 +262,16 @@ export const summarizeWindowsScanIssues = (
const denied = response.deniedStores ?? [];
if (denied.length > 0) {
issues.push(
- `${hostIdentifier}: The connection's user can't open these certificate stores: ${denied
+ `${hostIdentifier}: The connection's account can't open these certificate stores: ${denied
.map((store) => STORE_NAMES[store] ?? store)
.join(", ")}`
);
}
- const unreadable = (response.certificates ?? []).filter((cert) => cert.status !== HostCertificateFileStatus.Ok);
+ const unreadable = (response.certificates ?? []).filter(
+ (cert) =>
+ cert.status !== HostCertificateFileStatus.Ok &&
+ !(CA_ONLY_WINDOWS_STORES as readonly string[]).includes(cert.store)
+ );
if (unreadable.length > 0) {
const listed = unreadable
.slice(0, MAX_LISTED_UNREADABLE)
@@ -346,7 +284,7 @@ export const summarizeWindowsScanIssues = (
const unreadableIssuers = response.unreadableIssuerStores ?? [];
if (unreadableIssuers.length > 0) {
issues.push(
- `${hostIdentifier}: The connection's user can't open ${unreadableIssuers
+ `${hostIdentifier}: The connection's account can't open ${unreadableIssuers
.map((store) => STORE_NAMES[store] ?? store)
.join(", ")}, so some certificate chains may be incomplete`
);
@@ -390,7 +328,7 @@ const scanWindowsConnection = async (
try {
const host = await resolveWindowsHost(connection, run.orgId, deps);
hostLabel = host.hostIdentifier;
- const response = await withConnectionScanSlot(host.connectionId, WINDOWS_CONNECTION_KIND, deps, () =>
+ const response = await withConnectionScanSlot(host.connectionId, AppConnection.WinRM, deps, () =>
runWindowsCertificateScan(host, run.targetConfig.certificateStores, deps)
);
issues.push(...summarizeWindowsScanIssues(host.hostIdentifier, response));
@@ -425,9 +363,8 @@ const scanWindowsConnection = async (
}
};
-export const executeWindowsServerScan = (discoveryId: string, deps: THostScanDeps): Promise<void> =>
- executeHostScan<TWindowsServerTargetConfig>(
- discoveryId,
- { discoveryType: PkiDiscoveryType.WindowsServer, label: "Windows Server", scanConnection: scanWindowsConnection },
- deps
- );
+export const WINDOWS_SERVER_SCAN: THostScanDefinition<TWindowsServerTargetConfig> = {
+ ...WINDOWS_SERVER_SCAN_TYPE,
+ schema: WindowsServerTargetConfigSchema,
+ scanConnection: scanWindowsConnection
+};
diff --git a/backend/src/lib/gateway-v2/winrm-rpc.ts b/backend/src/lib/gateway-v2/winrm-rpc.ts
index 2aec064eb5..3e0eaeffb4 100644
--- a/backend/src/lib/gateway-v2/winrm-rpc.ts
+++ b/backend/src/lib/gateway-v2/winrm-rpc.ts
@@ -1,3 +1,5 @@
+import { HttpStatusCode } from "axios";
+
import { GatewayRpcResponseTooLargeError, postGatewayRpc } from "./gateway-rpc";
import { GatewayFailureKind } from "./test-connection-rpc";
@@ -52,8 +54,6 @@ export const WINRM_RPC_TIMEOUT_MS = 150_000;
const MAX_WINRM_RPC_RESPONSE_BYTES = 1024 * 1024;
-export const WINRM_RPC_RESPONSE_TOO_LARGE_STATUS = 413;
-
export const callWinRmEndpoint = async <T>(args: {
port: number;
endpoint: WinRmRpcEndpoint;
@@ -73,7 +73,7 @@ export const callWinRmEndpoint = async <T>(args: {
});
} catch (error) {
if (error instanceof GatewayRpcResponseTooLargeError) {
- return { ok: false, status: WINRM_RPC_RESPONSE_TOO_LARGE_STATUS, errorMessage: error.message, kind: null };
+ return { ok: false, status: HttpStatusCode.PayloadTooLarge, errorMessage: error.message, kind: null };
}
throw error;
}
diff --git a/docs/documentation/platform/pki/discovery/windows-server.mdx b/docs/documentation/platform/pki/discovery/windows-server.mdx
index dcb8e3fc20..42deb5ebd2 100644
--- a/docs/documentation/platform/pki/discovery/windows-server.mdx
+++ b/docs/documentation/platform/pki/discovery/windows-server.mdx
@@ -65,7 +65,7 @@ If the connection's account can't open a store, the scan completes and the job l
<AccordionGroup>
<Accordion title="Why does the job show a warning after a scan?">
- The scan completed, but some stores or certificates couldn't be read, or the scan stopped early. The job lists what happened. If a store couldn't be opened, check that the connection's account can read it on the server. If the scan stopped after 5,000 certificates, or found more certificates than one scan can return, select fewer stores.
+ The scan completed, but some stores or certificates couldn't be read, or the scan stopped early. The job lists what happened. If a store couldn't be opened, check that the connection's account can read it on the server. If the scan stopped after 5,000 certificates, ran out of time, or found more certificates than one scan can return, select fewer stores.
</Accordion>
<Accordion title="Does the scan read files on disk, such as PFX files?">
No. Windows Server discovery only reads the certificate store.
diff --git a/frontend/src/hooks/api/gateways-v2/types.ts b/frontend/src/hooks/api/gateways-v2/types.ts
index 635069e2fc..5c8870726d 100644
--- a/frontend/src/hooks/api/gateways-v2/types.ts
+++ b/frontend/src/hooks/api/gateways-v2/types.ts
@@ -156,3 +156,8 @@ export type TGatewayConnectedResources = {
pamAccounts?: TGatewayConnectedPamAccount[];
pamAccountTemplates?: TGatewayConnectedPamAccountTemplate[];
};
+
+export enum GatewayCapability {
+ CertificateScan = "certificateScan",
+ WindowsCertificateScan = "windowsCertificateScan"
+}
diff --git a/frontend/src/hooks/api/pkiDiscovery/types.ts b/frontend/src/hooks/api/pkiDiscovery/types.ts
index 26f65fa5ab..84893c9e3e 100644
--- a/frontend/src/hooks/api/pkiDiscovery/types.ts
+++ b/frontend/src/hooks/api/pkiDiscovery/types.ts
@@ -126,7 +126,7 @@ export type TPkiInstallation = {
hostname?: string;
format?: PkiCertificateFileFormat;
storeLocation?: string;
- storeName?: string;
+ storeName?: WindowsCertificateStore;
thumbprint?: string;
hasPrivateKey?: boolean;
};
diff --git a/frontend/src/pages/cert-manager/DiscoveryDetailsByIDPage/components/DiscoveryTargetSection.tsx b/frontend/src/pages/cert-manager/DiscoveryDetailsByIDPage/components/DiscoveryTargetSection.tsx
index f444fd06ef..6d84941ca8 100644
--- a/frontend/src/pages/cert-manager/DiscoveryDetailsByIDPage/components/DiscoveryTargetSection.tsx
+++ b/frontend/src/pages/cert-manager/DiscoveryDetailsByIDPage/components/DiscoveryTargetSection.tsx
@@ -109,11 +109,13 @@ const WindowsServerTargetSection = ({ discovery }: Props) => {
<Detail>
<DetailLabel>Certificate Stores</DetailLabel>
<DetailValue>
- <OverflowBadgeList
- items={targetConfig.certificateStores ?? []}
- getKey={(store) => store}
- getLabel={(store) => WindowsCertificateStoreLabels[store] ?? store}
- />
+ <div className="flex flex-wrap gap-1">
+ {(targetConfig.certificateStores ?? []).map((store) => (
+ <Badge key={store} variant="neutral">
+ {WindowsCertificateStoreLabels[store] ?? store}
+ </Badge>
+ ))}
+ </div>
</DetailValue>
</Detail>
<Detail>
diff --git a/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobSheet/DiscoveryJobForm.tsx b/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobSheet/DiscoveryJobForm.tsx
index 5f8e9fe485..1e1e0543b0 100644
--- a/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobSheet/DiscoveryJobForm.tsx
+++ b/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobSheet/DiscoveryJobForm.tsx
@@ -12,6 +12,7 @@ import {
import { getDiscoveryDocsUrl, PKI_DISCOVERY_TYPE_MAP } from "@app/helpers/pkiDiscovery";
import { useCreatePkiDiscovery, useUpdatePkiDiscovery } from "@app/hooks/api";
import { AppConnection } from "@app/hooks/api/appConnections/enums";
+import { GatewayCapability } from "@app/hooks/api/gateways-v2/types";
import {
PkiDiscoveryType,
TPkiDiscovery,
@@ -83,7 +84,7 @@ const STEP_META: Record<
short: "Stores and CA certificates",
subtitle: "Choose the certificate stores to read and what to import.",
rightDescription:
- "The scan reads the Local Machine certificate stores. Private keys aren't read or imported; the installation only records whether a certificate has one.\n\nStores the connection's user can't open are listed in the scan."
+ "The scan reads the Local Machine certificate stores. Private keys aren't read or imported; the installation only records whether a certificate has one.\n\nStores the connection's account can't open are listed in the scan."
},
[DiscoveryJobStep.Folders]: {
name: "Where to Look",
@@ -315,14 +316,14 @@ export const DiscoveryJobForm = ({
<HostConnectionsFields
app={AppConnection.SSH}
connectionLabel="SSH"
- capability="certificateScan"
+ capability={GatewayCapability.CertificateScan}
/>
)}
{currentKey === DiscoveryJobStep.WindowsHosts && (
<HostConnectionsFields
app={AppConnection.WinRM}
connectionLabel="Windows (WinRM)"
- capability="windowsCertificateScan"
+ capability={GatewayCapability.WindowsCertificateScan}
/>
)}
{currentKey === DiscoveryJobStep.Stores && <WindowsServerStoresFields />}
diff --git a/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobSheet/HostConnectionsFields.tsx b/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobSheet/HostConnectionsFields.tsx
index 6689628e0e..0d87e4a464 100644
--- a/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobSheet/HostConnectionsFields.tsx
+++ b/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobSheet/HostConnectionsFields.tsx
@@ -21,6 +21,7 @@ import {
} from "@app/hooks/api/appConnections";
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { gatewaysQueryKeys } from "@app/hooks/api/gateways/queries";
+import { GatewayCapability } from "@app/hooks/api/gateways-v2/types";
import { useConnectionCreation } from "@app/pages/cert-manager/CertificateAuthoritiesPage/components/CaInstallCertModal/useConnectionCreation";
import { THostDiscoveryJobForm } from "./discovery-job-form-schema";
@@ -31,7 +32,7 @@ type TConnectionOption = Pick<TAvailableAppConnection, "id" | "name"> &
type Props = {
app: AppConnection.SSH | AppConnection.WinRM;
connectionLabel: string;
- capability: "certificateScan" | "windowsCertificateScan";
+ capability: GatewayCapability.CertificateScan | GatewayCapability.WindowsCertificateScan;
};
export const HostConnectionsFields = ({ app, connectionLabel, capability }: Props) => {
diff --git a/frontend/src/pages/cert-manager/InstallationDetailsByIDPage/components/InstallationDetailsSection.tsx b/frontend/src/pages/cert-manager/InstallationDetailsByIDPage/components/InstallationDetailsSection.tsx
index b8403bbda2..d7d9fe0f82 100644
--- a/frontend/src/pages/cert-manager/InstallationDetailsByIDPage/components/InstallationDetailsSection.tsx
+++ b/frontend/src/pages/cert-manager/InstallationDetailsByIDPage/components/InstallationDetailsSection.tsx
@@ -17,10 +17,7 @@ import {
PkiInstallationLocationType,
TPkiInstallation
} from "@app/hooks/api";
-import {
- WindowsCertificateStore,
- WindowsCertificateStoreLabels
-} from "@app/hooks/api/pkiDiscovery/types";
+import { WindowsCertificateStoreLabels } from "@app/hooks/api/pkiDiscovery/types";
import {
getKeystoreStatusBadge,
getStorePath,
@@ -72,9 +69,7 @@ export const InstallationDetailsSection = ({ installation }: Props) => {
<DetailLabel>Certificate Store</DetailLabel>
<DetailValue>
{(locationDetails.storeName &&
- WindowsCertificateStoreLabels[
- locationDetails.storeName as WindowsCertificateStore
- ]) ||
+ WindowsCertificateStoreLabels[locationDetails.storeName]) ||
locationDetails.storeName}
</DetailValue>
</Detail>