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
add validation rules for LDAP, SQL and linux
Matheus Nogueiraedc656cc6ae2
diff --git a/backend/src/ee/services/secret-rotation-v2/ldap-password/ldap-password-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/ldap-password/ldap-password-rotation-fns.tsindex 3f0a7c132a..ee12230f88 100644--- a/backend/src/ee/services/secret-rotation-v2/ldap-password/ldap-password-rotation-fns.ts+++ b/backend/src/ee/services/secret-rotation-v2/ldap-password/ldap-password-rotation-fns.ts@@ -24,6 +24,8 @@ import {TLdapConnection} from "@app/services/app-connection/ldap";+import { generatePasswordWithConstraints } from "@app/services/secret-validation-rule/secret-validation-rule-password-generator";+import { generatePassword } from "../shared/utils";import {LdapPasswordRotationMethod,@@ -110,7 +112,7 @@ export const ldapPasswordRotationFactory: TRotationFactory<TLdapPasswordRotationWithConnection,TLdapPasswordRotationGeneratedCredentials,TLdapPasswordRotationInput["temporaryParameters"]-> = (secretRotation, appConnectionDAL, kmsService, gatewayService, gatewayV2Service, gatewayPoolService) => {+> = (secretRotation, appConnectionDAL, kmsService, gatewayService, gatewayV2Service, gatewayPoolService, passwordValidationContext) => {const { connection, parameters, secretsMapping, activeIndex } = secretRotation;const { dn, passwordRequirements } = parameters;@@ -148,7 +150,9 @@ export const ldapPasswordRotationFactory: TRotationFactory<if (!credentials.url.startsWith("ldaps")) throw new Error("Password Rotation requires an LDAPS connection");const isConnectionRotation = credentials.dn === dn;- const password = generatePassword(passwordRequirements);+ const password = passwordValidationContext?.constraints?.length+ ? generatePasswordWithConstraints(passwordValidationContext.constraints)+ : generatePassword(passwordRequirements);const rotationContext = {targetDn: dn,diff --git a/backend/src/ee/services/secret-rotation-v2/unix-linux-local-account-rotation/unix-linux-local-account-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/unix-linux-local-account-rotation/unix-linux-local-account-rotation-fns.tsindex 03d29cf419..dff40a0633 100644--- a/backend/src/ee/services/secret-rotation-v2/unix-linux-local-account-rotation/unix-linux-local-account-rotation-fns.ts+++ b/backend/src/ee/services/secret-rotation-v2/unix-linux-local-account-rotation/unix-linux-local-account-rotation-fns.ts@@ -17,6 +17,7 @@ import {TSshConnectionConfig} from "@app/services/app-connection/ssh";+import { generatePasswordWithConstraints } from "@app/services/secret-validation-rule/secret-validation-rule-password-generator";import { generatePassword } from "../shared/utils";import { UnixLinuxLocalAccountRotationMethod } from "./unix-linux-local-account-rotation-schemas";import {@@ -307,7 +308,7 @@ export const unixLinuxLocalAccountRotationFactory: TRotationFactory<TUnixLinuxLocalAccountRotationWithConnection,TUnixLinuxLocalAccountRotationGeneratedCredentials,TUnixLinuxLocalAccountRotationInput["temporaryParameters"]-> = (secretRotation, appConnectionDAL, kmsService, _gatewayService, gatewayV2Service, gatewayPoolService) => {+> = (secretRotation, appConnectionDAL, kmsService, _gatewayService, gatewayV2Service, gatewayPoolService, passwordValidationContext) => {const { connection, parameters, secretsMapping, activeIndex } = secretRotation;const {username,@@ -395,7 +396,9 @@ export const unixLinuxLocalAccountRotationFactory: TRotationFactory<const $rotatePassword = async (currentPassword?: string): Promise<{ username: string; password: string }> => {const conn = await getResolvedConnection();const { credentials } = conn;- const newPassword = generatePassword(passwordRequirements);+ const newPassword = passwordValidationContext?.constraints?.length+ ? generatePasswordWithConstraints(passwordValidationContext.constraints)+ : generatePassword(passwordRequirements);const isSelfRotation = rotationMethod === UnixLinuxLocalAccountRotationMethod.LoginAsTarget;if (username === credentials.username)diff --git a/backend/src/services/secret-validation-rule/secret-validation-rule-fns.ts b/backend/src/services/secret-validation-rule/secret-validation-rule-fns.tsindex f438fa2aea..ea78e92d79 100644--- a/backend/src/services/secret-validation-rule/secret-validation-rule-fns.ts+++ b/backend/src/services/secret-validation-rule/secret-validation-rule-fns.ts@@ -448,5 +448,20 @@ export const convertSecretRotationToValidationRuleProvider = (if (type === SecretRotation.PostgresCredentials) {return SecretRotationRuleProvider.PostgresCredentials;}+ if (type === SecretRotation.MySqlCredentials) {+ return SecretRotationRuleProvider.MySqlCredentials;+ }+ if (type === SecretRotation.MsSqlCredentials) {+ return SecretRotationRuleProvider.MsSqlCredentials;+ }+ if (type === SecretRotation.OracleDBCredentials) {+ return SecretRotationRuleProvider.OracleDBCredentials;+ }+ if (type === SecretRotation.UnixLinuxLocalAccount) {+ return SecretRotationRuleProvider.UnixLinuxLocalAccount;+ }+ if (type === SecretRotation.LdapPassword) {+ return SecretRotationRuleProvider.LdapPassword;+ }return null;};diff --git a/backend/src/services/secret-validation-rule/secret-validation-rule-types.ts b/backend/src/services/secret-validation-rule/secret-validation-rule-types.tsindex 7df4cf975c..0dc350a251 100644--- a/backend/src/services/secret-validation-rule/secret-validation-rule-types.ts+++ b/backend/src/services/secret-validation-rule/secret-validation-rule-types.ts@@ -33,7 +33,12 @@ export enum DynamicSecretRuleProvider {// Provider identifiers selectable in secret-rotation rules.// Keep aligned with `SecretRotation` in secret-rotation-v2-enums.ts.export enum SecretRotationRuleProvider {- PostgresCredentials = "postgres-credentials"+ PostgresCredentials = "postgres-credentials",+ MySqlCredentials = "mysql-credentials",+ MsSqlCredentials = "mssql-credentials",+ OracleDBCredentials = "oracledb-credentials",+ UnixLinuxLocalAccount = "unix-linux-local-account",+ LdapPassword = "ldap-password"}export type TConstraint = {diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/LdapPasswordRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/LdapPasswordRotationParametersFields.tsxindex 21aac90b40..ccf020500f 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/LdapPasswordRotationParametersFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/LdapPasswordRotationParametersFields.tsx@@ -2,8 +2,13 @@ import { Controller, useFormContext } from "react-hook-form";import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";import { DEFAULT_PASSWORD_REQUIREMENTS } from "@app/components/secret-rotations-v2/forms/schemas/shared";+import { ValidationRuleOverrideNotice } from "@app/components/secret-validation/ValidationRuleOverrideNotice";import { FormControl, Input, Select, SelectItem } from "@app/components/v2";import { SecretRotation } from "@app/hooks/api/secretRotationsV2";+import {+ SecretRotationRuleProvider,+ SecretValidationRuleType+} from "@app/hooks/api/secretValidationRules";import { LdapPasswordRotationMethod } from "@app/hooks/api/secretRotationsV2/types/ldap-password-rotation";export const LdapPasswordRotationParametersFields = () => {@@ -14,6 +19,8 @@ export const LdapPasswordRotationParametersFields = () => {>();const [id, rotationMethod] = watch(["id", "parameters.rotationMethod"]);+ const environmentSlug = watch("environment")?.slug;+ const secretPath = watch("secretPath");const isUpdate = Boolean(id);return (@@ -127,6 +134,12 @@ export const LdapPasswordRotationParametersFields = () => {)}</div><div className="flex flex-col gap-3">+ <ValidationRuleOverrideNotice+ type={SecretValidationRuleType.SecretRotations}+ provider={SecretRotationRuleProvider.LdapPassword}+ environmentSlug={environmentSlug}+ secretPath={secretPath}+ /><div className="w-full border-b border-mineshaft-600"><span className="text-sm text-mineshaft-300">Password Requirements</span></div>diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/UnixLinuxLocalAccountRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/UnixLinuxLocalAccountRotationParametersFields.tsxindex af53a4afef..15bb7b8bda 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/UnixLinuxLocalAccountRotationParametersFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/UnixLinuxLocalAccountRotationParametersFields.tsx@@ -2,8 +2,13 @@ import { Controller, useFormContext } from "react-hook-form";import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";import { DEFAULT_PASSWORD_REQUIREMENTS } from "@app/components/secret-rotations-v2/forms/schemas/shared";+import { ValidationRuleOverrideNotice } from "@app/components/secret-validation/ValidationRuleOverrideNotice";import { Checkbox, FormControl, Input, Select, SelectItem } from "@app/components/v2";import { SecretRotation } from "@app/hooks/api/secretRotationsV2";+import {+ SecretRotationRuleProvider,+ SecretValidationRuleType+} from "@app/hooks/api/secretValidationRules";import { UnixLinuxLocalAccountRotationMethod } from "@app/hooks/api/secretRotationsV2/types/unix-linux-local-account-rotation";export const UnixLinuxLocalAccountRotationParametersFields = () => {@@ -14,6 +19,8 @@ export const UnixLinuxLocalAccountRotationParametersFields = () => {>();const id = watch("id");+ const environmentSlug = watch("environment")?.slug;+ const secretPath = watch("secretPath");const rotationMethod = watch("parameters.rotationMethod",UnixLinuxLocalAccountRotationMethod.LoginAsTarget@@ -151,6 +158,12 @@ export const UnixLinuxLocalAccountRotationParametersFields = () => {)}</div><div className="flex flex-col gap-3">+ <ValidationRuleOverrideNotice+ type={SecretValidationRuleType.SecretRotations}+ provider={SecretRotationRuleProvider.UnixLinuxLocalAccount}+ environmentSlug={environmentSlug}+ secretPath={secretPath}+ /><div className="w-full border-b border-mineshaft-600"><span className="text-sm text-mineshaft-300">Password Requirements</span></div>diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/shared/SqlCredentialsRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/shared/SqlCredentialsRotationParametersFields.tsxindex 4474de14c1..cb3bb1ebe9 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/shared/SqlCredentialsRotationParametersFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/shared/SqlCredentialsRotationParametersFields.tsx@@ -26,6 +26,7 @@ export const SqlCredentialsRotationParametersFields = () => {TSecretRotationV2Form & {type:| SecretRotation.PostgresCredentials+ | SecretRotation.MySqlCredentials| SecretRotation.MsSqlCredentials| SecretRotation.OracleDBCredentials;}@@ -162,6 +163,30 @@ export const SqlCredentialsRotationParametersFields = () => {secretPath={secretPath}/>)}+ {type === SecretRotation.MySqlCredentials && (+ <ValidationRuleOverrideNotice+ type={SecretValidationRuleType.SecretRotations}+ provider={SecretRotationRuleProvider.MySqlCredentials}+ environmentSlug={environmentSlug}+ secretPath={secretPath}+ />+ )}+ {type === SecretRotation.MsSqlCredentials && (+ <ValidationRuleOverrideNotice+ type={SecretValidationRuleType.SecretRotations}+ provider={SecretRotationRuleProvider.MsSqlCredentials}+ environmentSlug={environmentSlug}+ secretPath={secretPath}+ />+ )}+ {type === SecretRotation.OracleDBCredentials && (+ <ValidationRuleOverrideNotice+ type={SecretValidationRuleType.SecretRotations}+ provider={SecretRotationRuleProvider.OracleDBCredentials}+ environmentSlug={environmentSlug}+ secretPath={secretPath}+ />+ )}<div className="w-full border-b border-mineshaft-600"><span className="text-sm text-mineshaft-300">Password Requirements</span></div>diff --git a/frontend/src/hooks/api/secretValidationRules/types.ts b/frontend/src/hooks/api/secretValidationRules/types.tsindex 6b86086442..0273641b11 100644--- a/frontend/src/hooks/api/secretValidationRules/types.ts+++ b/frontend/src/hooks/api/secretValidationRules/types.ts@@ -29,7 +29,12 @@ export enum DynamicSecretRuleProvider {// Provider identifiers selectable in secret-rotation rules.// Mirror of backend `SecretRotationRuleProvider`.export enum SecretRotationRuleProvider {- PostgresCredentials = "postgres-credentials"+ PostgresCredentials = "postgres-credentials",+ MySqlCredentials = "mysql-credentials",+ MsSqlCredentials = "mssql-credentials",+ OracleDBCredentials = "oracledb-credentials",+ UnixLinuxLocalAccount = "unix-linux-local-account",+ LdapPassword = "ldap-password"}export type TConstraint = {diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesSection/SecretValidationRulesSection.utils.ts b/frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesSection/SecretValidationRulesSection.utils.tsindex eebff8fcb8..2e3d80ef74 100644--- a/frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesSection/SecretValidationRulesSection.utils.ts+++ b/frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesSection/SecretValidationRulesSection.utils.ts@@ -2,9 +2,11 @@ import {DatabaseIcon,HashIcon,HistoryIcon,+ KeyRoundIcon,LayersIcon,LucideIcon,RulerIcon,+ TerminalIcon,TextCursorInputIcon,TextIcon} from "lucide-react";@@ -121,7 +123,12 @@ export enum DynamicSecretRuleProvider {// Provider identifiers selectable in secret-rotation rules. Keep aligned with// backend `SecretRotationRuleProvider`.export enum SecretRotationRuleProvider {- PostgresCredentials = "postgres-credentials"+ PostgresCredentials = "postgres-credentials",+ MySqlCredentials = "mysql-credentials",+ MsSqlCredentials = "mssql-credentials",+ OracleDBCredentials = "oracledb-credentials",+ UnixLinuxLocalAccount = "unix-linux-local-account",+ LdapPassword = "ldap-password"}export type TProviderOption<T extends string> = {@@ -140,6 +147,31 @@ export const SECRET_ROTATION_PROVIDER_OPTIONS: TProviderOption<SecretRotationRulvalue: SecretRotationRuleProvider.PostgresCredentials,label: "PostgreSQL Credentials",icon: DatabaseIcon+ },+ {+ value: SecretRotationRuleProvider.MySqlCredentials,+ label: "MySQL Credentials",+ icon: DatabaseIcon+ },+ {+ value: SecretRotationRuleProvider.MsSqlCredentials,+ label: "MsSQL Credentials",+ icon: DatabaseIcon+ },+ {+ value: SecretRotationRuleProvider.OracleDBCredentials,+ label: "OracleDB Credentials",+ icon: DatabaseIcon+ },+ {+ value: SecretRotationRuleProvider.UnixLinuxLocalAccount,+ label: "Unix/Linux Local Account",+ icon: TerminalIcon+ },+ {+ value: SecretRotationRuleProvider.LdapPassword,+ label: "LDAP Password",+ icon: KeyRoundIcon}];