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
fix(pki): keep imperva errors through the gateway and match form validation
bernie-gc16cf8cfef22
diff --git a/backend/src/services/app-connection/imperva/imperva-connection-fns.ts b/backend/src/services/app-connection/imperva/imperva-connection-fns.tsindex 998081cc35..056a82d674 100644--- a/backend/src/services/app-connection/imperva/imperva-connection-fns.ts+++ b/backend/src/services/app-connection/imperva/imperva-connection-fns.ts@@ -168,7 +168,7 @@ export const withImpervaOperation = async <T>(// withGatewayV2Proxy replaces the thrown error with one of its own, so Imperva's status and// message are kept here and rethrown once the proxies have been torn down.- let impervaError: Error | undefined;+ let operationError: Error | undefined;// Pooled per host for the operation, then destroyed: the proxy's port goes away with it, so a// socket kept alive past the teardown points at nothing.const agents: Record<string, https.Agent> = {@@ -194,19 +194,23 @@ export const withImpervaOperation = async <T>(});return resp.data;} catch (error) {- impervaError = toImpervaRequestError(error);- throw impervaError;+ throw toImpervaRequestError(error);}};- return operation(makeRequest);+ try {+ return await operation(makeRequest);+ } catch (error) {+ operationError = error instanceof Error ? error : new Error(String(error));+ throw operationError;+ }},{ protocol: GatewayProxyProtocol.Tcp, ...restTarget }),{ protocol: GatewayProxyProtocol.Tcp, ...provTarget });} catch (error) {- if (impervaError) throw impervaError;+ if (operationError) throw operationError;throw error;} finally {Object.values(agents).forEach((agent) => agent.destroy());diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/ImpervaConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/ImpervaConnectionForm.tsxindex ca5ce0937e..dddc6ff3c2 100644--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/ImpervaConnectionForm.tsx+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/ImpervaConnectionForm.tsx@@ -50,12 +50,14 @@ const formSchema = z.discriminatedUnion("method", [.string().trim().min(1, "API ID is required")- .max(256, "API ID cannot exceed 256 characters"),+ .max(256, "API ID cannot exceed 256 characters")+ .regex(/^[\x21-\x7e]+$/, "API ID cannot contain spaces or line breaks"),apiKey: z.string().trim().min(1, "API key is required")- .max(512, "API key cannot exceed 512 characters"),+ .max(512, "API key cannot exceed 512 characters")+ .regex(/^[\x21-\x7e]+$/, "API key cannot contain spaces or line breaks"),accountId: z.string().trim()