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
feat(approval-policies): ensure proper path syntax
x032205fe214f21eed0
diff --git a/backend/src/services/approval-policy/pam-access/pam-access-policy-schemas.ts b/backend/src/services/approval-policy/pam-access/pam-access-policy-schemas.tsindex caa2cfa67f..eb92b836fe 100644--- a/backend/src/services/approval-policy/pam-access/pam-access-policy-schemas.ts+++ b/backend/src/services/approval-policy/pam-access/pam-access-policy-schemas.ts@@ -22,6 +22,12 @@ export const PamAccessPolicyConditionsSchema = z.object({accountPaths: z.string()+ .refine((el) => el.startsWith("/"), {+ message: "Path must start with /"+ })+ .refine((el) => !el.endsWith("/"), {+ message: "Path cannot end with /"+ }).refine((el) => {try {@@ -57,7 +63,14 @@ export const PamAccessPolicyConstraintsSchema = z.object({// Request Dataexport const PamAccessPolicyRequestDataSchema = z.object({- accountPath: z.string(),+ accountPath: z+ .string()+ .refine((el) => el.startsWith("/"), {+ message: "Path must start with /"+ })+ .refine((el) => !el.endsWith("/"), {+ message: "Path cannot end with /"+ }),accessDuration: DurationSchema});diff --git a/frontend/src/pages/pam/ApprovalsPage/components/PolicyTab/components/PolicySchema.tsx b/frontend/src/pages/pam/ApprovalsPage/components/PolicyTab/components/PolicySchema.tsxindex 6115a1a93a..ac97768d11 100644--- a/frontend/src/pages/pam/ApprovalsPage/components/PolicyTab/components/PolicySchema.tsx+++ b/frontend/src/pages/pam/ApprovalsPage/components/PolicyTab/components/PolicySchema.tsx@@ -35,6 +35,12 @@ export const PolicyFormSchema = z.object({.refine((val) => val.every((path) => path.length > 0), {message: "All account paths must be non-empty"})+ .refine((val) => val.every((path) => path.startsWith("/")), {+ message: "All account paths must start with /"+ })+ .refine((val) => val.every((path) => !path.endsWith("/")), {+ message: "All account paths cannot end with /"+ })}).array().min(1, "At least one condition is required"),diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamRequestAccountAccessModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamRequestAccountAccessModal.tsxindex f50df38f9a..1feafedce8 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamRequestAccountAccessModal.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamRequestAccountAccessModal.tsx@@ -15,10 +15,10 @@ import {ModalContent,TextArea} from "@app/components/v2";+import { UnstableAlert, UnstableAlertDescription, UnstableAlertTitle } from "@app/components/v3";import { useProject } from "@app/context";import { ApprovalPolicyType } from "@app/hooks/api/approvalPolicies";import { useCreateApprovalRequest } from "@app/hooks/api/approvalRequests/mutations";-import { UnstableAlert, UnstableAlertDescription, UnstableAlertTitle } from "@app/components/v3";type Props = {accountPath?: string;@@ -28,7 +28,15 @@ type Props = {};const formSchema = z.object({- accountPath: z.string().min(1, "Account path is required"),+ accountPath: z+ .string()+ .min(1, "Account path is required")+ .refine((el) => el.startsWith("/"), {+ message: "Path must start with /"+ })+ .refine((el) => !el.endsWith("/"), {+ message: "Path cannot end with /"+ }),accessDuration: z.string().min(1, "Access duration is required")@@ -55,6 +63,7 @@ const Content = ({ onOpenChange, accountPath, accountAccessed }: Props) => {const form = useForm<FormData>({resolver: zodResolver(formSchema),+ mode: "onChange",defaultValues: {accountPath,accessDuration: "4h",