Skip to content

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

cleanup

Daniel Hougaard94598880fd05
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
index 3209e9606e..7858e35044 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
@@ -104,13 +104,28 @@ export const secretValidationRuleServiceFactory = ({
const parsedInputs = parseSecretValidationRuleInputs(type, inputs);
+ const { decryptor: ruleInputsDecryptor } = await kmsService.createCipherPairWithDataKey({
+ type: KmsDataKey.SecretManager,
+ projectId
+ });
+
const existingRules = await secretValidationRuleDAL.find({ projectId });
checkForOverlappingRules({
ruleType: type,
envId,
secretPath,
inputs: parsedInputs,
- existingRules
+ existingRules: existingRules.map((r) => ({
+ id: r.id,
+ name: r.name,
+ envId: r.envId,
+ secretPath: r.secretPath,
+ type: r.type,
+ inputs: parseSecretValidationRuleInputs(
+ r.type,
+ JSON.parse(ruleInputsDecryptor({ cipherTextBlob: r.encryptedInputs }).toString()) as unknown
+ )
+ }))
});
const { encryptor: ruleInputsEncryptor } = await kmsService.createCipherPairWithDataKey({
@@ -196,7 +211,17 @@ export const secretValidationRuleServiceFactory = ({
envId: finalEnvId,
secretPath: finalSecretPath,
inputs: parsedInputs,
- existingRules,
+ existingRules: existingRules.map((r) => ({
+ id: r.id,
+ name: r.name,
+ envId: r.envId,
+ secretPath: r.secretPath,
+ type: r.type,
+ inputs: parseSecretValidationRuleInputs(
+ r.type,
+ JSON.parse(ruleInputsDecryptor({ cipherTextBlob: r.encryptedInputs }).toString()) as unknown
+ )
+ })),
excludeRuleId: ruleId
});
diff --git a/frontend/src/components/notifications/Notifications.tsx b/frontend/src/components/notifications/Notifications.tsx
index 1639cc5cf6..121e840d69 100644
--- a/frontend/src/components/notifications/Notifications.tsx
+++ b/frontend/src/components/notifications/Notifications.tsx
@@ -23,7 +23,11 @@ export const NotificationContent = ({
return (
<div className="msg-container">
{title && <div className="text-md mb-1 font-medium">{title}</div>}
- <div className={title ? "text-sm whitespace-pre-line text-neutral-400" : "text-md whitespace-pre-line"}>
+ <div
+ className={
+ title ? "text-sm whitespace-pre-line text-neutral-400" : "text-md whitespace-pre-line"
+ }
+ >
{text}
</div>
{children && <div className="mt-2">{children}</div>}
diff --git a/frontend/src/pages/secret-manager/SettingsPage/SettingsPage.tsx b/frontend/src/pages/secret-manager/SettingsPage/SettingsPage.tsx
index e60b982dfa..e17219226e 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 { SecretValidationRulesTab } from "./components/SecretEnforcementTab";
+import { SecretValidationRulesTab } from "./components/SecretValidationRulesTab";
import { WebhooksTab } from "./components/WebhooksTab";
import { WorkflowIntegrationTab } from "./components/WorkflowIntegrationSection";
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/ConstraintCard.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesTab/ConstraintCard.tsx
similarity index 98%
rename from frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/ConstraintCard.tsx
rename to frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesTab/ConstraintCard.tsx
index ff58127ba4..bf1daadda4 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/ConstraintCard.tsx
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesTab/ConstraintCard.tsx
@@ -19,7 +19,7 @@ import {
ConstraintTarget,
ConstraintType,
TRuleForm
-} from "./SecretEnforcementTab.utils";
+} from "./SecretValidationRulesTab.utils";
type Props = {
index: number;
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretValidationRulesTab.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesTab/SecretValidationRulesTab.tsx
similarity index 90%
rename from frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretValidationRulesTab.tsx
rename to frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesTab/SecretValidationRulesTab.tsx
index 78455e4832..75a42c1af4 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretValidationRulesTab.tsx
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesTab/SecretValidationRulesTab.tsx
@@ -2,10 +2,18 @@
import { useState } from "react";
import { Controller, FormProvider, useFieldArray, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
-import { EllipsisVerticalIcon, PencilIcon, PlusIcon, TrashIcon } from "lucide-react";
+import { EllipsisVerticalIcon, InfoIcon, PencilIcon, PlusIcon, TrashIcon } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
Badge,
Button,
Select,
@@ -20,6 +28,9 @@ import {
SheetHeader,
SheetTitle,
Switch,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
UnstableDropdownMenu,
UnstableDropdownMenuContent,
UnstableDropdownMenuItem,
@@ -55,7 +66,7 @@ import {
ruleFormSchema,
RuleType,
TRuleForm
-} from "./SecretEnforcementTab.utils";
+} from "./SecretValidationRulesTab.utils";
const RuleFormContent = ({
defaultValues,
@@ -298,6 +309,7 @@ type SheetState =
export const SecretValidationRulesTab = () => {
const { currentProject } = useProject();
const [sheetState, setSheetState] = useState<SheetState>({ open: false });
+ const [deleteRuleId, setDeleteRuleId] = useState<string | null>(null);
const { data: rules = [], isLoading } = useListSecretValidationRules({
projectId: currentProject.id
@@ -319,12 +331,15 @@ export const SecretValidationRulesTab = () => {
return env?.name ?? envId;
};
- const handleDelete = async (ruleId: string) => {
+ const handleDelete = async () => {
+ if (!deleteRuleId) return;
try {
- await deleteRule.mutateAsync({ projectId: currentProject.id, ruleId });
+ await deleteRule.mutateAsync({ projectId: currentProject.id, ruleId: deleteRuleId });
createNotification({ text: "Rule deleted", type: "success" });
} catch {
createNotification({ text: "Failed to delete rule", type: "error" });
+ } finally {
+ setDeleteRuleId(null);
}
};
@@ -448,31 +463,36 @@ export const SecretValidationRulesTab = () => {
<UnstableTableBody>
{rules.map((rule) => (
<UnstableTableRow key={rule.id}>
- <UnstableTableCell>
- <div>
+ <UnstableTableCell className="py-3">
+ <div className="flex items-center">
<span className="text-sm font-medium text-foreground">{rule.name}</span>
{rule.description && (
- <p className="text-xs text-muted">{rule.description}</p>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <InfoIcon className="ml-1.5 size-3.5 text-muted" />
+ </TooltipTrigger>
+ <TooltipContent>{rule.description}</TooltipContent>
+ </Tooltip>
)}
</div>
</UnstableTableCell>
- <UnstableTableCell>
+ <UnstableTableCell className="py-3">
<Badge variant="neutral">
{RULE_TYPE_LABELS[rule.type as string as RuleType] ?? rule.type}
</Badge>
</UnstableTableCell>
- <UnstableTableCell>
+ <UnstableTableCell className="py-3">
<div className="flex items-center gap-1.5">
<Badge variant="neutral">{resolveEnvName(rule.envId)}</Badge>
<Badge variant="neutral">{rule.secretPath}</Badge>
</div>
</UnstableTableCell>
- <UnstableTableCell>
+ <UnstableTableCell className="py-3">
<Badge variant={rule.isActive ? "success" : "neutral"}>
{rule.isActive ? "Active" : "Inactive"}
</Badge>
</UnstableTableCell>
- <UnstableTableCell>
+ <UnstableTableCell className="py-3">
<UnstableDropdownMenu>
<UnstableDropdownMenuTrigger asChild>
<UnstableIconButton aria-label="Actions" variant="ghost" size="xs">
@@ -490,7 +510,7 @@ export const SecretValidationRulesTab = () => {
</UnstableDropdownMenuItem>
<UnstableDropdownMenuItem
variant="danger"
- onClick={() => handleDelete(rule.id)}
+ onClick={() => setDeleteRuleId(rule.id)}
>
<TrashIcon className="mr-2 size-4" />
Delete
@@ -508,6 +528,26 @@ export const SecretValidationRulesTab = () => {
</div>
</div>
+ <AlertDialog
+ open={deleteRuleId !== null}
+ onOpenChange={(open) => !open && setDeleteRuleId(null)}
+ >
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>Delete Validation Rule</AlertDialogTitle>
+ <AlertDialogDescription>
+ Are you sure you want to delete this rule? This action cannot be undone.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
+ <AlertDialogAction variant="danger" onClick={handleDelete}>
+ Delete
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
+
<Sheet open={sheetState.open} onOpenChange={(open) => !open && handleClose()}>
<SheetContent className="flex h-full flex-col gap-y-0 overflow-y-auto sm:max-w-lg">
<SheetHeader className="border-b">
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretEnforcementTab.utils.ts b/frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesTab/SecretValidationRulesTab.utils.ts
similarity index 100%
rename from frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/SecretEnforcementTab.utils.ts
rename to frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesTab/SecretValidationRulesTab.utils.ts
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/index.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesTab/index.tsx
similarity index 100%
rename from frontend/src/pages/secret-manager/SettingsPage/components/SecretEnforcementTab/index.tsx
rename to frontend/src/pages/secret-manager/SettingsPage/components/SecretValidationRulesTab/index.tsx
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/index.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/index.tsx
index 62ae922097..7b58012626 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 { SecretValidationRulesTab } from "./SecretEnforcementTab";
export { SecretTagsSection } from "./SecretTagsSection";
+export { SecretValidationRulesTab } from "./SecretValidationRulesTab";