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
checkpoint
Daniel Hougaard1cc5e7c0b834
diff --git a/backend/src/db/migrations/20260319204352_secret-validation-rules.ts b/backend/src/db/migrations/20260319204352_secret-validation-rules.tsindex edb0de984d..85f97d0d47 100644--- a/backend/src/db/migrations/20260319204352_secret-validation-rules.ts+++ b/backend/src/db/migrations/20260319204352_secret-validation-rules.ts@@ -11,7 +11,7 @@ export async function up(knex: Knex): Promise<void> {tb.string("description").nullable();tb.string("projectId").notNullable();tb.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE");- tb.uuid("envId").notNullable();+ tb.uuid("envId").nullable();tb.foreign("envId").references("id").inTable(TableName.Environment).onDelete("CASCADE");tb.string("secretPath").notNullable().defaultTo("/");tb.string("type").notNullable();diff --git a/backend/src/db/schemas/secret-validation-rules.ts b/backend/src/db/schemas/secret-validation-rules.tsindex 35ff5ab4bf..65f68a33e4 100644--- a/backend/src/db/schemas/secret-validation-rules.ts+++ b/backend/src/db/schemas/secret-validation-rules.ts@@ -12,7 +12,7 @@ export const SecretValidationRulesSchema = z.object({name: z.string(),description: z.string().nullable().optional(),projectId: z.string(),- envId: z.string().uuid(),+ envId: z.string().uuid().nullable().optional(),secretPath: z.string().default("/"),type: z.string(),inputs: z.unknown(),diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex 3c4e570afc..27973349cb 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -1623,7 +1623,8 @@ export const registerRoutes = async (snapshotService,resourceMetadataDAL,reminderService,- keyStore+ keyStore,+ secretValidationRuleService});const secretApprovalRequestService = secretApprovalRequestServiceFactory({diff --git a/backend/src/server/routes/v1/secret-validation-rule-router.ts b/backend/src/server/routes/v1/secret-validation-rule-router.tsindex db4a6d0cbf..dabc26dfba 100644--- a/backend/src/server/routes/v1/secret-validation-rule-router.ts+++ b/backend/src/server/routes/v1/secret-validation-rule-router.ts@@ -53,7 +53,7 @@ export const registerSecretValidationRuleRouter = async (server: FastifyZodProvibody: z.object({name: z.string().trim().min(1).max(100),description: z.string().trim().max(500).nullable().optional(),- environmentSlug: z.string().trim().min(1),+ environmentSlug: z.string().trim().min(1).optional(),secretPath: z.string().trim().default("/"),rule: SecretValidationRuleInputSchema}),diff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.tsindex 5e69e39e96..0bc2414eef 100644--- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts+++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts@@ -61,6 +61,7 @@ import { TSecretFolderDALFactory } from "../secret-folder/secret-folder-dal";import { TSecretImportDALFactory } from "../secret-import/secret-import-dal";import { fnSecretsV2FromImports } from "../secret-import/secret-import-fns";import { TSecretTagDALFactory } from "../secret-tag/secret-tag-dal";+import { TSecretValidationRuleServiceFactory } from "../secret-validation-rule/secret-validation-rule-service";import { expandSecretReferencesFactory, getAllSecretReferences } from "./secret-reference-fns";import {MAX_SECRET_CACHE_BYTES,@@ -135,6 +136,7 @@ type TSecretV2BridgeServiceFactoryDep = {resourceMetadataDAL: Pick<TResourceMetadataDALFactory, "insertMany" | "delete">;keyStore: Pick<TKeyStoreFactory, "getItem" | "setExpiry" | "setItemWithExpiry" | "deleteItem" | "pgGetIntItem">;reminderService: Pick<TReminderServiceFactory, "createReminder" | "getReminder">;+ secretValidationRuleService: Pick<TSecretValidationRuleServiceFactory, "validateSecrets">;};export type TSecretV2BridgeServiceFactory = ReturnType<typeof secretV2BridgeServiceFactory>;@@ -161,7 +163,8 @@ export const secretV2BridgeServiceFactory = ({kmsService,resourceMetadataDAL,keyStore,- reminderService+ reminderService,+ secretValidationRuleService}: TSecretV2BridgeServiceFactoryDep) => {const $validateSecretReferences = async (projectId: string,@@ -346,6 +349,13 @@ export const secretV2BridgeServiceFactory = ({project.secretDetectionIgnoreValues || []);+ await secretValidationRuleService.validateSecrets({+ projectId,+ envId: folder.envId,+ secretPath,+ secrets: [{ key: inputSecret.secretName, value: inputSecret.secretValue }]+ });+const { nestedReferences, localReferences } = getAllSecretReferences(inputSecret.secretValue);const allSecretReferences = nestedReferences.concat(localReferences.map((el) => ({ secretKey: el, secretPath, environment }))@@ -597,6 +607,17 @@ export const secretV2BridgeServiceFactory = ({);}+ // Validate against secret validation rules (key rename and/or value change)+ const finalKey = inputSecret.newSecretName || secretName;+ if (secretValue || inputSecret.newSecretName) {+ await secretValidationRuleService.validateSecrets({+ projectId,+ envId: folder.envId,+ secretPath,+ secrets: [{ key: finalKey, value: secretValue }]+ });+ }+if (secretValue) {const { nestedReferences, localReferences } = getAllSecretReferences(secretValue);const allSecretReferences = nestedReferences.concat(@@ -1862,6 +1883,13 @@ export const secretV2BridgeServiceFactory = ({project.secretDetectionIgnoreValues || []);+ await secretValidationRuleService.validateSecrets({+ projectId,+ envId: folder.envId,+ secretPath,+ secrets: deduplicatedSecrets.map((s) => ({ key: s.secretKey, value: s.secretValue }))+ });+// get all tagsconst sanitizedTagIds = [...new Set(deduplicatedSecrets.flatMap(({ tagIds = [] }) => tagIds))];const tags = sanitizedTagIds.length ? await secretTagDAL.findManyTagsById(projectId, sanitizedTagIds) : [];@@ -2223,6 +2251,25 @@ export const secretV2BridgeServiceFactory = ({project.secretDetectionIgnoreValues || []);+ // Validate against secret validation rules for all secrets being updated or created (upsert)+ const secretsToValidate = [+ ...secretsToUpdate+ .filter((el) => el.secretValue || el.newSecretName)+ .map((el) => ({ key: el.newSecretName || el.secretKey, value: el.secretValue })),+ ...(updateMode === SecretUpdateMode.Upsert+ ? secretsToCreate.map((el) => ({ key: el.secretKey, value: el.secretValue }))+ : [])+ ];+ if (secretsToValidate.length) {+ // eslint-disable-next-line no-await-in-loop+ await secretValidationRuleService.validateSecrets({+ projectId,+ envId: folder.envId,+ secretPath,+ secrets: secretsToValidate+ });+ }+const secretKeyUpdates: {secretId: string;oldSecretKey: string;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.tsnew file mode 100644index 0000000000..d708d89bbd--- /dev/null+++ b/backend/src/services/secret-validation-rule/secret-validation-rule-fns.ts@@ -0,0 +1,333 @@+import picomatch from "picomatch";+import RE2 from "re2";++import { BadRequestError } from "@app/lib/errors";++import {+ ConstraintTarget,+ ConstraintType,+ SecretValidationRuleType,+ TConstraint,+ TSecretValidationRuleInputs,+ TStaticSecretsInputs+} from "./secret-validation-rule-types";++type TExistingRule = {+ id: string;+ name: string;+ envId?: string | null;+ secretPath: string;+ type: string;+ inputs?: unknown;+};++const doPathsOverlap = (pathA: string, pathB: string): boolean => {+ const opts: picomatch.PicomatchOptions = { strictSlashes: false };++ if (picomatch.isMatch(pathA, pathB, opts) || picomatch.isMatch(pathB, pathA, opts)) {+ return true;+ }++ // When both sides are globs, check if the non-glob prefix of one is+ // reachable from the other pattern. e.g. "/a/**" vs "/a/b/*" → the+ // prefix "/a/b" is matched by "/a/**".+ const scanA = picomatch.scan(pathA);+ const scanB = picomatch.scan(pathB);++ if (scanA.isGlob && scanB.isGlob) {+ const prefixA = scanA.base || "/";+ const prefixB = scanB.base || "/";++ if (picomatch.isMatch(prefixA, pathB, opts) || picomatch.isMatch(prefixB, pathA, opts)) {+ return true;+ }+ }++ return false;+};++const doEnvironmentsOverlap = (envIdA: string | null | undefined, envIdB: string | null | undefined): boolean => {+ if (!envIdA || !envIdB) return true;+ return envIdA === envIdB;+};++/**+ * For static secrets: two rules conflict if they share any constraint of the+ * same type + appliesTo target in overlapping scope. This is because two+ * constraints of the same kind on the same target can contradict each other+ * (e.g. two different regex patterns on the value).+ */+const $checkStaticSecretsConstraintOverlap = (+ incoming: TStaticSecretsInputs,+ existing: TStaticSecretsInputs+): ConstraintType[] => {+ const overlapping: ConstraintType[] = [];++ for (const incomingConstraint of incoming.constraints) {+ for (const existingConstraint of existing.constraints) {+ if (+ incomingConstraint.type === existingConstraint.type &&+ incomingConstraint.appliesTo === existingConstraint.appliesTo+ ) {+ overlapping.push(incomingConstraint.type);+ }+ }+ }++ return overlapping;+};++type TOverlapChecker<TInputs = TSecretValidationRuleInputs> = (+ incoming: TInputs,+ existing: TInputs+) => ConstraintType[];++const overlapCheckersByType: Record<SecretValidationRuleType, TOverlapChecker> = {+ [SecretValidationRuleType.StaticSecrets]: $checkStaticSecretsConstraintOverlap as TOverlapChecker+};++export const checkForOverlappingRules = ({+ ruleType,+ envId,+ secretPath,+ inputs,+ existingRules,+ excludeRuleId+}: {+ ruleType: SecretValidationRuleType;+ envId: string | null;+ secretPath: string;+ inputs: TSecretValidationRuleInputs;+ existingRules: TExistingRule[];+ excludeRuleId?: string;+}): void => {+ const checker = overlapCheckersByType[ruleType as SecretValidationRuleType];+ if (!checker) {+ return;+ }++ for (const existing of existingRules) {+ // if the rule is the one being updated, skip the check+ if (excludeRuleId && existing.id === excludeRuleId) {+ // eslint-disable-next-line no-continue+ continue;+ }++ // if the rule type doesn't match, skip the check+ if (existing.type !== ruleType) {+ // eslint-disable-next-line no-continue+ continue;+ }++ // if the env or folder ID doesn't overlap, skip the check+ if (!doEnvironmentsOverlap(envId, existing.envId) || !doPathsOverlap(secretPath, existing.secretPath)) {+ // eslint-disable-next-line no-continue+ continue;+ }++ // at this point we're sure that the rule is overlapping with other rules, so we check if the constraints themselves are overlapping+ const overlappingConstraints = checker(inputs, existing.inputs as TSecretValidationRuleInputs);++ if (overlappingConstraints.length > 0) {+ const constraintList = [...new Set(overlappingConstraints)].join(", ");+ throw new BadRequestError({+ message:+ `Rule "${existing.name}" already enforces overlapping constraints (${constraintList}) ` ++ `on the same scope. Adjust the environment, path, or constraints to avoid conflicts.`+ });+ }+ }+};++// ---------------------------------------------------------------------------+// Constraint enforcement — evaluate rules against secrets+// ---------------------------------------------------------------------------++type TSecretToValidate = {+ key: string;+ value?: string;+};++type TValidationRule = {+ name: string;+ envId?: string | null;+ secretPath: string;+ type: string;+ inputs?: unknown;+ isActive: boolean;+};++type TValidationViolation = {+ secretKey: string;+ ruleName: string;+ constraintType: ConstraintType;+ message: string;+};++const CONSTRAINT_LABELS: Record<ConstraintType, string> = {+ [ConstraintType.MinLength]: "minimum length",+ [ConstraintType.MaxLength]: "maximum length",+ [ConstraintType.RegexPattern]: "regex pattern",+ [ConstraintType.RequiredPrefix]: "required prefix",+ [ConstraintType.RequiredSuffix]: "required suffix"+};++const TARGET_LABELS: Record<ConstraintTarget, string> = {+ [ConstraintTarget.SecretKey]: "key",+ [ConstraintTarget.SecretValue]: "value"+};++const evaluateConstraint = (constraint: TConstraint, secret: TSecretToValidate): string | null => {+ const targetValue = constraint.appliesTo === ConstraintTarget.SecretKey ? secret.key : (secret.value ?? "");+ const targetLabel = TARGET_LABELS[constraint.appliesTo];++ switch (constraint.type) {+ case ConstraintType.MinLength: {+ const min = Number(constraint.value);+ if (targetValue.length < min) {+ return `${targetLabel} must be at least ${min} characters (got ${targetValue.length})`;+ }+ return null;+ }+ case ConstraintType.MaxLength: {+ const max = Number(constraint.value);+ if (targetValue.length > max) {+ return `${targetLabel} must be at most ${max} characters (got ${targetValue.length})`;+ }+ return null;+ }+ case ConstraintType.RegexPattern: {+ const regex = new RE2(constraint.value);+ if (!regex.test(targetValue)) {+ return `${targetLabel} must match pattern ${constraint.value}`;+ }+ return null;+ }+ case ConstraintType.RequiredPrefix: {+ if (!targetValue.startsWith(constraint.value)) {+ return `${targetLabel} must start with "${constraint.value}"`;+ }+ return null;+ }+ case ConstraintType.RequiredSuffix: {+ if (!targetValue.endsWith(constraint.value)) {+ return `${targetLabel} must end with "${constraint.value}"`;+ }+ return null;+ }+ default:+ return null;+ }+};++/**+ * Evaluate static secret constraints against a set of secrets.+ */+const enforceStaticSecretsRules = (rules: TValidationRule[], secrets: TSecretToValidate[]): TValidationViolation[] => {+ const violations: TValidationViolation[] = [];++ for (const rule of rules) {+ const inputs = rule.inputs as TStaticSecretsInputs | undefined;+ if (!inputs?.constraints?.length) {+ // eslint-disable-next-line no-continue+ continue;+ }++ for (const secret of secrets) {+ for (const constraint of inputs.constraints) {+ const error = evaluateConstraint(constraint, secret);+ if (error) {+ violations.push({+ secretKey: secret.key,+ ruleName: rule.name,+ constraintType: constraint.type,+ message: error+ });+ }+ }+ }+ }++ return violations;+};++// Registry of enforcement functions per rule type.+// To add a new rule type, implement an enforcer and add it here.+type TRuleEnforcer = (rules: TValidationRule[], secrets: TSecretToValidate[]) => TValidationViolation[];++const ruleEnforcersByType: Record<SecretValidationRuleType, TRuleEnforcer> = {+ [SecretValidationRuleType.StaticSecrets]: enforceStaticSecretsRules+};++/**+ * Finds matching rules for the given scope and evaluates all constraints+ * against the provided secrets. Throws a BadRequestError if any violation+ * is found.+ *+ * @param projectRules All rules for the project (caller fetches from DAL)+ * @param envId The environment ID of the secrets being written+ * @param secretPath The path where secrets are being written (concrete, not a glob)+ * @param secrets The plaintext secrets to validate+ */+export const enforceSecretValidationRules = ({+ projectRules,+ envId,+ secretPath,+ secrets+}: {+ projectRules: TValidationRule[];+ envId: string;+ secretPath: string;+ secrets: TSecretToValidate[];+}): void => {+ if (!projectRules.length || !secrets.length) return;++ const matchingRulesByType = new Map<SecretValidationRuleType, TValidationRule[]>();++ for (const rule of projectRules) {+ if (!rule.isActive) {+ // eslint-disable-next-line no-continue+ continue;+ }++ // Check environment match (null envId on rule = all environments)+ if (rule.envId && rule.envId !== envId) {+ // eslint-disable-next-line no-continue+ continue;+ }++ // Check path match (rule.secretPath may be a glob)+ if (!picomatch.isMatch(secretPath, rule.secretPath, { strictSlashes: false })) {+ // eslint-disable-next-line no-continue+ continue;+ }++ const ruleType = rule.type as SecretValidationRuleType;+ const existing = matchingRulesByType.get(ruleType) || [];+ existing.push(rule);+ matchingRulesByType.set(ruleType, existing);+ }++ const allViolations: TValidationViolation[] = [];++ for (const [ruleType, matchedRules] of matchingRulesByType) {+ const enforcer = ruleEnforcersByType[ruleType];+ if (!enforcer) {+ // eslint-disable-next-line no-continue+ continue;+ }+ const violations = enforcer(matchedRules, secrets);+ allViolations.push(...violations);+ }++ if (allViolations.length > 0) {+ const details = allViolations.map(+ (v) =>+ `Secret "${v.secretKey}": ${v.message} (rule: "${v.ruleName}", constraint: ${CONSTRAINT_LABELS[v.constraintType]})`+ );++ throw new BadRequestError({+ message: `Secret validation failed:\n${details.join("\n")}`+ });+ }+};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.tsindex 8c3ad9f553..4a559a6b5e 100644--- a/backend/src/services/secret-validation-rule/secret-validation-rule-service.ts+++ b/backend/src/services/secret-validation-rule/secret-validation-rule-service.ts@@ -7,6 +7,7 @@ import { NotFoundError } from "@app/lib/errors";import { TProjectEnvDALFactory } from "@app/services/project-env/project-env-dal";import { TSecretValidationRuleDALFactory } from "./secret-validation-rule-dal";+import { checkForOverlappingRules, enforceSecretValidationRules } from "./secret-validation-rule-fns";import { parseSecretValidationRuleInputs } from "./secret-validation-rule-schemas";import {SecretValidationRuleType,@@ -78,18 +79,31 @@ export const secretValidationRuleServiceFactory = ({});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` });+ let envId: string | null = null;+ if (environmentSlug) {+ 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 parsedInputs = parseSecretValidationRuleInputs(type, inputs);+ const existingRules = await secretValidationRuleDAL.find({ projectId });+ checkForOverlappingRules({+ ruleType: type,+ envId,+ secretPath,+ inputs: parsedInputs,+ existingRules+ });+const rule = await secretValidationRuleDAL.create({name,description,projectId,- envId: env.id,+ envId,secretPath,type,inputs: parsedInputs@@ -124,21 +138,38 @@ export const secretValidationRuleServiceFactory = ({throw new NotFoundError({ message: `Secret validation rule with ID ${ruleId} not found` });}- let envId: string | undefined;+ let envId: string | null | 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` });+ if (environmentSlug) {+ 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;+ } else {+ envId = null;}- envId = env.id;}const ruleType = dto.type ?? existingRule.type;const ruleInputs = inputs ?? existingRule.inputs;const parsedInputs = parseSecretValidationRuleInputs(ruleType, ruleInputs);+ const finalEnvId = envId !== undefined ? envId : (existingRule.envId as string | null);+ const finalSecretPath = dto.secretPath ?? existingRule.secretPath;++ const existingRules = await secretValidationRuleDAL.find({ projectId });+ checkForOverlappingRules({+ ruleType: ruleType as SecretValidationRuleType,+ envId: finalEnvId,+ secretPath: finalSecretPath,+ inputs: parsedInputs,+ existingRules,+ excludeRuleId: ruleId+ });+const updatedRule = await secretValidationRuleDAL.updateById(ruleId, {- ...(Boolean(envId) && { envId }),+ ...(envId !== undefined && { envId }),...(Boolean(inputs) && { inputs: parsedInputs }),...dto});@@ -181,10 +212,42 @@ export const secretValidationRuleServiceFactory = ({};};+ /**+ * Fetch all rules for a project and enforce them against the given secrets.+ * Called by secret write paths before the DB transaction starts.+ */+ const validateSecrets = async ({+ projectId,+ envId,+ secretPath,+ secrets+ }: {+ projectId: string;+ envId: string;+ secretPath: string;+ secrets: { key: string; value?: string }[];+ }) => {+ if (!secrets.length) return;++ const rules = await secretValidationRuleDAL.find({ projectId });+ if (!rules.length) return;++ enforceSecretValidationRules({+ projectRules: rules.map((r) => ({+ ...r,+ isActive: r.isActive ?? true+ })),+ envId,+ secretPath,+ secrets+ });+ };+return {listByProjectId,createRule,updateRule,- deleteRule+ deleteRule,+ validateSecrets};};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 eeee1a7f92..6835d599bd 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@@ -32,7 +32,7 @@ export type TSecretValidationRuleInputs = TStaticSecretsInputs;export type TCreateSecretValidationRuleDTO = {name: string;description?: string | null;- environmentSlug: string;+ environmentSlug?: string;secretPath: string;type: SecretValidationRuleType;inputs: TSecretValidationRuleInputs;diff --git a/frontend/src/hooks/api/secretValidationRules/mutations.tsx b/frontend/src/hooks/api/secretValidationRules/mutations.tsxindex bb0228c4e2..226024eaa5 100644--- a/frontend/src/hooks/api/secretValidationRules/mutations.tsx+++ b/frontend/src/hooks/api/secretValidationRules/mutations.tsx@@ -15,7 +15,7 @@ export const useCreateSecretValidationRule = () => {return useMutation({mutationFn: async ({ projectId, ...body }: TCreateSecretValidationRuleDTO) => {const { data } = await apiRequest.post<{ rule: TSecretValidationRule }>(- `/api/v1/${projectId}/secret-validation-rules`,+ `/api/v1/projects/${projectId}/secret-validation-rules`,body);return data.rule;@@ -31,7 +31,7 @@ export const useUpdateSecretValidationRule = () => {return useMutation({mutationFn: async ({ projectId, ruleId, ...body }: TUpdateSecretValidationRuleDTO) => {const { data } = await apiRequest.patch<{ rule: TSecretValidationRule }>(- `/api/v1/${projectId}/secret-validation-rules/${ruleId}`,+ `/api/v1/projects/${projectId}/secret-validation-rules/${ruleId}`,body);return data.rule;@@ -47,7 +47,7 @@ export const useDeleteSecretValidationRule = () => {return useMutation({mutationFn: async ({ projectId, ruleId }: TDeleteSecretValidationRuleDTO) => {const { data } = await apiRequest.delete<{ rule: TSecretValidationRule }>(- `/api/v1/${projectId}/secret-validation-rules/${ruleId}`+ `/api/v1/projects/${projectId}/secret-validation-rules/${ruleId}`);return data.rule;},diff --git a/frontend/src/hooks/api/secretValidationRules/queries.tsx b/frontend/src/hooks/api/secretValidationRules/queries.tsxindex 77e867dd82..e37a4ae55c 100644--- a/frontend/src/hooks/api/secretValidationRules/queries.tsx+++ b/frontend/src/hooks/api/secretValidationRules/queries.tsx@@ -25,7 +25,7 @@ export const useListSecretValidationRules = (queryKey: secretValidationRuleKeys.list(projectId),queryFn: async () => {const { data } = await apiRequest.get<{ rules: TSecretValidationRule[] }>(- `/api/v1/${projectId}/secret-validation-rules`+ `/api/v1/projects/${projectId}/secret-validation-rules`);return data.rules;},diff --git a/frontend/src/hooks/api/secretValidationRules/types.ts b/frontend/src/hooks/api/secretValidationRules/types.tsindex 301823d4e1..4ca09aaf61 100644--- a/frontend/src/hooks/api/secretValidationRules/types.ts+++ b/frontend/src/hooks/api/secretValidationRules/types.ts@@ -32,7 +32,7 @@ export type TSecretValidationRule = {name: string;description?: string | null;projectId: string;- envId: string;+ envId: string | null;secretPath: string;type: SecretValidationRuleType;inputs: TSecretValidationRuleInputs;@@ -49,7 +49,7 @@ export type TCreateSecretValidationRuleDTO = {projectId: string;name: string;description?: string | null;- environmentSlug: string;+ environmentSlug?: string;secretPath: string;rule: {type: SecretValidationRuleType;diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretValidationRulesTab.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretValidationRulesTab.tsxindex f50d364e2b..184b9c7f45 100644--- a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretValidationRulesTab.tsx+++ b/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretValidationRulesTab.tsx@@ -307,12 +307,14 @@ export const SecretValidationRulesTab = () => {const updateRule = useUpdateSecretValidationRule();const deleteRule = useDeleteSecretValidationRule();- const resolveEnvSlug = (envId: string) => {+ const resolveEnvSlug = (envId: string | null) => {+ if (!envId) return null;const env = currentProject.environments.find((e) => e.id === envId);return env?.slug ?? null;};- const resolveEnvName = (envId: string) => {+ const resolveEnvName = (envId: string | null) => {+ if (!envId) return "All Environments";const env = currentProject.environments.find((e) => e.id === envId);return env?.name ?? envId;};@@ -350,7 +352,7 @@ export const SecretValidationRulesTab = () => {projectId: currentProject.id,name: data.name,description: data.description,- environmentSlug: data.environment ?? "",+ environmentSlug: data.environment ?? undefined,secretPath: data.folderPath,rule: {type: data.enforcement.type as string as SecretValidationRuleType,