Skip to content

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

requested changes

Danielbc41d55f287e
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesSection/SecretValidationRulesSection.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesSection/SecretValidationRulesSection.tsx
index 108be1df52..c9479642ef 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesSection/SecretValidationRulesSection.tsx
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesSection/SecretValidationRulesSection.tsx
@@ -590,7 +590,10 @@ export const SecretValidationRulesSection = () => {
<Card className="mb-6">
<CardHeader>
<CardTitle>Secret Validation Rules</CardTitle>
- <CardDescription>Define validation constraints for secret keys and values</CardDescription>
+ <CardDescription>
+ Define constraints applied to static secret keys and values on write, and to the passwords
+ generated for dynamic secrets and secret rotations.
+ </CardDescription>
<CardAction>
<ProjectPermissionCan I={ProjectPermissionActions.Edit} a={ProjectPermissionSub.Settings}>
{(isAllowed) => (
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.ts
index 75ab4ba434..eebff8fcb8 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
@@ -167,17 +167,42 @@ export const constraintSchema = z
message: "Value is required",
path: ["value"]
})
- .refine(
- (c) => {
- if (c.type !== ConstraintType.PreventValueReuse) return true;
+ .superRefine((c, ctx) => {
+ if (c.type === ConstraintType.PreventValueReuse) {
const num = Number(c.value);
- return Number.isInteger(num) && num >= 1 && num <= MAX_PREVENT_VALUE_REUSE_VERSIONS;
- },
- {
- message: `Must be a number between 1 and ${MAX_PREVENT_VALUE_REUSE_VERSIONS}`,
- path: ["value"]
+
+ const isAboveMaxVersions =
+ Number.isInteger(num) && (num < 1 || num > MAX_PREVENT_VALUE_REUSE_VERSIONS);
+
+ if (isAboveMaxVersions) {
+ ctx.addIssue({
+ path: ["value"],
+ code: z.ZodIssueCode.custom,
+ message: `Must be a number between 1 and ${MAX_PREVENT_VALUE_REUSE_VERSIONS}`
+ });
+ }
+ } else if (c.type === ConstraintType.MinLength) {
+ const num = Number(c.value);
+
+ if (num <= 0) {
+ ctx.addIssue({
+ path: ["value"],
+ code: z.ZodIssueCode.custom,
+ message: "Minimum length must be a at least 1"
+ });
+ }
+ } else if (c.type === ConstraintType.MaxLength) {
+ const num = Number(c.value);
+
+ if (num <= 0) {
+ ctx.addIssue({
+ path: ["value"],
+ code: z.ZodIssueCode.custom,
+ message: "Maximum length must be a at least 1"
+ });
+ }
}
- );
+ });
const duplicateConstraintRefinement = (
constraints: { type: ConstraintType; appliesTo: ConstraintTarget }[]