From b5c3f17ec1414aa2005cd7b27599a07631e2f8b0 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 28 May 2025 17:04:43 +0530 Subject: [PATCH] feat: resolved reptile changes --- backend/src/ee/routes/v1/dynamic-secret-router.ts | 13 +++++++++++++ .../dynamic-secret/providers/aws-elasticache.ts | 2 +- .../services/dynamic-secret/providers/mongo-db.ts | 2 +- .../platform/dynamic-secrets/aws-elasticache.mdx | 2 +- .../platform/dynamic-secrets/mongo-atlas.mdx | 6 +++--- .../platform/dynamic-secrets/rabbit-mq.mdx | 3 --- .../CreateDynamicSecretForm/SapAseInputForm.tsx | 1 - .../CreateDynamicSecretForm/SapHanaInputForm.tsx | 1 - 8 files changed, 19 insertions(+), 11 deletions(-) diff --git a/backend/src/ee/routes/v1/dynamic-secret-router.ts b/backend/src/ee/routes/v1/dynamic-secret-router.ts index 486f92980..ba2a5e4eb 100644 --- a/backend/src/ee/routes/v1/dynamic-secret-router.ts +++ b/backend/src/ee/routes/v1/dynamic-secret-router.ts @@ -7,6 +7,7 @@ import { daysToMillisecond } from "@app/lib/dates"; import { removeTrailingSlash } from "@app/lib/fn"; import { ms } from "@app/lib/ms"; import { isValidHandleBarTemplate } from "@app/lib/template/validate-handlebars"; +import { CharacterType, characterValidator } from "@app/lib/validator/validate-string"; import { readLimit, writeLimit } from "@app/server/config/rateLimiter"; import { slugSchema } from "@app/server/lib/schemas"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; @@ -14,9 +15,21 @@ import { SanitizedDynamicSecretSchema } from "@app/server/routes/sanitizedSchema import { AuthMode } from "@app/services/auth/auth-type"; import { ResourceMetadataSchema } from "@app/services/resource-metadata/resource-metadata-schema"; +const validateUsernameTemplateCharacters = characterValidator([ + CharacterType.AlphaNumeric, + CharacterType.Underscore, + CharacterType.Hyphen, + CharacterType.OpenBrace, + CharacterType.CloseBrace, + CharacterType.CloseBracket, + CharacterType.OpenBracket, + CharacterType.Fullstop +]); + const userTemplateSchema = z .string() .trim() + .refine((el) => validateUsernameTemplateCharacters(el)) .refine((el) => isValidHandleBarTemplate(el, { allowedExpressions: (val) => ["randomUsername", "unixTimestamp"].includes(val) diff --git a/backend/src/ee/services/dynamic-secret/providers/aws-elasticache.ts b/backend/src/ee/services/dynamic-secret/providers/aws-elasticache.ts index 5e6279a13..56fa110d1 100644 --- a/backend/src/ee/services/dynamic-secret/providers/aws-elasticache.ts +++ b/backend/src/ee/services/dynamic-secret/providers/aws-elasticache.ts @@ -134,7 +134,7 @@ const generatePassword = () => { const generateUsername = (usernameTemplate?: string | null) => { const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-"; - const randomUsername = `inf-${customAlphabet(charset, 32)()}`; // Username must start with an ascii letter, so we prepend the username with "inf-" + const randomUsername = `inf-${customAlphabet(charset, 32)()}`; if (!usernameTemplate) return randomUsername; return handlebars.compile(usernameTemplate)({ diff --git a/backend/src/ee/services/dynamic-secret/providers/mongo-db.ts b/backend/src/ee/services/dynamic-secret/providers/mongo-db.ts index 2af7dcf4e..0a15209e0 100644 --- a/backend/src/ee/services/dynamic-secret/providers/mongo-db.ts +++ b/backend/src/ee/services/dynamic-secret/providers/mongo-db.ts @@ -14,7 +14,7 @@ const generatePassword = (size = 48) => { }; const generateUsername = (usernameTemplate?: string | null) => { - const randomUsername = alphaNumericNanoId(32); // Username must start with an ascii letter, so we prepend the username with "inf-" + const randomUsername = alphaNumericNanoId(32); if (!usernameTemplate) return randomUsername; return handlebars.compile(usernameTemplate)({ diff --git a/docs/documentation/platform/dynamic-secrets/aws-elasticache.mdx b/docs/documentation/platform/dynamic-secrets/aws-elasticache.mdx index de8278a8f..66c4c706a 100644 --- a/docs/documentation/platform/dynamic-secrets/aws-elasticache.mdx +++ b/docs/documentation/platform/dynamic-secrets/aws-elasticache.mdx @@ -103,7 +103,7 @@ The Infisical AWS ElastiCache dynamic secret allows you to generate AWS ElastiCa - `{{unixTimestamp}}`: Current Unix timestamp - If you want to provide specific privileges for the generated dynamic credentials, you can modify the ElastiCache statement to your needs. This is useful if you want to only give access to a specific table(s). + If you want to provide specific privileges for the generated dynamic credentials, you can modify the ElastiCache statement to your needs. This is useful if you want to only give access to a specific resource. diff --git a/docs/documentation/platform/dynamic-secrets/mongo-atlas.mdx b/docs/documentation/platform/dynamic-secrets/mongo-atlas.mdx index 983078796..5d27d16e2 100644 --- a/docs/documentation/platform/dynamic-secrets/mongo-atlas.mdx +++ b/docs/documentation/platform/dynamic-secrets/mongo-atlas.mdx @@ -7,7 +7,7 @@ The Infisical Mongo Atlas dynamic secret allows you to generate Mongo Atlas Data ## Prerequisite -Create a project scopped API Key with the required permission in your Mongo Atlas following the [official doc](https://www.mongodb.com/docs/atlas/configure-api-access/#grant-programmatic-access-to-a-project). +Create a project scoped API Key with the required permission in your Mongo Atlas following the [official doc](https://www.mongodb.com/docs/atlas/configure-api-access/#grant-programmatic-access-to-a-project). The API Key must have permission to manage users in the project. @@ -83,7 +83,7 @@ Create a project scopped API Key with the required permission in your Mongo Atla After submitting the form, you will see a dynamic secret created in the dashboard. - If this step fails, you may have to add the CA certficate. + If this step fails, you may have to add the CA certificate. ![Dynamic Secret](../../../images/platform/dynamic-secrets/dynamic-secret.png) @@ -102,7 +102,7 @@ Create a project scopped API Key with the required permission in your Mongo Atla ![Provision Lease](/images/platform/dynamic-secrets/provision-lease.png) - Ensure that the TTL for the lease fall within the maximum TTL defined when configuring the dynamic secret. + Ensure that the TTL for the lease falls within the maximum TTL defined when configuring the dynamic secret. diff --git a/docs/documentation/platform/dynamic-secrets/rabbit-mq.mdx b/docs/documentation/platform/dynamic-secrets/rabbit-mq.mdx index 4ec7a62ab..09c04e61b 100644 --- a/docs/documentation/platform/dynamic-secrets/rabbit-mq.mdx +++ b/docs/documentation/platform/dynamic-secrets/rabbit-mq.mdx @@ -65,9 +65,6 @@ The port that the RabbitMQ management plugin is listening on. This is `15672` by leases. - - A CA may be required if your DB requires it for incoming connections. This is often the case when connecting to a managed service. - Specifies a template for generating usernames. This field allows customization of how usernames are automatically created. diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SapAseInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SapAseInputForm.tsx index 2cb80c0ef..e5caa5214 100644 --- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SapAseInputForm.tsx +++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/SapAseInputForm.tsx @@ -277,7 +277,6 @@ sp_droplogin '{{username}}';` label="Username Template" isError={Boolean(error?.message)} errorText={error?.message} - tooltipText="randomUsername: Function used to generate random username" >