Skip to content

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

checkpoint

Daniel Hougaard5d5ce62ce3a0
diff --git a/backend/src/@types/fastify.d.ts b/backend/src/@types/fastify.d.ts
index 546004f613..1990c6c3c0 100644
--- a/backend/src/@types/fastify.d.ts
+++ b/backend/src/@types/fastify.d.ts
@@ -140,6 +140,7 @@ import { TSecretReplicationServiceFactory } from "@app/services/secret-replicati
import { TSecretSharingServiceFactory } from "@app/services/secret-sharing/secret-sharing-service";
import { TSecretSyncServiceFactory } from "@app/services/secret-sync/secret-sync-service";
import { TSecretTagServiceFactory } from "@app/services/secret-tag/secret-tag-service";
+import { TSecretValidationRuleServiceFactory } from "@app/services/secret-validation-rule/secret-validation-rule-service";
import { TServiceTokenServiceFactory } from "@app/services/service-token/service-token-service";
import { TSlackServiceFactory } from "@app/services/slack/slack-service";
import { TSuperAdminServiceFactory } from "@app/services/super-admin/super-admin-service";
@@ -271,6 +272,7 @@ declare module "fastify" {
secret: TSecretServiceFactory;
secretReplication: TSecretReplicationServiceFactory;
secretTag: TSecretTagServiceFactory;
+ secretValidationRule: TSecretValidationRuleServiceFactory;
secretImport: TSecretImportServiceFactory;
projectBot: TProjectBotServiceFactory;
folder: TSecretFolderServiceFactory;
diff --git a/backend/src/@types/knex.d.ts b/backend/src/@types/knex.d.ts
index c7fb887b69..947797c955 100644
--- a/backend/src/@types/knex.d.ts
+++ b/backend/src/@types/knex.d.ts
@@ -720,6 +720,11 @@ import {
TSecretReminderRecipientsInsert,
TSecretReminderRecipientsUpdate
} from "@app/db/schemas/secret-reminder-recipients";
+import {
+ TSecretValidationRules,
+ TSecretValidationRulesInsert,
+ TSecretValidationRulesUpdate
+} from "@app/db/schemas/secret-validation-rules";
import {
TUserNotifications,
TUserNotificationsInsert,
@@ -1708,5 +1713,10 @@ declare module "knex/types/tables" {
TCertificateCleanupConfigsInsert,
TCertificateCleanupConfigsUpdate
>;
+ [TableName.SecretValidationRule]: KnexOriginal.CompositeTableType<
+ TSecretValidationRules,
+ TSecretValidationRulesInsert,
+ TSecretValidationRulesUpdate
+ >;
}
}
diff --git a/backend/src/db/migrations/20260319204352_secret-validation-rules.ts b/backend/src/db/migrations/20260319204352_secret-validation-rules.ts
new file mode 100644
index 0000000000..edb0de984d
--- /dev/null
+++ b/backend/src/db/migrations/20260319204352_secret-validation-rules.ts
@@ -0,0 +1,33 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils";
+
+export async function up(knex: Knex): Promise<void> {
+ if (!(await knex.schema.hasTable(TableName.SecretValidationRule))) {
+ await knex.schema.createTable(TableName.SecretValidationRule, (tb) => {
+ tb.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
+ tb.string("name").notNullable();
+ tb.string("description").nullable();
+ tb.string("projectId").notNullable();
+ tb.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE");
+ tb.uuid("envId").notNullable();
+ tb.foreign("envId").references("id").inTable(TableName.Environment).onDelete("CASCADE");
+ tb.string("secretPath").notNullable().defaultTo("/");
+ tb.string("type").notNullable();
+ tb.jsonb("inputs").notNullable();
+ tb.boolean("isActive").notNullable().defaultTo(true);
+ tb.index("projectId");
+ tb.index("envId");
+ tb.index("secretPath");
+ tb.timestamps(true, true, true);
+ });
+
+ await createOnUpdateTrigger(knex, TableName.SecretValidationRule);
+ }
+}
+
+export async function down(knex: Knex): Promise<void> {
+ await dropOnUpdateTrigger(knex, TableName.SecretValidationRule);
+ await knex.schema.dropTableIfExists(TableName.SecretValidationRule);
+}
diff --git a/backend/src/db/schemas/index.ts b/backend/src/db/schemas/index.ts
index 0a34a8972a..6e4f04e497 100644
--- a/backend/src/db/schemas/index.ts
+++ b/backend/src/db/schemas/index.ts
@@ -204,6 +204,7 @@ export * from "./secret-syncs";
export * from "./secret-tag-junction";
export * from "./secret-tags";
export * from "./secret-v2-tag-junction";
+export * from "./secret-validation-rules";
export * from "./secret-version-tag-junction";
export * from "./secret-version-v2-tag-junction";
export * from "./secret-versions";
diff --git a/backend/src/db/schemas/models.ts b/backend/src/db/schemas/models.ts
index 360598111b..a2233d5dfb 100644
--- a/backend/src/db/schemas/models.ts
+++ b/backend/src/db/schemas/models.ts
@@ -272,7 +272,8 @@ export enum TableName {
ApprovalRequestGrants = "approval_request_grants",
QueueJobs = "queue_jobs",
- CaSigningConfig = "ca_signing_configs"
+ CaSigningConfig = "ca_signing_configs",
+ SecretValidationRule = "secret_validation_rules"
}
export type TImmutableDBKeys = "id" | "createdAt" | "updatedAt" | "commitId";
diff --git a/backend/src/db/schemas/secret-validation-rules.ts b/backend/src/db/schemas/secret-validation-rules.ts
new file mode 100644
index 0000000000..35ff5ab4bf
--- /dev/null
+++ b/backend/src/db/schemas/secret-validation-rules.ts
@@ -0,0 +1,26 @@
+// Code generated by automation script, DO NOT EDIT.
+// Automated by pulling database and generating zod schema
+// To update. Just run npm run generate:schema
+// Written by akhilmhdh.
+
+import { z } from "zod";
+
+import { TImmutableDBKeys } from "./models";
+
+export const SecretValidationRulesSchema = z.object({
+ id: z.string().uuid(),
+ name: z.string(),
+ description: z.string().nullable().optional(),
+ projectId: z.string(),
+ envId: z.string().uuid(),
+ secretPath: z.string().default("/"),
+ type: z.string(),
+ inputs: z.unknown(),
+ isActive: z.boolean().default(true),
+ createdAt: z.date(),
+ updatedAt: z.date()
+});
+
+export type TSecretValidationRules = z.infer<typeof SecretValidationRulesSchema>;
+export type TSecretValidationRulesInsert = Omit<z.input<typeof SecretValidationRulesSchema>, TImmutableDBKeys>;
+export type TSecretValidationRulesUpdate = Partial<Omit<z.input<typeof SecretValidationRulesSchema>, TImmutableDBKeys>>;
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index adf7a13be7..3c4e570afc 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -416,6 +416,8 @@ import { secretV2BridgeDALFactory } from "@app/services/secret-v2-bridge/secret-
import { secretV2BridgeServiceFactory } from "@app/services/secret-v2-bridge/secret-v2-bridge-service";
import { secretVersionV2BridgeDALFactory } from "@app/services/secret-v2-bridge/secret-version-dal";
import { secretVersionV2TagBridgeDALFactory } from "@app/services/secret-v2-bridge/secret-version-tag-dal";
+import { secretValidationRuleDALFactory } from "@app/services/secret-validation-rule/secret-validation-rule-dal";
+import { secretValidationRuleServiceFactory } from "@app/services/secret-validation-rule/secret-validation-rule-service";
import { serviceTokenDALFactory } from "@app/services/service-token/service-token-dal";
import { serviceTokenServiceFactory } from "@app/services/service-token/service-token-service";
import { projectSlackConfigDALFactory } from "@app/services/slack/project-slack-config-dal";
@@ -508,6 +510,7 @@ export const registerRoutes = async (
const secretDAL = secretDALFactory(db);
const secretTagDAL = secretTagDALFactory(db);
+ const secretValidationRuleDAL = secretValidationRuleDALFactory(db);
const folderDAL = secretFolderDALFactory(db);
const folderVersionDAL = secretFolderVersionDALFactory(db);
const secretImportDAL = secretImportDALFactory(db);
@@ -1564,6 +1567,11 @@ export const registerRoutes = async (
});
const secretTagService = secretTagServiceFactory({ secretTagDAL, permissionService });
+ const secretValidationRuleService = secretValidationRuleServiceFactory({
+ secretValidationRuleDAL,
+ projectEnvDAL,
+ permissionService
+ });
const folderService = secretFolderServiceFactory({
permissionService,
folderDAL,
@@ -2948,6 +2956,7 @@ export const registerRoutes = async (
secret: secretService,
secretReplication: secretReplicationService,
secretTag: secretTagService,
+ secretValidationRule: secretValidationRuleService,
rateLimit: rateLimitService,
folder: folderService,
secretImport: secretImportService,
diff --git a/backend/src/server/routes/v1/index.ts b/backend/src/server/routes/v1/index.ts
index 9583cb911d..8895c70b9b 100644
--- a/backend/src/server/routes/v1/index.ts
+++ b/backend/src/server/routes/v1/index.ts
@@ -74,6 +74,7 @@ import { SECRET_REMINDER_REGISTER_ROUTER_MAP } from "./reminder-routers";
import { registerSecretRequestsRouter } from "./secret-requests-router";
import { registerSecretSharingRouter } from "./secret-sharing-router";
import { registerSecretTagRouter } from "./secret-tag-router";
+import { registerSecretValidationRuleRouter } from "./secret-validation-rule-router";
import { registerSlackRouter } from "./slack-router";
import { registerSsoRouter } from "./sso-router";
import { registerUpgradePathRouter } from "./upgrade-path-router";
@@ -154,6 +155,7 @@ export const registerV1Routes = async (server: FastifyZodProvider) => {
await projectRouter.register(registerProjectIdentityRouter);
await projectRouter.register(registerProjectEnvRouter);
await projectRouter.register(registerSecretTagRouter);
+ await projectRouter.register(registerSecretValidationRuleRouter);
await projectRouter.register(registerGroupProjectRouter);
await projectRouter.register(registerDeprecatedIdentityProjectMembershipRouter);
},
diff --git a/backend/src/server/routes/v1/secret-validation-rule-router.ts b/backend/src/server/routes/v1/secret-validation-rule-router.ts
new file mode 100644
index 0000000000..db4a6d0cbf
--- /dev/null
+++ b/backend/src/server/routes/v1/secret-validation-rule-router.ts
@@ -0,0 +1,156 @@
+import { z } from "zod";
+
+import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
+import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
+import { AuthMode } from "@app/services/auth/auth-type";
+import {
+ SecretValidationRuleInputSchema,
+ SecretValidationRuleResponseSchema,
+ staticSecretsInputsSchema
+} from "@app/services/secret-validation-rule/secret-validation-rule-schemas";
+import { SecretValidationRuleType } from "@app/services/secret-validation-rule/secret-validation-rule-types";
+
+export const registerSecretValidationRuleRouter = async (server: FastifyZodProvider) => {
+ // List all rules for a project
+ server.route({
+ method: "GET",
+ url: "/:projectId/secret-validation-rules",
+ config: { rateLimit: readLimit },
+ schema: {
+ hide: false,
+ params: z.object({
+ projectId: z.string().trim()
+ }),
+ response: {
+ 200: z.object({
+ rules: SecretValidationRuleResponseSchema.array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const rules = await server.services.secretValidationRule.listByProjectId({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.projectId
+ });
+ return { rules };
+ }
+ });
+
+ // Create a rule
+ server.route({
+ method: "POST",
+ url: "/:projectId/secret-validation-rules",
+ config: { rateLimit: writeLimit },
+ schema: {
+ hide: false,
+ params: z.object({
+ projectId: z.string().trim()
+ }),
+ body: z.object({
+ name: z.string().trim().min(1).max(100),
+ description: z.string().trim().max(500).nullable().optional(),
+ environmentSlug: z.string().trim().min(1),
+ secretPath: z.string().trim().default("/"),
+ rule: SecretValidationRuleInputSchema
+ }),
+ response: {
+ 200: z.object({
+ rule: SecretValidationRuleResponseSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const rule = await server.services.secretValidationRule.createRule({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.projectId,
+ name: req.body.name,
+ description: req.body.description,
+ environmentSlug: req.body.environmentSlug,
+ secretPath: req.body.secretPath,
+ type: req.body.rule.type,
+ inputs: req.body.rule.inputs
+ });
+ return { rule };
+ }
+ });
+
+ // Update a rule
+ server.route({
+ method: "PATCH",
+ url: "/:projectId/secret-validation-rules/:ruleId",
+ config: { rateLimit: writeLimit },
+ schema: {
+ hide: false,
+ params: z.object({
+ projectId: z.string().trim(),
+ ruleId: z.string().uuid()
+ }),
+ body: z.object({
+ name: z.string().trim().min(1).max(100).optional(),
+ description: z.string().trim().max(500).nullable().optional(),
+ environmentSlug: z.string().trim().min(1).optional(),
+ secretPath: z.string().trim().optional(),
+ type: z.nativeEnum(SecretValidationRuleType).optional(),
+ inputs: staticSecretsInputsSchema.optional(),
+ isActive: z.boolean().optional()
+ }),
+ response: {
+ 200: z.object({
+ rule: SecretValidationRuleResponseSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const rule = await server.services.secretValidationRule.updateRule({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.projectId,
+ ruleId: req.params.ruleId,
+ ...req.body
+ });
+ return { rule };
+ }
+ });
+
+ // Delete a rule
+ server.route({
+ method: "DELETE",
+ url: "/:projectId/secret-validation-rules/:ruleId",
+ config: { rateLimit: writeLimit },
+ schema: {
+ hide: false,
+ params: z.object({
+ projectId: z.string().trim(),
+ ruleId: z.string().uuid()
+ }),
+ response: {
+ 200: z.object({
+ rule: SecretValidationRuleResponseSchema
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const rule = await server.services.secretValidationRule.deleteRule({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ projectId: req.params.projectId,
+ ruleId: req.params.ruleId
+ });
+ return { rule };
+ }
+ });
+};
diff --git a/backend/src/services/secret-validation-rule/index.ts b/backend/src/services/secret-validation-rule/index.ts
new file mode 100644
index 0000000000..6dd3af636b
--- /dev/null
+++ b/backend/src/services/secret-validation-rule/index.ts
@@ -0,0 +1,4 @@
+export type { TSecretValidationRuleDALFactory } from "./secret-validation-rule-dal";
+export { secretValidationRuleDALFactory } from "./secret-validation-rule-dal";
+export type { TSecretValidationRuleServiceFactory } from "./secret-validation-rule-service";
+export { secretValidationRuleServiceFactory } from "./secret-validation-rule-service";
diff --git a/backend/src/services/secret-validation-rule/secret-validation-rule-dal.ts b/backend/src/services/secret-validation-rule/secret-validation-rule-dal.ts
new file mode 100644
index 0000000000..53e2282a03
--- /dev/null
+++ b/backend/src/services/secret-validation-rule/secret-validation-rule-dal.ts
@@ -0,0 +1,11 @@
+import { TDbClient } from "@app/db";
+import { TableName } from "@app/db/schemas";
+import { ormify } from "@app/lib/knex";
+
+export type TSecretValidationRuleDALFactory = ReturnType<typeof secretValidationRuleDALFactory>;
+
+export const secretValidationRuleDALFactory = (db: TDbClient) => {
+ const orm = ormify(db, TableName.SecretValidationRule);
+
+ return orm;
+};
diff --git a/backend/src/services/secret-validation-rule/secret-validation-rule-schemas.ts b/backend/src/services/secret-validation-rule/secret-validation-rule-schemas.ts
new file mode 100644
index 0000000000..007438e48f
--- /dev/null
+++ b/backend/src/services/secret-validation-rule/secret-validation-rule-schemas.ts
@@ -0,0 +1,43 @@
+import { z } from "zod";
+
+import { SecretValidationRulesSchema } from "@app/db/schemas";
+
+import {
+ ConstraintTarget,
+ ConstraintType,
+ SecretValidationRuleType,
+ TSecretValidationRuleInputs
+} from "./secret-validation-rule-types";
+
+export const constraintSchema = z.object({
+ type: z.nativeEnum(ConstraintType),
+ appliesTo: z.nativeEnum(ConstraintTarget),
+ value: z.string().min(1)
+});
+
+export const staticSecretsInputsSchema = z.object({
+ constraints: z.array(constraintSchema).min(1)
+});
+
+// Discriminated union for create/update request bodies
+export const SecretValidationRuleInputSchema = z.discriminatedUnion("type", [
+ z.object({ type: z.literal(SecretValidationRuleType.StaticSecrets), inputs: staticSecretsInputsSchema })
+]);
+
+// Map of type → inputs schema, used for runtime parsing
+const inputsSchemaMap: Record<SecretValidationRuleType, z.ZodSchema<TSecretValidationRuleInputs>> = {
+ [SecretValidationRuleType.StaticSecrets]: staticSecretsInputsSchema
+};
+
+export const parseSecretValidationRuleInputs = (type: string, inputs: unknown) => {
+ const schema = inputsSchemaMap[type as SecretValidationRuleType];
+ if (!schema) {
+ throw new Error(`Unknown secret validation rule type: ${type}`);
+ }
+ return schema.parse(inputs);
+};
+
+export const SecretValidationRuleResponseSchema = SecretValidationRulesSchema.omit({
+ type: true,
+ inputs: true
+}).and(SecretValidationRuleInputSchema);
diff --git a/backend/src/services/secret-validation-rule/secret-validation-rule-service.ts b/backend/src/services/secret-validation-rule/secret-validation-rule-service.ts
new file mode 100644
index 0000000000..8c3ad9f553
--- /dev/null
+++ b/backend/src/services/secret-validation-rule/secret-validation-rule-service.ts
@@ -0,0 +1,190 @@
+import { ForbiddenError } from "@casl/ability";
+
+import { ActionProjectType } from "@app/db/schemas";
+import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
+import { ProjectPermissionActions, ProjectPermissionSub } from "@app/ee/services/permission/project-permission";
+import { NotFoundError } from "@app/lib/errors";
+import { TProjectEnvDALFactory } from "@app/services/project-env/project-env-dal";
+
+import { TSecretValidationRuleDALFactory } from "./secret-validation-rule-dal";
+import { parseSecretValidationRuleInputs } from "./secret-validation-rule-schemas";
+import {
+ SecretValidationRuleType,
+ TCreateSecretValidationRuleDTO,
+ TDeleteSecretValidationRuleDTO,
+ TListSecretValidationRulesDTO,
+ TUpdateSecretValidationRuleDTO
+} from "./secret-validation-rule-types";
+
+type TSecretValidationRuleServiceFactoryDep = {
+ secretValidationRuleDAL: TSecretValidationRuleDALFactory;
+ projectEnvDAL: Pick<TProjectEnvDALFactory, "findOne">;
+ permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;
+};
+
+export type TSecretValidationRuleServiceFactory = ReturnType<typeof secretValidationRuleServiceFactory>;
+
+export const secretValidationRuleServiceFactory = ({
+ secretValidationRuleDAL,
+ projectEnvDAL,
+ permissionService
+}: TSecretValidationRuleServiceFactoryDep) => {
+ const listByProjectId = async ({
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId,
+ projectId
+ }: TListSecretValidationRulesDTO) => {
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.SecretManager
+ });
+ ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Settings);
+
+ const rules = await secretValidationRuleDAL.find({ projectId });
+
+ return (rules || []).map((rule) => ({
+ ...rule,
+ type: rule.type as SecretValidationRuleType,
+ inputs: parseSecretValidationRuleInputs(rule.type, rule.inputs)
+ }));
+ };
+
+ const createRule = async ({
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId,
+ projectId,
+ name,
+ description,
+ environmentSlug,
+ secretPath,
+ type,
+ inputs
+ }: TCreateSecretValidationRuleDTO) => {
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.SecretManager
+ });
+ ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Settings);
+
+ const env = await projectEnvDAL.findOne({ projectId, slug: environmentSlug });
+ if (!env) {
+ throw new NotFoundError({ message: `Environment with slug '${environmentSlug}' not found in project` });
+ }
+
+ const parsedInputs = parseSecretValidationRuleInputs(type, inputs);
+
+ const rule = await secretValidationRuleDAL.create({
+ name,
+ description,
+ projectId,
+ envId: env.id,
+ secretPath,
+ type,
+ inputs: parsedInputs
+ });
+
+ return { ...rule, type: rule.type as SecretValidationRuleType, inputs: parsedInputs };
+ };
+
+ const updateRule = async ({
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId,
+ projectId,
+ ruleId,
+ environmentSlug,
+ inputs,
+ ...dto
+ }: TUpdateSecretValidationRuleDTO) => {
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.SecretManager
+ });
+ ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Settings);
+
+ const existingRule = await secretValidationRuleDAL.findById(ruleId);
+ if (!existingRule) {
+ throw new NotFoundError({ message: `Secret validation rule with ID ${ruleId} not found` });
+ }
+
+ let envId: string | undefined;
+ if (environmentSlug !== undefined) {
+ const env = await projectEnvDAL.findOne({ projectId, slug: environmentSlug });
+ if (!env) {
+ throw new NotFoundError({ message: `Environment with slug '${environmentSlug}' not found in project` });
+ }
+ envId = env.id;
+ }
+
+ const ruleType = dto.type ?? existingRule.type;
+ const ruleInputs = inputs ?? existingRule.inputs;
+ const parsedInputs = parseSecretValidationRuleInputs(ruleType, ruleInputs);
+
+ const updatedRule = await secretValidationRuleDAL.updateById(ruleId, {
+ ...(Boolean(envId) && { envId }),
+ ...(Boolean(inputs) && { inputs: parsedInputs }),
+ ...dto
+ });
+
+ return {
+ ...updatedRule,
+ type: updatedRule.type as SecretValidationRuleType,
+ inputs: parseSecretValidationRuleInputs(updatedRule.type, updatedRule.inputs)
+ };
+ };
+
+ const deleteRule = async ({
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId,
+ projectId,
+ ruleId
+ }: TDeleteSecretValidationRuleDTO) => {
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.SecretManager
+ });
+ ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Settings);
+
+ const existingRule = await secretValidationRuleDAL.findById(ruleId);
+ if (!existingRule) {
+ throw new NotFoundError({ message: `Secret validation rule with ID ${ruleId} not found` });
+ }
+
+ await secretValidationRuleDAL.deleteById(ruleId);
+ return {
+ ...existingRule,
+ type: existingRule.type as SecretValidationRuleType,
+ inputs: parseSecretValidationRuleInputs(existingRule.type, existingRule.inputs)
+ };
+ };
+
+ return {
+ listByProjectId,
+ createRule,
+ updateRule,
+ deleteRule
+ };
+};
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.ts
new file mode 100644
index 0000000000..eeee1a7f92
--- /dev/null
+++ b/backend/src/services/secret-validation-rule/secret-validation-rule-types.ts
@@ -0,0 +1,56 @@
+import { TProjectPermission } from "@app/lib/types";
+
+export enum SecretValidationRuleType {
+ StaticSecrets = "static-secrets"
+}
+
+export enum ConstraintType {
+ MinLength = "min-length",
+ MaxLength = "max-length",
+ RegexPattern = "regex-pattern",
+ RequiredPrefix = "required-prefix",
+ RequiredSuffix = "required-suffix"
+}
+
+export enum ConstraintTarget {
+ SecretKey = "key",
+ SecretValue = "value"
+}
+
+export type TConstraint = {
+ type: ConstraintType;
+ appliesTo: ConstraintTarget;
+ value: string;
+};
+
+export type TStaticSecretsInputs = {
+ constraints: TConstraint[];
+};
+
+export type TSecretValidationRuleInputs = TStaticSecretsInputs;
+
+export type TCreateSecretValidationRuleDTO = {
+ name: string;
+ description?: string | null;
+ environmentSlug: string;
+ secretPath: string;
+ type: SecretValidationRuleType;
+ inputs: TSecretValidationRuleInputs;
+} & TProjectPermission;
+
+export type TUpdateSecretValidationRuleDTO = {
+ ruleId: string;
+ name?: string;
+ description?: string | null;
+ environmentSlug?: string;
+ secretPath?: string;
+ type?: SecretValidationRuleType;
+ inputs?: TSecretValidationRuleInputs;
+ isActive?: boolean;
+} & TProjectPermission;
+
+export type TDeleteSecretValidationRuleDTO = {
+ ruleId: string;
+} & TProjectPermission;
+
+export type TListSecretValidationRulesDTO = TProjectPermission;
diff --git a/frontend/src/hooks/api/index.tsx b/frontend/src/hooks/api/index.tsx
index 2a25f78a1e..8bbaf3567c 100644
--- a/frontend/src/hooks/api/index.tsx
+++ b/frontend/src/hooks/api/index.tsx
@@ -58,6 +58,7 @@ export * from "./secretRotation";
export * from "./secrets";
export * from "./secretSharing";
export * from "./secretSnapshots";
+export * from "./secretValidationRules";
export * from "./serverDetails";
export * from "./serviceTokens";
export * from "./sshCa";
diff --git a/frontend/src/hooks/api/secretValidationRules/index.ts b/frontend/src/hooks/api/secretValidationRules/index.ts
new file mode 100644
index 0000000000..6e26f65c67
--- /dev/null
+++ b/frontend/src/hooks/api/secretValidationRules/index.ts
@@ -0,0 +1,12 @@
+export {
+ useCreateSecretValidationRule,
+ useDeleteSecretValidationRule,
+ useUpdateSecretValidationRule
+} from "./mutations";
+export { useListSecretValidationRules } from "./queries";
+export type {
+ TCreateSecretValidationRuleDTO,
+ TDeleteSecretValidationRuleDTO,
+ TSecretValidationRule,
+ TUpdateSecretValidationRuleDTO
+} from "./types";
diff --git a/frontend/src/hooks/api/secretValidationRules/mutations.tsx b/frontend/src/hooks/api/secretValidationRules/mutations.tsx
new file mode 100644
index 0000000000..bb0228c4e2
--- /dev/null
+++ b/frontend/src/hooks/api/secretValidationRules/mutations.tsx
@@ -0,0 +1,58 @@
+import { useMutation, useQueryClient } from "@tanstack/react-query";
+
+import { apiRequest } from "@app/config/request";
+
+import { secretValidationRuleKeys } from "./queries";
+import {
+ TCreateSecretValidationRuleDTO,
+ TDeleteSecretValidationRuleDTO,
+ TSecretValidationRule,
+ TUpdateSecretValidationRuleDTO
+} from "./types";
+
+export const useCreateSecretValidationRule = () => {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: async ({ projectId, ...body }: TCreateSecretValidationRuleDTO) => {
+ const { data } = await apiRequest.post<{ rule: TSecretValidationRule }>(
+ `/api/v1/${projectId}/secret-validation-rules`,
+ body
+ );
+ return data.rule;
+ },
+ onSuccess: (_, { projectId }) => {
+ queryClient.invalidateQueries({ queryKey: secretValidationRuleKeys.list(projectId) });
+ }
+ });
+};
+
+export const useUpdateSecretValidationRule = () => {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: async ({ projectId, ruleId, ...body }: TUpdateSecretValidationRuleDTO) => {
+ const { data } = await apiRequest.patch<{ rule: TSecretValidationRule }>(
+ `/api/v1/${projectId}/secret-validation-rules/${ruleId}`,
+ body
+ );
+ return data.rule;
+ },
+ onSuccess: (_, { projectId }) => {
+ queryClient.invalidateQueries({ queryKey: secretValidationRuleKeys.list(projectId) });
+ }
+ });
+};
+
+export const useDeleteSecretValidationRule = () => {
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn: async ({ projectId, ruleId }: TDeleteSecretValidationRuleDTO) => {
+ const { data } = await apiRequest.delete<{ rule: TSecretValidationRule }>(
+ `/api/v1/${projectId}/secret-validation-rules/${ruleId}`
+ );
+ return data.rule;
+ },
+ onSuccess: (_, { projectId }) => {
+ queryClient.invalidateQueries({ queryKey: secretValidationRuleKeys.list(projectId) });
+ }
+ });
+};
diff --git a/frontend/src/hooks/api/secretValidationRules/queries.tsx b/frontend/src/hooks/api/secretValidationRules/queries.tsx
new file mode 100644
index 0000000000..77e867dd82
--- /dev/null
+++ b/frontend/src/hooks/api/secretValidationRules/queries.tsx
@@ -0,0 +1,35 @@
+import { useQuery, UseQueryOptions } from "@tanstack/react-query";
+
+import { apiRequest } from "@app/config/request";
+
+import { TListSecretValidationRulesDTO, TSecretValidationRule } from "./types";
+
+export const secretValidationRuleKeys = {
+ all: ["secretValidationRules"] as const,
+ list: (projectId: string) => [...secretValidationRuleKeys.all, "list", projectId] as const
+};
+
+export const useListSecretValidationRules = (
+ { projectId }: TListSecretValidationRulesDTO,
+ options?: Omit<
+ UseQueryOptions<
+ TSecretValidationRule[],
+ unknown,
+ TSecretValidationRule[],
+ ReturnType<typeof secretValidationRuleKeys.list>
+ >,
+ "queryKey" | "queryFn"
+ >
+) => {
+ return useQuery({
+ queryKey: secretValidationRuleKeys.list(projectId),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ rules: TSecretValidationRule[] }>(
+ `/api/v1/${projectId}/secret-validation-rules`
+ );
+ return data.rules;
+ },
+ enabled: Boolean(projectId) && (options?.enabled ?? true),
+ ...options
+ });
+};
diff --git a/frontend/src/hooks/api/secretValidationRules/types.ts b/frontend/src/hooks/api/secretValidationRules/types.ts
new file mode 100644
index 0000000000..301823d4e1
--- /dev/null
+++ b/frontend/src/hooks/api/secretValidationRules/types.ts
@@ -0,0 +1,75 @@
+export enum SecretValidationRuleType {
+ StaticSecrets = "static-secrets"
+}
+
+export enum ConstraintType {
+ MinLength = "min-length",
+ MaxLength = "max-length",
+ RegexPattern = "regex-pattern",
+ RequiredPrefix = "required-prefix",
+ RequiredSuffix = "required-suffix"
+}
+
+export enum ConstraintTarget {
+ SecretKey = "key",
+ SecretValue = "value"
+}
+
+export type TConstraint = {
+ type: ConstraintType;
+ appliesTo: ConstraintTarget;
+ value: string;
+};
+
+export type TStaticSecretsInputs = {
+ constraints: TConstraint[];
+};
+
+export type TSecretValidationRuleInputs = TStaticSecretsInputs;
+
+export type TSecretValidationRule = {
+ id: string;
+ name: string;
+ description?: string | null;
+ projectId: string;
+ envId: string;
+ secretPath: string;
+ type: SecretValidationRuleType;
+ inputs: TSecretValidationRuleInputs;
+ isActive: boolean;
+ createdAt: string;
+ updatedAt: string;
+};
+
+export type TListSecretValidationRulesDTO = {
+ projectId: string;
+};
+
+export type TCreateSecretValidationRuleDTO = {
+ projectId: string;
+ name: string;
+ description?: string | null;
+ environmentSlug: string;
+ secretPath: string;
+ rule: {
+ type: SecretValidationRuleType;
+ inputs: TSecretValidationRuleInputs;
+ };
+};
+
+export type TUpdateSecretValidationRuleDTO = {
+ projectId: string;
+ ruleId: string;
+ name?: string;
+ description?: string | null;
+ environmentSlug?: string;
+ secretPath?: string;
+ type?: SecretValidationRuleType;
+ inputs?: TSecretValidationRuleInputs;
+ isActive?: boolean;
+};
+
+export type TDeleteSecretValidationRuleDTO = {
+ projectId: string;
+ ruleId: string;
+};
diff --git a/frontend/src/pages/secret-manager/SettingsPage/SettingsPage.tsx b/frontend/src/pages/secret-manager/SettingsPage/SettingsPage.tsx
index 9cf21393e3..e60b982dfa 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/SettingsPage.tsx
+++ b/frontend/src/pages/secret-manager/SettingsPage/SettingsPage.tsx
@@ -10,7 +10,7 @@ import { ProjectGeneralTab } from "@app/pages/project/SettingsPage/components/Pr
import { EncryptionTab } from "./components/EncryptionTab";
import { SecretSettingsTab } from "./components/ProjectGeneralTab";
-import { SecretEnforcementTab } from "./components/SecretEnforcementTab";
+import { SecretValidationRulesTab } from "./components/SecretEnforcementTab";
import { WebhooksTab } from "./components/WebhooksTab";
import { WorkflowIntegrationTab } from "./components/WorkflowIntegrationSection";
@@ -23,9 +23,9 @@ export const SettingsPage = () => {
{ name: "General", key: "tab-project-general", Component: ProjectGeneralTab },
{ name: "Secrets Management", key: "tab-secret-general", Component: SecretSettingsTab },
{
- name: "Secret Enforcement",
- key: "tab-secret-enforcement",
- Component: SecretEnforcementTab
+ name: "Secret Validation Rules",
+ key: "tab-secret-validation-rules",
+ Component: SecretValidationRulesTab
},
{
name: "Encryption",
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/ConstraintCard.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/ConstraintCard.tsx
new file mode 100644
index 0000000000..ff58127ba4
--- /dev/null
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/ConstraintCard.tsx
@@ -0,0 +1,101 @@
+/* eslint-disable jsx-a11y/label-has-associated-control */
+import { Controller, useFormContext } from "react-hook-form";
+import { TrashIcon } from "lucide-react";
+
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+ UnstableIconButton,
+ UnstableInput
+} from "@app/components/v3";
+
+import {
+ CONSTRAINT_OPTIONS,
+ CONSTRAINT_TYPE_LABELS,
+ CONSTRAINT_VALUE_LABELS,
+ ConstraintTarget,
+ ConstraintType,
+ TRuleForm
+} from "./SecretEnforcementTab.utils";
+
+type Props = {
+ index: number;
+ onRemove: () => void;
+};
+
+export const ConstraintCard = ({ index, onRemove }: Props) => {
+ const { control, watch } = useFormContext<TRuleForm>();
+ const constraintType = watch(`enforcement.inputs.constraints.${index}.type`);
+
+ const constraintOption = CONSTRAINT_OPTIONS.find((o) => o.type === constraintType);
+
+ const Icon = constraintOption?.icon;
+ const placeholder = constraintOption?.placeholder;
+
+ return (
+ <div className="rounded-md border border-border bg-card p-4">
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-2">
+ {Icon && <Icon className="size-4 text-muted" />}
+ <span className="text-sm font-medium text-foreground">
+ {CONSTRAINT_TYPE_LABELS[constraintType]}
+ </span>
+ </div>
+ <UnstableIconButton
+ aria-label="Remove constraint"
+ variant="danger"
+ size="xs"
+ onClick={onRemove}
+ >
+ <TrashIcon className="size-3.5" />
+ </UnstableIconButton>
+ </div>
+
+ <div className="mt-3 grid grid-cols-2 gap-3">
+ <div className="flex flex-col gap-1">
+ <label className="text-xs font-medium text-muted">Applies to</label>
+ <Controller
+ control={control}
+ name={`enforcement.inputs.constraints.${index}.appliesTo`}
+ render={({ field: { value, onChange } }) => (
+ <Select value={value} onValueChange={onChange}>
+ <SelectTrigger>
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent position="popper">
+ <SelectItem value={ConstraintTarget.SecretKey}>Secret Key</SelectItem>
+ <SelectItem value={ConstraintTarget.SecretValue}>Secret Value</SelectItem>
+ </SelectContent>
+ </Select>
+ )}
+ />
+ </div>
+ <div className="flex flex-col gap-1">
+ <label className="text-xs font-medium text-muted">
+ {CONSTRAINT_VALUE_LABELS[constraintType]}
+ </label>
+ <Controller
+ control={control}
+ name={`enforcement.inputs.constraints.${index}.value`}
+ render={({ field, fieldState: { error } }) => (
+ <UnstableInput
+ {...field}
+ type={
+ constraintType === ConstraintType.MinLength ||
+ constraintType === ConstraintType.MaxLength
+ ? "number"
+ : "text"
+ }
+ placeholder={placeholder?.toString() || undefined}
+ isError={Boolean(error)}
+ />
+ )}
+ />
+ </div>
+ </div>
+ </div>
+ );
+};
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretEnforcementTab.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretEnforcementTab.tsx
deleted file mode 100644
index 492df2bf34..0000000000
--- a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretEnforcementTab.tsx
+++ /dev/null
@@ -1,160 +0,0 @@
-import { useState } from "react";
-import { FormProvider, useFieldArray, useForm } from "react-hook-form";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { PlusIcon, SaveIcon, ShieldCheckIcon } from "lucide-react";
-
-import { createNotification } from "@app/components/notifications";
-import {
- Badge,
- Button,
- UnstableAccordion,
- UnstableAccordionContent,
- UnstableAccordionItem,
- UnstableAccordionTrigger
-} from "@app/components/v3";
-
-import {
- DEFAULT_STATIC_SECRET_RULE,
- secretEnforcementFormSchema,
- TSecretEnforcementForm
-} from "./SecretEnforcementTab.utils";
-import { StaticSecretRuleCard } from "./StaticSecretRuleCard";
-
-export const SecretEnforcementTab = () => {
- const [openSections, setOpenSections] = useState<string[]>([]);
-
- const form = useForm<TSecretEnforcementForm>({
- resolver: zodResolver(secretEnforcementFormSchema),
- defaultValues: {
- staticSecrets: []
- }
- });
-
- const {
- handleSubmit,
- formState: { isDirty, isSubmitting },
- reset,
- control
- } = form;
-
- const { fields, append, remove } = useFieldArray({
- control,
- name: "staticSecrets"
- });
-
- const onSubmit = (data: TSecretEnforcementForm) => {
- // eslint-disable-next-line no-console
- console.log("Secret enforcement policies:", data);
- createNotification({
- text: "Secret enforcement policies saved (no backend yet)",
- type: "success"
- });
- reset(data);
- };
-
- const handleAddRule = (e: React.MouseEvent) => {
- e.stopPropagation();
- append(DEFAULT_STATIC_SECRET_RULE);
- if (!openSections.includes("static-secrets")) {
- setOpenSections((prev) => [...prev, "static-secrets"]);
- }
- };
-
- return (
- <div className="w-full">
- <form
- onSubmit={handleSubmit(onSubmit)}
- className="flex h-full w-full flex-1 flex-col rounded-lg border border-border bg-card py-4"
- >
- <FormProvider {...form}>
- <div className="mx-4 flex items-center justify-between border-b border-border pb-4">
- <div>
- <h3 className="text-lg font-medium text-foreground">Secret Enforcement</h3>
- <p className="text-sm leading-3 text-muted">
- Configure enforcement policies for secret values and keys
- </p>
- </div>
- <div className="flex items-center gap-2">
- {isDirty && (
- <Button
- type="button"
- className="mr-4 text-muted"
- variant="ghost"
- disabled={isSubmitting}
- onClick={() => reset()}
- >
- Discard
- </Button>
- )}
- <Button variant="project" type="submit" disabled={isSubmitting || !isDirty}>
- <SaveIcon className="size-4" />
- Save
- </Button>
- <div className="ml-2 border-l border-border pl-4">
- <Button type="button" variant="outline" size="xs" onClick={handleAddRule}>
- <PlusIcon className="size-4" />
- Add Policy
- </Button>
- </div>
- </div>
- </div>
- <div className="flex flex-1 flex-col overflow-hidden px-4">
- <div className="thin-scrollbar flex-1 overflow-y-scroll py-4">
- {fields.length === 0 ? (
- <div className="flex flex-col items-center justify-center rounded-md border border-dashed border-border py-12">
- <ShieldCheckIcon className="mb-3 size-10 text-muted" />
- <p className="text-sm text-muted">No enforcement policies configured</p>
- <p className="mt-1 text-xs text-muted">
- Click &quot;Add Policy&quot; to create your first secret enforcement rule.
- </p>
- </div>
- ) : (
- <UnstableAccordion
- type="multiple"
- value={openSections}
- onValueChange={setOpenSections}
- className="overflow-clip rounded-md border border-border bg-container hover:bg-container-hover"
- >
- <UnstableAccordionItem value="static-secrets">
- <UnstableAccordionTrigger className="min-h-14 px-4 py-2.5 hover:bg-container-hover [&>svg]:size-5">
- <div className="flex flex-1 items-center gap-2 text-left">
- <div className="flex grow flex-col">
- <span className="text-base select-none">Static Secrets</span>
- <span className="text-sm text-muted">
- Enforce requirements on static secret values and keys
- </span>
- </div>
- {fields.length > 0 && (
- <Badge variant="neutral" className="mr-2">
- {fields.length} {fields.length === 1 ? "Rule" : "Rules"}
- </Badge>
- )}
- {openSections.includes("static-secrets") && (
- <Button type="button" variant="outline" size="xs" onClick={handleAddRule}>
- <PlusIcon className="size-4" />
- Add Rule
- </Button>
- )}
- </div>
- </UnstableAccordionTrigger>
- <UnstableAccordionContent className="!p-0">
- <div className="flex flex-col space-y-3 bg-container p-3">
- {fields.map((field, idx) => (
- <StaticSecretRuleCard
- key={field.id}
- index={idx}
- onRemove={() => remove(idx)}
- />
- ))}
- </div>
- </UnstableAccordionContent>
- </UnstableAccordionItem>
- </UnstableAccordion>
- )}
- </div>
- </div>
- </FormProvider>
- </form>
- </div>
- );
-};
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretEnforcementTab.utils.ts b/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretEnforcementTab.utils.ts
index 6ce29f28f9..518eb5dfc4 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretEnforcementTab.utils.ts
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretEnforcementTab.utils.ts
@@ -1,38 +1,112 @@
+import { HashIcon, LucideIcon, RulerIcon, TextCursorInputIcon, TextIcon } from "lucide-react";
import { z } from "zod";
-export const staticSecretRuleSchema = z.object({
- enabled: z.boolean().default(true),
- folderPath: z.string().default("/**"),
- environment: z.string().default(""),
- keyPattern: z.object({
- enabled: z.boolean().default(false),
- pattern: z.string().default("*")
- }),
- valueRequirements: z.object({
- minLength: z.coerce.number().min(0).optional(),
- maxLength: z.coerce.number().min(0).optional(),
- minLowercase: z.coerce.number().min(0).optional(),
- minUppercase: z.coerce.number().min(0).optional(),
- minDigits: z.coerce.number().min(0).optional(),
- minSymbols: z.coerce.number().min(0).optional(),
- allowedSpecialChars: z.string().optional()
- })
+export enum ConstraintType {
+ MinLength = "min-length",
+ MaxLength = "max-length",
+ RegexPattern = "regex-pattern",
+ RequiredPrefix = "required-prefix",
+ RequiredSuffix = "required-suffix"
+}
+
+export enum ConstraintTarget {
+ SecretKey = "key",
+ SecretValue = "value"
+}
+
+export const CONSTRAINT_OPTIONS: {
+ type: ConstraintType;
+ label: string;
+ description: string;
+ placeholder: string | number;
+ icon: LucideIcon;
+}[] = [
+ {
+ type: ConstraintType.MinLength,
+ label: "Min Length",
+ description: "Minimum character count",
+ placeholder: 8,
+ icon: RulerIcon
+ },
+ {
+ type: ConstraintType.MaxLength,
+ label: "Max Length",
+ description: "Maximum character count",
+ placeholder: 256,
+ icon: RulerIcon
+ },
+ {
+ type: ConstraintType.RegexPattern,
+ label: "Regex Pattern",
+ description: "Must match a regular expression",
+ placeholder: "^[A-Z_]+$",
+ icon: HashIcon
+ },
+ {
+ type: ConstraintType.RequiredPrefix,
+ label: "Required Prefix",
+ description: "Must start with specific text",
+ placeholder: "PREFIX-",
+ icon: TextCursorInputIcon
+ },
+ {
+ type: ConstraintType.RequiredSuffix,
+ label: "Required Suffix",
+ description: "Must end with specific text",
+ placeholder: "-SUFFIX",
+ icon: TextIcon
+ }
+];
+
+export const CONSTRAINT_VALUE_LABELS: Record<ConstraintType, string> = {
+ [ConstraintType.MinLength]: "Characters",
+ [ConstraintType.MaxLength]: "Characters",
+ [ConstraintType.RegexPattern]: "Pattern",
+ [ConstraintType.RequiredPrefix]: "Text",
+ [ConstraintType.RequiredSuffix]: "Text"
+};
+
+export const CONSTRAINT_TYPE_LABELS: Record<ConstraintType, string> = {
+ [ConstraintType.MinLength]: "Min Length",
+ [ConstraintType.MaxLength]: "Max Length",
+ [ConstraintType.RegexPattern]: "Regex Pattern",
+ [ConstraintType.RequiredPrefix]: "Required Prefix",
+ [ConstraintType.RequiredSuffix]: "Required Suffix"
+};
+
+export enum RuleType {
+ StaticSecrets = "static-secrets"
+}
+
+export const RULE_TYPE_LABELS: Record<RuleType, string> = {
+ [RuleType.StaticSecrets]: "Static Secrets"
+};
+
+export const constraintSchema = z.object({
+ type: z.nativeEnum(ConstraintType),
+ appliesTo: z.nativeEnum(ConstraintTarget),
+ value: z.string().min(1, "Value is required")
});
-export const secretEnforcementFormSchema = z.object({
- staticSecrets: z.array(staticSecretRuleSchema)
+const staticSecretsInputsSchema = z.object({
+ constraints: z.array(constraintSchema).min(1, "At least one constraint is required")
});
-export type TSecretEnforcementForm = z.infer<typeof secretEnforcementFormSchema>;
-export type TStaticSecretRule = z.infer<typeof staticSecretRuleSchema>;
+export const ruleFormSchema = z.object({
+ name: z.string().min(1, "Name is required").max(100),
+ description: z.string().max(500).optional(),
+ environment: z.string().nullable().default(null),
+ folderPath: z.string().default("/**"),
+ enforcement: z.object({
+ type: z.nativeEnum(RuleType),
+ inputs: staticSecretsInputsSchema
+ })
+});
-export const DEFAULT_STATIC_SECRET_RULE: TStaticSecretRule = {
- enabled: true,
- folderPath: "/**",
- environment: "",
- keyPattern: {
- enabled: false,
- pattern: "*"
- },
- valueRequirements: {}
+export type TRuleForm = z.infer<typeof ruleFormSchema>;
+export type TConstraint = z.infer<typeof constraintSchema>;
+
+export type TRule = TRuleForm & {
+ id: string;
+ isActive: boolean;
};
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretValidationRulesTab.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretValidationRulesTab.tsx
new file mode 100644
index 0000000000..f50d364e2b
--- /dev/null
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretValidationRulesTab.tsx
@@ -0,0 +1,502 @@
+/* eslint-disable jsx-a11y/label-has-associated-control */
+import { useState } from "react";
+import { Controller, FormProvider, useFieldArray, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import {
+ ArrowLeftIcon,
+ EllipsisVerticalIcon,
+ PencilIcon,
+ PlusIcon,
+ ShieldCheckIcon,
+ TrashIcon
+} from "lucide-react";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Badge,
+ Button,
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+ UnstableDropdownMenu,
+ UnstableDropdownMenuContent,
+ UnstableDropdownMenuItem,
+ UnstableDropdownMenuTrigger,
+ UnstableIconButton,
+ UnstableInput,
+ UnstableTable,
+ UnstableTableBody,
+ UnstableTableCell,
+ UnstableTableHead,
+ UnstableTableHeader,
+ UnstableTableRow
+} from "@app/components/v3";
+import { useProject } from "@app/context";
+import {
+ useCreateSecretValidationRule,
+ useDeleteSecretValidationRule,
+ useListSecretValidationRules,
+ useUpdateSecretValidationRule
+} from "@app/hooks/api/secretValidationRules";
+import { SecretValidationRuleType } from "@app/hooks/api/secretValidationRules/types";
+
+import { ConstraintCard } from "./ConstraintCard";
+import {
+ CONSTRAINT_OPTIONS,
+ ConstraintTarget,
+ RULE_TYPE_LABELS,
+ ruleFormSchema,
+ RuleType,
+ TRuleForm
+} from "./SecretEnforcementTab.utils";
+
+const RuleForm = ({
+ defaultValues,
+ isEditing,
+ environments,
+ onCancel,
+ onSubmit
+}: {
+ defaultValues?: Partial<TRuleForm>;
+ isEditing: boolean;
+ environments: { slug: string; name: string }[];
+ onCancel: () => void;
+ onSubmit: (data: TRuleForm) => void;
+}) => {
+ const form = useForm<TRuleForm>({
+ resolver: zodResolver(ruleFormSchema),
+ defaultValues: defaultValues || {
+ name: "",
+ description: "",
+ environment: null,
+ folderPath: "/**",
+ enforcement: {
+ type: RuleType.StaticSecrets,
+ inputs: {
+ constraints: []
+ }
+ }
+ }
+ });
+
+ const {
+ handleSubmit,
+ control,
+ formState: { errors }
+ } = form;
+
+ const { fields, append, remove } = useFieldArray({
+ control,
+ name: "enforcement.inputs.constraints"
+ });
+
+ const watchedConstraints = form.watch("enforcement.inputs.constraints");
+ const usedConstraintTypes = new Set(watchedConstraints?.map((c) => c.type));
+ const availableConstraintOptions = CONSTRAINT_OPTIONS.filter(
+ (opt) => !usedConstraintTypes.has(opt.type)
+ );
+
+ return (
+ <div className="w-full">
+ <div className="flex h-full w-full flex-1 flex-col rounded-lg border border-border bg-card py-4">
+ <div className="mx-4 flex items-center gap-3 border-b border-border pb-4">
+ <UnstableIconButton
+ aria-label="Back to list"
+ variant="ghost"
+ size="sm"
+ onClick={onCancel}
+ >
+ <ArrowLeftIcon className="size-4" />
+ </UnstableIconButton>
+ <div>
+ <h3 className="text-lg font-medium text-foreground">
+ {isEditing ? "Edit Rule" : "Create Rule"}
+ </h3>
+ <p className="text-sm leading-3 text-muted">
+ {isEditing ? "Modify this validation rule" : "Define a new secret validation rule"}
+ </p>
+ </div>
+ </div>
+
+ <FormProvider {...form}>
+ <form onSubmit={handleSubmit(onSubmit)} className="flex flex-1 flex-col overflow-hidden">
+ <div className="thin-scrollbar flex-1 space-y-6 overflow-y-scroll p-4">
+ {/* Name & Description */}
+ <div className="grid grid-cols-2 gap-4">
+ <div className="flex flex-col gap-1">
+ <label className="text-xs font-medium text-muted">Name</label>
+ <Controller
+ control={control}
+ name="name"
+ render={({ field }) => (
+ <UnstableInput
+ {...field}
+ placeholder="e.g. Production key naming"
+ isError={Boolean(errors.name)}
+ />
+ )}
+ />
+ </div>
+ <div className="flex flex-col gap-1">
+ <label className="text-xs font-medium text-muted">Description (optional)</label>
+ <Controller
+ control={control}
+ name="description"
+ render={({ field }) => (
+ <UnstableInput
+ {...field}
+ value={field.value ?? ""}
+ placeholder="Brief description of this rule"
+ />
+ )}
+ />
+ </div>
+ </div>
+
+ {/* Enforcement Type */}
+ <div className="flex flex-col gap-1">
+ <label className="text-xs font-medium text-muted">Rule Type</label>
+ <Controller
+ control={control}
+ name="enforcement.type"
+ render={({ field: { value, onChange } }) => (
+ <Select value={value} onValueChange={onChange}>
+ <SelectTrigger className="w-64">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent position="popper">
+ <SelectItem value={RuleType.StaticSecrets}>
+ {RULE_TYPE_LABELS[RuleType.StaticSecrets]}
+ </SelectItem>
+ </SelectContent>
+ </Select>
+ )}
+ />
+ </div>
+
+ {/* Scope */}
+ <div>
+ <h4 className="mb-3 text-sm font-medium text-foreground">Scope</h4>
+ <div className="grid grid-cols-2 gap-4">
+ <div className="flex flex-col gap-1">
+ <label className="text-xs font-medium text-muted">Environment</label>
+ <Controller
+ control={control}
+ name="environment"
+ render={({ field: { value, onChange } }) => (
+ <Select
+ value={value ?? "all"}
+ onValueChange={(val) => onChange(val === "all" ? null : val)}
+ >
+ <SelectTrigger>
+ <SelectValue placeholder="All Environments" />
+ </SelectTrigger>
+ <SelectContent position="popper">
+ <SelectItem value="all">All Environments</SelectItem>
+ {environments.map((env) => (
+ <SelectItem key={env.slug} value={env.slug}>
+ {env.name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ )}
+ />
+ </div>
+ <div className="flex flex-col gap-1">
+ <label className="text-xs font-medium text-muted">Folder Path</label>
+ <Controller
+ control={control}
+ name="folderPath"
+ render={({ field }) => <UnstableInput {...field} placeholder="/**" />}
+ />
+ </div>
+ </div>
+ </div>
+
+ {/* Constraints */}
+ <div>
+ <div className="mb-3 flex items-center justify-between">
+ <h4 className="text-sm font-medium text-foreground">Validation Constraints</h4>
+ {availableConstraintOptions.length > 0 && (
+ <UnstableDropdownMenu>
+ <UnstableDropdownMenuTrigger asChild>
+ <Button type="button" variant="outline" size="xs">
+ <PlusIcon className="size-4" />
+ Add Constraint
+ </Button>
+ </UnstableDropdownMenuTrigger>
+ <UnstableDropdownMenuContent align="end">
+ {availableConstraintOptions.map((opt) => (
+ <UnstableDropdownMenuItem
+ key={opt.type}
+ onClick={() =>
+ append({
+ type: opt.type,
+ appliesTo: ConstraintTarget.SecretValue,
+ value: ""
+ })
+ }
+ >
+ <opt.icon className="mr-2 size-4" />
+ <div>
+ <div className="text-sm">{opt.label}</div>
+ <div className="text-xs text-muted">{opt.description}</div>
+ </div>
+ </UnstableDropdownMenuItem>
+ ))}
+ </UnstableDropdownMenuContent>
+ </UnstableDropdownMenu>
+ )}
+ </div>
+
+ {fields.length === 0 && (
+ <div className="rounded-md border border-dashed border-border py-8 text-center">
+ <p className="text-sm text-muted">No constraints added yet</p>
+ {errors.enforcement?.inputs?.constraints?.root?.message && (
+ <p className="mt-1 text-xs text-danger">
+ {errors.enforcement?.inputs?.constraints?.root?.message}
+ </p>
+ )}
+ </div>
+ )}
+
+ <div className="space-y-3">
+ {fields.map((field, idx) => (
+ <ConstraintCard key={field.id} index={idx} onRemove={() => remove(idx)} />
+ ))}
+ </div>
+
+ {fields.length > 0 && errors.enforcement?.inputs?.constraints?.root?.message && (
+ <p className="mt-1 text-xs text-danger">
+ {errors.enforcement?.inputs?.constraints?.root?.message}
+ </p>
+ )}
+ </div>
+ </div>
+
+ {/* Footer */}
+ <div className="flex items-center justify-end gap-2 border-t border-border px-4 pt-4">
+ <Button type="button" variant="ghost" onClick={onCancel}>
+ Cancel
+ </Button>
+ <Button variant="project" type="submit">
+ {isEditing ? "Save Changes" : "Create Rule"}
+ </Button>
+ </div>
+ </form>
+ </FormProvider>
+ </div>
+ </div>
+ );
+};
+
+type ViewState = { mode: "list" } | { mode: "create" } | { mode: "edit"; ruleId: string };
+
+export const SecretValidationRulesTab = () => {
+ const { currentProject } = useProject();
+ const [view, setView] = useState<ViewState>({ mode: "list" });
+
+ const { data: rules = [], isLoading } = useListSecretValidationRules({
+ projectId: currentProject.id
+ });
+
+ const createRule = useCreateSecretValidationRule();
+ const updateRule = useUpdateSecretValidationRule();
+ const deleteRule = useDeleteSecretValidationRule();
+
+ const resolveEnvSlug = (envId: string) => {
+ const env = currentProject.environments.find((e) => e.id === envId);
+ return env?.slug ?? null;
+ };
+
+ const resolveEnvName = (envId: string) => {
+ const env = currentProject.environments.find((e) => e.id === envId);
+ return env?.name ?? envId;
+ };
+
+ const handleDelete = async (ruleId: string) => {
+ try {
+ await deleteRule.mutateAsync({ projectId: currentProject.id, ruleId });
+ createNotification({ text: "Rule deleted", type: "success" });
+ } catch {
+ createNotification({ text: "Failed to delete rule", type: "error" });
+ }
+ };
+
+ const handleEdit = (id: string) => {
+ setView({ mode: "edit", ruleId: id });
+ };
+
+ const handleSubmit = async (data: TRuleForm) => {
+ try {
+ if (view.mode === "edit") {
+ const editView = view as { mode: "edit"; ruleId: string };
+ await updateRule.mutateAsync({
+ projectId: currentProject.id,
+ ruleId: editView.ruleId,
+ name: data.name,
+ description: data.description,
+ environmentSlug: data.environment ?? undefined,
+ secretPath: data.folderPath,
+ type: data.enforcement.type as string as SecretValidationRuleType,
+ inputs: data.enforcement.inputs
+ });
+ createNotification({ text: "Rule updated", type: "success" });
+ } else {
+ await createRule.mutateAsync({
+ projectId: currentProject.id,
+ name: data.name,
+ description: data.description,
+ environmentSlug: data.environment ?? "",
+ secretPath: data.folderPath,
+ rule: {
+ type: data.enforcement.type as string as SecretValidationRuleType,
+ inputs: data.enforcement.inputs
+ }
+ });
+ createNotification({ text: "Rule created", type: "success" });
+ }
+ setView({ mode: "list" });
+ } catch {
+ createNotification({
+ text: `Failed to ${view.mode === "edit" ? "update" : "create"} rule`,
+ type: "error"
+ });
+ }
+ };
+
+ if (view.mode === "list") {
+ return (
+ <div className="w-full">
+ <div className="flex h-full w-full flex-1 flex-col rounded-lg border border-border bg-card py-4">
+ <div className="mx-4 flex items-center justify-between border-b border-border pb-4">
+ <div>
+ <h3 className="text-lg font-medium text-foreground">Secret Validation Rules</h3>
+ <p className="text-sm leading-3 text-muted">
+ Define validation constraints for secret keys and values
+ </p>
+ </div>
+ <Button variant="outline" size="xs" onClick={() => setView({ mode: "create" })}>
+ <PlusIcon className="size-4" />
+ Create Rule
+ </Button>
+ </div>
+ <div className="flex flex-1 flex-col overflow-hidden px-4">
+ <div className="thin-scrollbar flex-1 overflow-y-scroll py-4">
+ {isLoading && (
+ <div className="flex items-center justify-center py-12">
+ <p className="text-sm text-muted">Loading rules...</p>
+ </div>
+ )}
+ {!isLoading && rules.length === 0 ? (
+ <div className="flex flex-col items-center justify-center rounded-md border border-dashed border-border py-12">
+ <ShieldCheckIcon className="mb-3 size-10 text-muted" />
+ <p className="text-sm text-muted">No validation rules configured</p>
+ <p className="mt-1 text-xs text-muted">
+ Click &quot;Create Rule&quot; to define your first secret validation rule.
+ </p>
+ </div>
+ ) : (
+ !isLoading && (
+ <UnstableTable>
+ <UnstableTableHeader>
+ <UnstableTableRow>
+ <UnstableTableHead>Name</UnstableTableHead>
+ <UnstableTableHead>Type</UnstableTableHead>
+ <UnstableTableHead>Scope</UnstableTableHead>
+ <UnstableTableHead>Status</UnstableTableHead>
+ <UnstableTableHead className="w-12" />
+ </UnstableTableRow>
+ </UnstableTableHeader>
+ <UnstableTableBody>
+ {rules.map((rule) => (
+ <UnstableTableRow key={rule.id}>
+ <UnstableTableCell>
+ <div>
+ <span className="text-sm font-medium text-foreground">
+ {rule.name}
+ </span>
+ {rule.description && (
+ <p className="text-xs text-muted">{rule.description}</p>
+ )}
+ </div>
+ </UnstableTableCell>
+ <UnstableTableCell>
+ <Badge variant="neutral">
+ {RULE_TYPE_LABELS[rule.type as string as RuleType] ?? rule.type}
+ </Badge>
+ </UnstableTableCell>
+ <UnstableTableCell>
+ <div className="flex items-center gap-1.5">
+ <Badge variant="neutral">{resolveEnvName(rule.envId)}</Badge>
+ <Badge variant="neutral">{rule.secretPath}</Badge>
+ </div>
+ </UnstableTableCell>
+ <UnstableTableCell>
+ <Badge variant={rule.isActive ? "success" : "neutral"}>
+ {rule.isActive ? "Active" : "Inactive"}
+ </Badge>
+ </UnstableTableCell>
+ <UnstableTableCell>
+ <UnstableDropdownMenu>
+ <UnstableDropdownMenuTrigger asChild>
+ <UnstableIconButton aria-label="Actions" variant="ghost" size="xs">
+ <EllipsisVerticalIcon className="size-4" />
+ </UnstableIconButton>
+ </UnstableDropdownMenuTrigger>
+ <UnstableDropdownMenuContent align="end">
+ <UnstableDropdownMenuItem onClick={() => handleEdit(rule.id)}>
+ <PencilIcon className="mr-2 size-4" />
+ Edit
+ </UnstableDropdownMenuItem>
+ <UnstableDropdownMenuItem
+ variant="danger"
+ onClick={() => handleDelete(rule.id)}
+ >
+ <TrashIcon className="mr-2 size-4" />
+ Delete
+ </UnstableDropdownMenuItem>
+ </UnstableDropdownMenuContent>
+ </UnstableDropdownMenu>
+ </UnstableTableCell>
+ </UnstableTableRow>
+ ))}
+ </UnstableTableBody>
+ </UnstableTable>
+ )
+ )}
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+ }
+
+ const editingRule = view.mode === "edit" ? rules.find((r) => r.id === view.ruleId) : undefined;
+
+ const editingDefaults = editingRule
+ ? {
+ name: editingRule.name,
+ description: editingRule.description ?? undefined,
+ environment: resolveEnvSlug(editingRule.envId),
+ folderPath: editingRule.secretPath,
+ enforcement: {
+ type: editingRule.type as string as RuleType,
+ inputs: editingRule.inputs
+ }
+ }
+ : undefined;
+
+ return (
+ <RuleForm
+ defaultValues={editingDefaults}
+ isEditing={view.mode === "edit"}
+ environments={currentProject.environments}
+ onCancel={() => setView({ mode: "list" })}
+ onSubmit={handleSubmit}
+ />
+ );
+};
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/StaticSecretRuleCard.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/StaticSecretRuleCard.tsx
deleted file mode 100644
index 68245e4298..0000000000
--- a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/StaticSecretRuleCard.tsx
+++ /dev/null
@@ -1,304 +0,0 @@
-/* eslint-disable jsx-a11y/label-has-associated-control */
-import { Controller, useFormContext } from "react-hook-form";
-import { TrashIcon } from "lucide-react";
-
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
- Switch,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
- UnstableIconButton,
- UnstableInput
-} from "@app/components/v3";
-import { useProject } from "@app/context";
-
-import { TSecretEnforcementForm } from "./SecretEnforcementTab.utils";
-
-type Props = {
- index: number;
- onRemove: () => void;
-};
-
-export const StaticSecretRuleCard = ({ index, onRemove }: Props) => {
- const { currentProject } = useProject();
- const { control, watch } = useFormContext<TSecretEnforcementForm>();
-
- const isEnabled = watch(`staticSecrets.${index}.enabled`);
- const keyPatternEnabled = watch(`staticSecrets.${index}.keyPattern.enabled`);
-
- return (
- <div className="relative rounded-md border border-l-[6px] border-border border-l-green-600/50 bg-card px-5 py-4">
- <div className="flex items-center justify-between">
- <div className="flex items-center gap-3">
- <Controller
- control={control}
- name={`staticSecrets.${index}.enabled`}
- render={({ field: { value, onChange } }) => (
- <Switch variant="project" checked={value} onCheckedChange={onChange} />
- )}
- />
- <span className="text-sm font-medium text-foreground">
- {isEnabled ? "Enforcement Enabled" : "Enforcement Disabled"}
- </span>
- </div>
- <Tooltip>
- <TooltipTrigger asChild>
- <UnstableIconButton aria-label="Delete rule" variant="danger" onClick={onRemove}>
- <TrashIcon className="size-4" />
- </UnstableIconButton>
- </TooltipTrigger>
- <TooltipContent side="top">Delete Rule</TooltipContent>
- </Tooltip>
- </div>
-
- <div className="mt-4 grid grid-cols-2 gap-4">
- <div className="flex flex-col gap-1">
- <label className="text-xs font-medium text-muted" htmlFor={`folderPath-${index}`}>
- Folder Path
- </label>
- <Controller
- control={control}
- name={`staticSecrets.${index}.folderPath`}
- render={({ field }) => (
- <UnstableInput
- {...field}
- id={`folderPath-${index}`}
- placeholder="/**"
- disabled={!isEnabled}
- />
- )}
- />
- <span className="text-xs text-muted">Glob pattern for folder scope</span>
- </div>
- <div className="flex flex-col gap-1">
- <label className="text-xs font-medium text-muted" htmlFor={`environment-${index}`}>
- Environment
- </label>
- <Controller
- control={control}
- name={`staticSecrets.${index}.environment`}
- render={({ field: { value, onChange } }) => (
- <Select
- value={value || "all"}
- onValueChange={(val) => onChange(val === "all" ? "" : val)}
- disabled={!isEnabled}
- >
- <SelectTrigger id={`environment-${index}`}>
- <SelectValue placeholder="All Environments" />
- </SelectTrigger>
- <SelectContent position="popper">
- <SelectItem value="all">All Environments</SelectItem>
- {currentProject.environments.map((env) => (
- <SelectItem key={env.slug} value={env.slug}>
- {env.name}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- )}
- />
- </div>
- </div>
-
- <div className="mt-4 border-t border-border pt-4">
- <div className="flex items-center gap-3">
- <Controller
- control={control}
- name={`staticSecrets.${index}.keyPattern.enabled`}
- render={({ field: { value, onChange } }) => (
- <Switch
- variant="project"
- size="sm"
- checked={value}
- onCheckedChange={onChange}
- disabled={!isEnabled}
- />
- )}
- />
- <span className="text-sm text-foreground">Filter by Key Pattern</span>
- </div>
- {keyPatternEnabled && (
- <div className="mt-2 ml-9">
- <Controller
- control={control}
- name={`staticSecrets.${index}.keyPattern.pattern`}
- render={({ field }) => (
- <UnstableInput
- {...field}
- placeholder="DB-*"
- className="w-64"
- disabled={!isEnabled}
- />
- )}
- />
- <span className="mt-1 block text-xs text-muted">
- Glob pattern to match secret keys (e.g. DB-*, *_TOKEN)
- </span>
- </div>
- )}
- </div>
-
- <div className="mt-4 border-t border-border pt-4">
- <h4 className="mb-3 text-sm font-medium text-foreground">Value Requirements</h4>
- <div className="grid grid-cols-2 gap-4">
- <div className="flex flex-col gap-1">
- <label className="text-xs font-medium text-muted" htmlFor={`minLength-${index}`}>
- Minimum Length
- </label>
- <Controller
- control={control}
- name={`staticSecrets.${index}.valueRequirements.minLength`}
- render={({ field }) => (
- <UnstableInput
- {...field}
- value={field.value ?? ""}
- id={`minLength-${index}`}
- type="number"
- min={0}
- placeholder="No minimum"
- disabled={!isEnabled}
- />
- )}
- />
- </div>
- <div className="flex flex-col gap-1">
- <label className="text-xs font-medium text-muted" htmlFor={`maxLength-${index}`}>
- Maximum Length
- </label>
- <Controller
- control={control}
- name={`staticSecrets.${index}.valueRequirements.maxLength`}
- render={({ field }) => (
- <UnstableInput
- {...field}
- value={field.value ?? ""}
- id={`maxLength-${index}`}
- type="number"
- min={0}
- placeholder="No maximum"
- disabled={!isEnabled}
- />
- )}
- />
- </div>
- </div>
-
- <h5 className="mt-4 mb-2 text-xs font-medium text-muted">
- Minimum Required Character Counts
- </h5>
- <div className="grid grid-cols-4 gap-3">
- <div className="flex flex-col gap-1">
- <label className="text-xs text-muted" htmlFor={`minLowercase-${index}`}>
- Lowercase
- </label>
- <Controller
- control={control}
- name={`staticSecrets.${index}.valueRequirements.minLowercase`}
- render={({ field }) => (
- <UnstableInput
- {...field}
- value={field.value ?? ""}
- id={`minLowercase-${index}`}
- type="number"
- min={0}
- placeholder="0"
- disabled={!isEnabled}
- />
- )}
- />
- </div>
- <div className="flex flex-col gap-1">
- <label className="text-xs text-muted" htmlFor={`minUppercase-${index}`}>
- Uppercase
- </label>
- <Controller
- control={control}
- name={`staticSecrets.${index}.valueRequirements.minUppercase`}
- render={({ field }) => (
- <UnstableInput
- {...field}
- value={field.value ?? ""}
- id={`minUppercase-${index}`}
- type="number"
- min={0}
- placeholder="0"
- disabled={!isEnabled}
- />
- )}
- />
- </div>
- <div className="flex flex-col gap-1">
- <label className="text-xs text-muted" htmlFor={`minDigits-${index}`}>
- Digits
- </label>
- <Controller
- control={control}
- name={`staticSecrets.${index}.valueRequirements.minDigits`}
- render={({ field }) => (
- <UnstableInput
- {...field}
- value={field.value ?? ""}
- id={`minDigits-${index}`}
- type="number"
- min={0}
- placeholder="0"
- disabled={!isEnabled}
- />
- )}
- />
- </div>
- <div className="flex flex-col gap-1">
- <label className="text-xs text-muted" htmlFor={`minSymbols-${index}`}>
- Symbols
- </label>
- <Controller
- control={control}
- name={`staticSecrets.${index}.valueRequirements.minSymbols`}
- render={({ field }) => (
- <UnstableInput
- {...field}
- value={field.value ?? ""}
- id={`minSymbols-${index}`}
- type="number"
- min={0}
- placeholder="0"
- disabled={!isEnabled}
- />
- )}
- />
- </div>
- </div>
-
- <div className="mt-3 flex flex-col gap-1">
- <label
- className="text-xs font-medium text-muted"
- htmlFor={`allowedSpecialChars-${index}`}
- >
- Allowed Special Characters (optional)
- </label>
- <Controller
- control={control}
- name={`staticSecrets.${index}.valueRequirements.allowedSpecialChars`}
- render={({ field }) => (
- <UnstableInput
- {...field}
- value={field.value ?? ""}
- id={`allowedSpecialChars-${index}`}
- placeholder="e.g. !@#$%^&*"
- disabled={!isEnabled}
- />
- )}
- />
- <span className="text-xs text-muted">
- If set, only these special characters will be allowed in values
- </span>
- </div>
- </div>
- </div>
- );
-};
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/index.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/index.tsx
index 1ea4ec9573..b8917bf55c 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/index.tsx
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/index.tsx
@@ -1 +1 @@
-export { SecretEnforcementTab } from "./SecretEnforcementTab";
+export { SecretValidationRulesTab } from "./SecretValidationRulesTab";
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/index.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/index.tsx
index 0ecd2d3aa5..62ae922097 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/components/index.tsx
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/index.tsx
@@ -2,5 +2,5 @@ export { AutoCapitalizationSection } from "./AutoCapitalizationSection";
export { BackfillSecretReferenceSecretion } from "./BackfillSecretReferenceSection";
export { EnforceEncryptedMetadataSection } from "./EnforceEncryptedMetadataSection";
export { EnvironmentSection } from "./EnvironmentSection";
-export { SecretEnforcementTab } from "./SecretEnforcementTab";
+export { SecretValidationRulesTab } from "./SecretEnforcementTab";
export { SecretTagsSection } from "./SecretTagsSection";