Skip to content

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

Address greptile comments

Carlos Monastyrski5cd17c64f21b
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 3eafd9fd40..d513562b09 100644
--- a/backend/src/ee/services/pki-discovery/pki-discovery-service.ts
+++ b/backend/src/ee/services/pki-discovery/pki-discovery-service.ts
@@ -113,12 +113,15 @@ export const pkiDiscoveryServiceFactory = ({
const $validateLinuxServerTarget = async (
targetConfig: TPkiDiscoveryTargetConfig,
projectId: string,
- actor: OrgServiceActor
+ actor: OrgServiceActor,
+ existingConnectionIds?: string[]
): Promise<TLinuxServerTargetConfig> => {
const config = $parseTargetConfig<TLinuxServerTargetConfig>(LinuxServerTargetConfigSchema, targetConfig);
+ const alreadyValidated = new Set(existingConnectionIds);
+ const newConnectionIds = config.connectionIds.filter((connectionId) => !alreadyValidated.has(connectionId));
const limit = pLimit(CONNECTION_VALIDATION_CONCURRENCY);
const connections = await Promise.all(
- config.connectionIds.map((connectionId) =>
+ newConnectionIds.map((connectionId) =>
limit(() =>
appConnectionService.validateAppConnectionUsageById(AppConnection.SSH, { connectionId, projectId }, actor)
)
@@ -147,19 +150,21 @@ export const pkiDiscoveryServiceFactory = ({
targetConfig,
hasGateway,
projectId,
- actor
+ actor,
+ existingConnectionIds
}: {
discoveryType: PkiDiscoveryType;
targetConfig: TPkiDiscoveryTargetConfig;
hasGateway: boolean;
projectId: string;
actor: OrgServiceActor;
+ existingConnectionIds?: string[];
}): Promise<TPkiDiscoveryTargetConfig> => {
switch (discoveryType) {
case PkiDiscoveryType.Network:
return $validateNetworkTarget(targetConfig, hasGateway);
case PkiDiscoveryType.LinuxServer:
- return $validateLinuxServerTarget(targetConfig, projectId, actor);
+ return $validateLinuxServerTarget(targetConfig, projectId, actor, existingConnectionIds);
default:
throw new BadRequestError({ message: `Unsupported discovery type: ${discoveryType as string}` });
}
@@ -329,13 +334,19 @@ export const pkiDiscoveryServiceFactory = ({
$assertJobGatewayAllowed(discoveryType, Boolean(gatewayId || gatewayPoolId));
+ const existingConnectionIds =
+ discoveryType === PkiDiscoveryType.LinuxServer
+ ? (discovery.targetConfig as TLinuxServerTargetConfig).connectionIds
+ : undefined;
+
const validatedTargetConfig = targetConfig
? await $validateTarget({
discoveryType,
targetConfig,
hasGateway: effectiveHasGateway,
projectId: discovery.projectId,
- actor: orgActor
+ actor: orgActor,
+ existingConnectionIds
})
: undefined;
diff --git a/frontend/src/pages/cert-manager/DiscoveryPage/components/SetKeystorePasswordDialog.tsx b/frontend/src/pages/cert-manager/DiscoveryPage/components/SetKeystorePasswordDialog.tsx
index 74c18c249d..43aa1f53ac 100644
--- a/frontend/src/pages/cert-manager/DiscoveryPage/components/SetKeystorePasswordDialog.tsx
+++ b/frontend/src/pages/cert-manager/DiscoveryPage/components/SetKeystorePasswordDialog.tsx
@@ -64,8 +64,13 @@ export const SetKeystorePasswordDialog = ({
onOpenChange(false);
};
+ const handleOpenChange = (nextOpen: boolean) => {
+ if (!nextOpen && updateInstallation.isPending) return;
+ onOpenChange(nextOpen);
+ };
+
return (
- <Dialog open={isOpen} onOpenChange={onOpenChange}>
+ <Dialog open={isOpen} onOpenChange={handleOpenChange}>
<DialogContent>
<DialogHeader>
<DialogTitle>{isChange ? "Change Password" : "Set Password"}</DialogTitle>
@@ -106,7 +111,12 @@ export const SetKeystorePasswordDialog = ({
</FieldDescription>
</Field>
<DialogFooter className="mt-6">
- <Button type="button" variant="outline" onClick={() => onOpenChange(false)}>
+ <Button
+ type="button"
+ variant="outline"
+ onClick={() => onOpenChange(false)}
+ isDisabled={updateInstallation.isPending}
+ >
Cancel
</Button>
<Button