Skip to content

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

Address greptile comments

Carlos Monastyrski04c77e4cd6a9
diff --git a/backend/src/services/app-connection/powerdns/powerdns-connection-fns.ts b/backend/src/services/app-connection/powerdns/powerdns-connection-fns.ts
index 3137997c06..656100f646 100644
--- a/backend/src/services/app-connection/powerdns/powerdns-connection-fns.ts
+++ b/backend/src/services/app-connection/powerdns/powerdns-connection-fns.ts
@@ -9,7 +9,7 @@ import { BadRequestError } from "@app/lib/errors";
import { removeTrailingSlash } from "@app/lib/fn";
import { GatewayProxyProtocol } from "@app/lib/gateway";
import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";
-import { logger } from "@app/lib/logger";
+import { logger, sanitizeUrlForLog } from "@app/lib/logger";
import { getSharedHttpsAgent, safeRequest } from "@app/lib/validator/safe-request";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
@@ -17,7 +17,7 @@ import { PowerDnsConnectionMethod } from "./powerdns-connection-enums";
import { TPowerDnsConnectionConfig, TPowerDnsRrset, TPowerDnsZone } from "./powerdns-connection-types";
const POWERDNS_DEFAULT_SERVER_ID = "localhost";
-const POWERDNS_REQUEST_TIMEOUT_MS = 30_000;
+export const POWERDNS_REQUEST_TIMEOUT_MS = 30_000;
const POWERDNS_MAX_RESPONSE_BYTES = 10 * 1024 * 1024;
export type TPowerDnsGatewayDeps = {
@@ -43,6 +43,23 @@ export const getPowerDnsConnectionListItem = () => {
export const getPowerDnsApiUrl = (apiUrl: string, path: string, serverId?: string) =>
`${removeTrailingSlash(apiUrl)}/api/v1/servers/${encodeURIComponent(serverId || POWERDNS_DEFAULT_SERVER_ID)}${path}`;
+const toLoggableError = (error: unknown) => {
+ if (isAxiosError(error)) {
+ return {
+ name: error.name,
+ code: error.code,
+ status: error.response?.status,
+ message: error.message,
+ url: error.config?.url ? sanitizeUrlForLog(error.config.url) : undefined,
+ stack: error.stack
+ };
+ }
+
+ if (error instanceof Error) return { name: error.name, message: error.message, stack: error.stack };
+
+ return { message: String(error) };
+};
+
export const getPowerDnsErrorMessage = (error: unknown, fallback: string) => {
if (isAxiosError(error)) {
const body = error.response?.data as { error?: string } | string | undefined;
@@ -171,7 +188,7 @@ export const listPowerDnsZones = async (
} catch (error) {
if (error instanceof BadRequestError) throw error;
- logger.error(error, "Failed to list PowerDNS zones");
+ logger.error(toLoggableError(error), "Failed to list PowerDNS zones");
throw new BadRequestError({
message: `Failed to list PowerDNS zones: ${getPowerDnsErrorMessage(error, "verify the API URL and API key")}`
});
@@ -198,7 +215,7 @@ export const getPowerDnsZoneRrset = async (
} catch (error) {
if (error instanceof BadRequestError) throw error;
- logger.error(error, `Failed to read PowerDNS zone [zoneId=${zoneId}] [name=${name}]`);
+ logger.error(toLoggableError(error), `Failed to read PowerDNS zone [zoneId=${zoneId}] [name=${name}]`);
throw new Error(`Failed to read PowerDNS zone '${zoneId}': ${getPowerDnsErrorMessage(error, "unknown error")}`);
}
};
@@ -217,7 +234,7 @@ export const patchPowerDnsZoneRrsets = async (
} catch (error) {
if (error instanceof BadRequestError) throw error;
- logger.error(error, `Failed to update PowerDNS records [zoneId=${zoneId}]`);
+ logger.error(toLoggableError(error), `Failed to update PowerDNS records [zoneId=${zoneId}]`);
throw new Error(
`Failed to update PowerDNS records in zone '${zoneId}': ${getPowerDnsErrorMessage(error, "unknown error")}`
);
@@ -234,7 +251,7 @@ export const validatePowerDnsConnectionCredentials = async (
} catch (error) {
if (error instanceof BadRequestError) throw error;
- logger.error(error, "Failed to validate PowerDNS connection credentials");
+ logger.error(toLoggableError(error), "Failed to validate PowerDNS connection credentials");
throw new BadRequestError({
message: `Unable to validate PowerDNS connection: ${getPowerDnsErrorMessage(error, "verify the API URL and API key")}`
});
diff --git a/backend/src/services/app-connection/powerdns/powerdns-connection-schemas.ts b/backend/src/services/app-connection/powerdns/powerdns-connection-schemas.ts
index a8a94f3eaa..479ca415cc 100644
--- a/backend/src/services/app-connection/powerdns/powerdns-connection-schemas.ts
+++ b/backend/src/services/app-connection/powerdns/powerdns-connection-schemas.ts
@@ -24,6 +24,9 @@ export const PowerDnsConnectionApiKeyCredentialsSchema = z.object({
.refine((value) => ["http:", "https:"].includes(new URL(value).protocol), {
message: "API URL must use http or https"
})
+ .refine((value) => !new URL(value).search && !new URL(value).hash, {
+ message: "API URL must not contain a query string or fragment"
+ })
.refine((value) => !API_PATH_SUFFIX.test(new URL(value).pathname), {
message:
"API URL must not include the /api/v1 path, only the web server address (e.g. https://pdns.example.com:8081)"
diff --git a/backend/src/services/certificate-authority/acme/dns-providers/powerdns.ts b/backend/src/services/certificate-authority/acme/dns-providers/powerdns.ts
index c9099bdc95..b3caa41679 100644
--- a/backend/src/services/certificate-authority/acme/dns-providers/powerdns.ts
+++ b/backend/src/services/certificate-authority/acme/dns-providers/powerdns.ts
@@ -3,6 +3,7 @@ import { logger } from "@app/lib/logger";
import {
getPowerDnsZoneRrset,
patchPowerDnsZoneRrsets,
+ POWERDNS_REQUEST_TIMEOUT_MS,
TPowerDnsGatewayDeps
} from "@app/services/app-connection/powerdns/powerdns-connection-fns";
import {
@@ -11,8 +12,8 @@ import {
} from "@app/services/app-connection/powerdns/powerdns-connection-types";
const ACME_CHALLENGE_TTL_SECONDS = 60;
-const RRSET_LOCK_TTL_MS = 60 * 1000;
-const RRSET_LOCK_RETRY = { retryCount: 20, retryDelay: 1_000, retryJitter: 300 };
+const RRSET_LOCK_TTL_MS = POWERDNS_REQUEST_TIMEOUT_MS * 2 + 30_000;
+const RRSET_LOCK_RETRY = { retryCount: 50, retryDelay: 2_000, retryJitter: 300 };
export type TPowerDnsProviderDeps = TPowerDnsGatewayDeps & {
keyStore?: Pick<TKeyStoreFactory, "acquireLock">;
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/PowerDnsConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/PowerDnsConnectionForm.tsx
index 1c9111b3ec..fb2730e697 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/PowerDnsConnectionForm.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/PowerDnsConnectionForm.tsx
@@ -65,6 +65,9 @@ const formSchema = z.discriminatedUnion("method", [
.refine((value) => ["http:", "https:"].includes(new URL(value).protocol), {
message: "API URL must use http or https"
})
+ .refine((value) => !new URL(value).search && !new URL(value).hash, {
+ message: "API URL must not contain a query string or fragment"
+ })
.refine((value) => !/\/api(\/v\d+)?\/*$/.test(new URL(value).pathname), {
message: "Enter the web server address only, without the /api/v1 path"
}),