Skip to content

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

address review comments

adilson43e217a8c619
diff --git a/backend/src/ee/services/secret-rotation-v2/datadog-application-key-secret/datadog-application-key-secret-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/datadog-application-key-secret/datadog-application-key-secret-rotation-fns.ts
index e427b27c44..d12e721639 100644
--- a/backend/src/ee/services/secret-rotation-v2/datadog-application-key-secret/datadog-application-key-secret-rotation-fns.ts
+++ b/backend/src/ee/services/secret-rotation-v2/datadog-application-key-secret/datadog-application-key-secret-rotation-fns.ts
@@ -46,10 +46,9 @@ export const datadogApplicationKeySecretRotationFactory: TRotationFactory<
const $createApplicationKey = async () => {
const baseUrl = await getDatadogBaseUrl(connection);
- logger.info(`Creating Datadog application key for service account ${serviceAccountId} on base URL: ${baseUrl}`);
try {
const { data } = await request.post<TDatadogCreateApplicationKeyResponse>(
- `${baseUrl}/api/v2/service_accounts/${serviceAccountId}/application_keys`,
+ `${baseUrl}/api/v2/service_accounts/${encodeURIComponent(serviceAccountId)}/application_keys`,
{
data: {
type: "application_keys",
@@ -83,7 +82,7 @@ export const datadogApplicationKeySecretRotationFactory: TRotationFactory<
try {
await request.delete(
- `${baseUrl}/api/v2/service_accounts/${serviceAccountId}/application_keys/${applicationKeyId}`,
+ `${baseUrl}/api/v2/service_accounts/${encodeURIComponent(serviceAccountId)}/application_keys/${encodeURIComponent(applicationKeyId)}`,
{ headers: authHeaders }
);
} catch (error: unknown) {
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts
index 3374909e21..06ff04be78 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts
@@ -10,7 +10,10 @@ import { AUTH0_CLIENT_SECRET_ROTATION_LIST_OPTION } from "./auth0-client-secret"
import { AWS_IAM_USER_SECRET_ROTATION_LIST_OPTION } from "./aws-iam-user-secret";
import { AZURE_CLIENT_SECRET_ROTATION_LIST_OPTION } from "./azure-client-secret";
import { DATABRICKS_SERVICE_PRINCIPAL_SECRET_ROTATION_LIST_OPTION } from "./databricks-service-principal-secret";
-import { DATADOG_APPLICATION_KEY_SECRET_ROTATION_LIST_OPTION } from "./datadog-application-key-secret";
+import {
+ DATADOG_APPLICATION_KEY_SECRET_ROTATION_LIST_OPTION,
+ TDatadogApplicationKeySecretRotation
+} from "./datadog-application-key-secret";
import { DBT_SERVICE_TOKEN_ROTATION_LIST_OPTION } from "./dbt-service-token";
import { HP_ILO_ROTATION_LIST_OPTION, THpIloRotation } from "./hp-ilo-rotation";
import { LDAP_PASSWORD_ROTATION_LIST_OPTION, TLdapPasswordRotation } from "./ldap-password";
@@ -374,6 +377,17 @@ export const throwOnImmutableParameterUpdate = (
throw new BadRequestError({ message: "Cannot update project reference or key type" });
}
break;
+ case SecretRotation.DatadogApplicationKeySecret:
+ if (
+ haveUnequalProperties(
+ updatePayload.parameters as TDatadogApplicationKeySecretRotation["parameters"],
+ secretRotation.parameters as TDatadogApplicationKeySecretRotation["parameters"],
+ ["serviceAccountId"]
+ )
+ ) {
+ throw new BadRequestError({ message: "Cannot update service account ID" });
+ }
+ break;
default:
// do nothing
}
diff --git a/backend/src/services/app-connection/datadog/datadog-connection-fns.ts b/backend/src/services/app-connection/datadog/datadog-connection-fns.ts
index 76e840ec09..6b04cce1a0 100644
--- a/backend/src/services/app-connection/datadog/datadog-connection-fns.ts
+++ b/backend/src/services/app-connection/datadog/datadog-connection-fns.ts
@@ -9,7 +9,7 @@ import { AppConnection } from "../app-connection-enums";
import { DatadogConnectionMethod } from "./datadog-connection-enums";
import { TDatadogConnection, TDatadogConnectionConfig, TDatadogServiceAccount } from "./datadog-connection-types";
-const DATADOG_ALLOWED_DOMAINS = ["datadoghq", "ddog-gov"];
+const DATADOG_ALLOWED_DOMAIN_SUFFIXES = ["datadoghq.com", "datadoghq.eu", "ddog-gov.com"];
export const getDatadogBaseUrl = async (config: TDatadogConnectionConfig) => {
const rawUrl = removeTrailingSlash(config.credentials.url);
@@ -21,11 +21,13 @@ export const getDatadogBaseUrl = async (config: TDatadogConnectionConfig) => {
throw new BadRequestError({ message: "Invalid Datadog URL" });
}
- const labels = parsed.hostname.split(".");
- const secondLevelLabel = labels[labels.length - 2];
- if (!secondLevelLabel || !DATADOG_ALLOWED_DOMAINS.includes(secondLevelLabel)) {
+ const { hostname } = parsed;
+ const isAllowedHost = DATADOG_ALLOWED_DOMAIN_SUFFIXES.some(
+ (suffix) => hostname === suffix || hostname.endsWith(`.${suffix}`)
+ );
+ if (!isAllowedHost) {
throw new BadRequestError({
- message: "Datadog URL must be a datadoghq.* or ddog-gov.* domain"
+ message: "Datadog URL must end with datadoghq.com, datadoghq.eu, or ddog-gov.com"
});
}
diff --git a/docs/integrations/app-connections/datadog.mdx b/docs/integrations/app-connections/datadog.mdx
index d77129cc66..1c3deb769e 100644
--- a/docs/integrations/app-connections/datadog.mdx
+++ b/docs/integrations/app-connections/datadog.mdx
@@ -51,7 +51,7 @@ Infisical supports the use of a Datadog [API Key](https://docs.datadoghq.com/acc
Provide a name, email, and select a role for the Service Account, then click **Create Service Account**.
<Note>
- The Service Account's role determines which resources Infisical can access. Make sure it has access to the resources you want Infisical to manage. For secret rotation, it is required to have the `Datadog Admin Role`
+ The Service Account's role determines which resources Infisical can access. Make sure it has access to the resources you want Infisical to manage. For secret rotation, it is required to have the `Datadog Admin Role` as a base so the **Application Key can be scoped**
</Note>
![Create Service Account](/images/app-connections/datadog/create-service-account.png)
diff --git a/docs/snippets/RotationsBrowser.jsx b/docs/snippets/RotationsBrowser.jsx
index 3ac791c606..457bddbda8 100644
--- a/docs/snippets/RotationsBrowser.jsx
+++ b/docs/snippets/RotationsBrowser.jsx
@@ -163,7 +163,7 @@ export const RotationsBrowser = () => {
{
name: "Datadog Application Key",
slug: "datadog-application-key",
- path: "/documentation/platform/secret-rotation/datadog-application-key",
+ path: "/documentation/platform/secret-rotation/datadog-application-key-secret",
description:
"Learn how to automatically rotate Datadog application keys.",
category: "Monitoring",