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
misc greptile reviews
Andrey37a32cc512ad
diff --git a/backend/src/ee/services/pam-access-request/pam-access-request-service.ts b/backend/src/ee/services/pam-access-request/pam-access-request-service.tsindex efda9a33ac..b0e1864df5 100644--- a/backend/src/ee/services/pam-access-request/pam-access-request-service.ts+++ b/backend/src/ee/services/pam-access-request/pam-access-request-service.ts@@ -78,7 +78,7 @@ type TPamAccessRequestServiceFactoryDep = {| "revokeGrant"| "getActiveGrant"| "getAccessStatuses"- | "getRequestableScopeIds"+ | "getRequestableScopes"| "getBypassableScopeIds"| "reapScope"| "reapSubject"@@ -217,9 +217,22 @@ export const pamAccessRequestServiceFactory = ({];if (dedupedBreakGlassUsers.length > 0 && requestedApprovers.length === 0) {- throw new BadRequestError({- message: "Break-glass users can only be configured on a folder that has approvers"- });+ // An omitted config leaves the stored rules in place, so they still count+ const rules = autoApproval+ ? autoApproval.rules+ : (+ await approvalPolicyService.getScopeConfiguration(+ ApprovalPolicyType.PamAccess,+ ApprovalPolicyScope.PamFolder,+ folderId,+ toApprovalActor(ctx)+ )+ ).autoApproval.rules;+ if (!rules.length) {+ throw new BadRequestError({+ message: "Break-glass users can only be configured on a folder that has approvers or auto-approval rules"+ });+ }}await pamAccessApprovalResource.verifyPolicyActors?.({@@ -574,16 +587,25 @@ export const pamAccessRequestServiceFactory = ({return new Map(accountIds.map((accountId, i) => [accountId, statuses[i]]));};- // A folder counts as "configured" only when its policy has an approver or an auto-approval rule, so an- // empty policy surfaces the unavailable flag.- const getFolderPolicyConfigured = async (folderIds: string[]): Promise<Set<string>> =>- new Set(- await approvalPolicyService.getRequestableScopeIds(- ApprovalPolicyType.PamAccess,- ApprovalPolicyScope.PamFolder,- folderIds- )+ // A folder is configured for an account when its policy has an approver, or auto-approval rules the account's+ // template lets decide its requests. Anything else surfaces the unavailable flag.+ const getFolderPolicyConfigured = async (folderIds: string[]) => {+ const hasApproversByFolderId = new Map(+ (+ await approvalPolicyService.getRequestableScopes(+ ApprovalPolicyType.PamAccess,+ ApprovalPolicyScope.PamFolder,+ folderIds+ )+ ).map(({ scopeId, hasApprovers }) => [scopeId, hasApprovers]));+ return {+ isConfiguredFor: (folderId: string, allowAutoApproval: boolean) => {+ const hasApprovers = hasApproversByFolderId.get(folderId);+ return hasApprovers !== undefined && (hasApprovers || allowAutoApproval);+ }+ };+ };// Of the given folders, the ones where this actor is a named break-glass user. Drives whether the// account list offers the break-glass action at all.diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.tsindex 3b8a1a646b..845627a734 100644--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@ -403,8 +403,10 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>return accounts.map((a, idx) => {const { accessibilityIssues, isAccessible } = computeAccessibility(a);- const { requiresApproval, requireReason, allowBreakGlass } = resolveAccessControls(a.templatePolicies);- if (requiresApproval && a.folderId && !foldersWithApprovalPolicy.has(a.folderId)) {+ const { requiresApproval, requireReason, allowBreakGlass, allowAutoApproval } = resolveAccessControls(+ a.templatePolicies+ );+ if (requiresApproval && a.folderId && !foldersWithApprovalPolicy.isConfiguredFor(a.folderId, allowAutoApproval)) {accessibilityIssues.push(PamAccountAccessibilityIssue.NoApprovalConfig);}const statusEntry = accessStatusMap.get(a.id);@@ -1323,11 +1325,12 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>return {accounts: accounts.map((a) => {- const { requiresApproval, requireReason, requireMfa, allowBreakGlass } = resolveAccessControls(- a.templatePolicies- );+ const { requiresApproval, requireReason, requireMfa, allowBreakGlass, allowAutoApproval } =+ resolveAccessControls(a.templatePolicies);const statusEntry = accessStatusMap.get(a.id);- const hasPolicyConfigured = a.folderId ? foldersWithApprovalPolicy.has(a.folderId) : false;+ const hasPolicyConfigured = a.folderId+ ? foldersWithApprovalPolicy.isConfiguredFor(a.folderId, allowAutoApproval)+ : false;let disabledReason: string | null = null;if (requiresApproval && !hasPolicyConfigured) {disabledReason =diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.tsindex 580007e367..5977dd445c 100644--- a/backend/src/ee/services/pam-session/pam-session-service.ts+++ b/backend/src/ee/services/pam-session/pam-session-service.ts@@ -555,7 +555,9 @@ export const pamSessionServiceFactory = ({details: {requireReason: policy.requireReason,hasPendingRequest: statusMap.get(account.id)?.accessStatus === ApprovalAccessStatus.Pending,- hasApprovalPolicy: Boolean(account.folderId && foldersWithApprovalPolicy.has(account.folderId))+ hasApprovalPolicy: Boolean(+ account.folderId && foldersWithApprovalPolicy.isConfiguredFor(account.folderId, policy.allowAutoApproval)+ )}});}diff --git a/backend/src/services/approval-policy/approval-policy-dal.ts b/backend/src/services/approval-policy/approval-policy-dal.tsindex ed2facc27c..ff408243c9 100644--- a/backend/src/services/approval-policy/approval-policy-dal.ts+++ b/backend/src/services/approval-policy/approval-policy-dal.ts@@ -375,11 +375,12 @@ export const approvalPolicyDALFactory = (db: TDbClient) => {// Of the given scopes, those whose policy can grant a request: it has an approver or an auto-approval rule.// A policy row with neither does not count as "configured".- const findRequestableScopeIds = async (args: {+ // Scopes whose policy has an approver or an auto-approval rule, and whether it has an approver+ const findRequestableScopes = async (args: {type: string;scopeType: string;scopeIds: string[];- }): Promise<string[]> => {+ }): Promise<{ scopeId: string; hasApprovers: boolean }[]> => {try {if (!args.scopeIds.length) return [];const dbInstance = db.replicaNode();@@ -418,14 +419,29 @@ export const approvalPolicyDALFactory = (db: TDbClient) => {]);});})- .distinct(`${TableName.ApprovalPolicies}.scopeId`)- .select<{ scopeId: string | null }[]>(`${TableName.ApprovalPolicies}.scopeId`)) as {- scopeId: string | null;- }[];+ .select(`${TableName.ApprovalPolicies}.scopeId`)+ .select(+ dbInstance.raw(+ `bool_or(exists (select 1 from ?? inner join ?? on ??.?? = ??.?? where ??.?? = ??.??)) as "hasApprovers"`,+ [+ TableName.ApprovalPolicySteps,+ TableName.ApprovalPolicyStepApprovers,+ TableName.ApprovalPolicyStepApprovers,+ "policyStepId",+ TableName.ApprovalPolicySteps,+ "id",+ TableName.ApprovalPolicySteps,+ "policyId",+ TableName.ApprovalPolicies,+ "id"+ ]+ )+ )+ .groupBy(`${TableName.ApprovalPolicies}.scopeId`)) as { scopeId: string | null; hasApprovers: boolean }[];- return rows.map((r) => r.scopeId).filter((id): id is string => Boolean(id));+ return rows.flatMap((r) => (r.scopeId ? [{ scopeId: r.scopeId, hasApprovers: Boolean(r.hasApprovers) }] : []));} catch (error) {- throw new DatabaseError({ error, name: "Find requestable scope ids" });+ throw new DatabaseError({ error, name: "Find requestable scopes" });}};@@ -581,7 +597,7 @@ export const approvalPolicyDALFactory = (db: TDbClient) => {findSecretAccessPolicyByEnvIdAndSecretPath,findPoliciesWhereSubjectIsApprover,isProjectApprover,- findRequestableScopeIds,+ findRequestableScopes,deleteStepApproversBySubject,deleteBypassersBySubject,deleteUserStepApproversInProjectsdiff --git a/backend/src/services/approval-policy/approval-policy-service.ts b/backend/src/services/approval-policy/approval-policy-service.tsindex 1aee5a64b9..63444d74c4 100644--- a/backend/src/services/approval-policy/approval-policy-service.ts+++ b/backend/src/services/approval-policy/approval-policy-service.ts@@ -920,6 +920,7 @@ export const approvalPolicyServiceFactory = ({: undefined;const updatedPolicy = await approvalPolicyDAL.transaction(async (tx) => {+ await approvalPolicyDAL.findByIdForUpdate(policyId, tx);const updateDoc: Partial<TApprovalPolicies> = {};if (name !== undefined) {@@ -2392,14 +2393,10 @@ export const approvalPolicyServiceFactory = ({});};- const getRequestableScopeIds = (- policyType: ApprovalPolicyType,- scopeType: ApprovalPolicyScope,- scopeIds: string[]- ) =>+ const getRequestableScopes = (policyType: ApprovalPolicyType, scopeType: ApprovalPolicyScope, scopeIds: string[]) =>scopeIds.length === 0- ? Promise.resolve([] as string[])- : approvalPolicyDAL.findRequestableScopeIds({ type: policyType, scopeType, scopeIds });+ ? Promise.resolve([] as { scopeId: string; hasApprovers: boolean }[])+ : approvalPolicyDAL.findRequestableScopes({ type: policyType, scopeType, scopeIds });const getBypassableScopeIds = async (policyType: ApprovalPolicyType,@@ -2799,7 +2796,7 @@ export const approvalPolicyServiceFactory = ({$resource(policyType).matchPolicy(projectId, inputs),getActiveGrant,getAccessStatuses,- getRequestableScopeIds,+ getRequestableScopes,getBypassableScopeIds,reapScope,reapSubject,diff --git a/backend/src/services/approval-policy/auto-approval/auto-approval-dal.ts b/backend/src/services/approval-policy/auto-approval/auto-approval-dal.tsindex 5bbee4c0f7..a18af187f8 100644--- a/backend/src/services/approval-policy/auto-approval/auto-approval-dal.ts+++ b/backend/src/services/approval-policy/auto-approval/auto-approval-dal.ts@@ -85,7 +85,6 @@ export const approvalPolicyAutoApprovalDALFactory = (db: TDbClient) => {// Replaces a policy's inputs and rules, the way policy steps are replacedconst replaceForPolicy = async (policyId: string, config: TAutoApprovalConfig, tx: Knex) => {- await tx(TableName.ApprovalPolicies).where({ id: policyId }).forUpdate().first();await rulesOrm.delete({ policyId }, tx);await inputsOrm.delete({ policyId }, tx);diff --git a/backend/src/services/approval-policy/auto-approval/auto-approval-schemas.ts b/backend/src/services/approval-policy/auto-approval/auto-approval-schemas.tsindex 488fb2d002..e596d0737e 100644--- a/backend/src/services/approval-policy/auto-approval/auto-approval-schemas.ts+++ b/backend/src/services/approval-policy/auto-approval/auto-approval-schemas.ts@@ -101,6 +101,7 @@ export const AutoApprovalOutcomeSchema = zexport const AutoApprovalInputDetailsSchema = z.object({connectionId: z.string().uuid(),+ connectionName: z.string(),subject: z.string(),label: z.string(),placeholder: z.string()diff --git a/backend/src/services/approval-policy/auto-approval/auto-approval-service.ts b/backend/src/services/approval-policy/auto-approval/auto-approval-service.tsindex 9fe83ef265..9b180cc8cd 100644--- a/backend/src/services/approval-policy/auto-approval/auto-approval-service.ts+++ b/backend/src/services/approval-policy/auto-approval/auto-approval-service.ts@@ -242,15 +242,18 @@ export const autoApprovalServiceFactory = ({if (!stored?.inputs.length) return [];const connections = await appConnectionDAL.find({ $in: { id: stored.inputs.map((input) => input.connectionId) } });- const appById = new Map(connections.map((connection) => [connection.id, connection.app]));+ const connectionById = new Map(connections.map((connection) => [connection.id, connection]));return stored.inputs.flatMap((input) => {- const app = appById.get(input.connectionId);- const definition = app ? getAutoApprovalProvider(app)?.subjects[input.subject]?.input : undefined;- if (!definition) return [];+ const connection = connectionById.get(input.connectionId);+ const definition = connection+ ? getAutoApprovalProvider(connection.app)?.subjects[input.subject]?.input+ : undefined;+ if (!connection || !definition) return [];return [{connectionId: input.connectionId,+ connectionName: connection.name,subject: input.subject,label: definition.label,placeholder: definition.placeholderdiff --git a/backend/src/services/approval-policy/auto-approval/providers/jira-auto-approval-provider.test.ts b/backend/src/services/approval-policy/auto-approval/providers/jira-auto-approval-provider.test.tsindex 2d00324da2..267ee21003 100644--- a/backend/src/services/approval-policy/auto-approval/providers/jira-auto-approval-provider.test.ts+++ b/backend/src/services/approval-policy/auto-approval/providers/jira-auto-approval-provider.test.ts@@ -1,4 +1,13 @@+import { AxiosError, AxiosResponse } from "axios";+import { BadRequestError } from "@app/lib/errors";+import {+ getJiraIssue,+ listJiraIssueApprovals,+ TJiraApproval,+ TJiraIssue,+ TJiraUser+} from "@app/services/app-connection/jira";import { TAutoApprovalContext } from "../auto-approval-types";import {@@ -9,6 +18,13 @@ import {TJiraTicketFacts} from "./jira-auto-approval-provider";+vi.mock("@app/lib/logger", () => ({ logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn(), debug: vi.fn() } }));+vi.mock("@app/services/app-connection/jira", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@app/services/app-connection/jira")>()),+ getJiraIssue: vi.fn(),+ listJiraIssueApprovals: vi.fn()+}));+const conn = { credentials: { instanceUrl: "https://acme.atlassian.net" } } as Parameters<typeof parseJiraTicket>[1];const ctx: TAutoApprovalContext = {@@ -105,3 +121,99 @@ describe("Jira ticket checks", () => {expect(check(JiraTicketConstraint.Approved, facts({ approval: { approved: true, reason: null } })).pass).toBe(true);});});++describe("resolving a Jira ticket", () => {+ const { resolve } = JIRA_AUTO_APPROVAL_PROVIDER.subjects[JIRA_SUBMITTED_TICKET_SUBJECT];++ const issue = (assignee: TJiraUser | null = null): TJiraIssue => ({+ id: "10001",+ key: "PAY-123",+ fields: { status: { id: "1", name: "Approved" }, project: { id: "1", key: "PAY", name: "Payments" }, assignee }+ });+ const approval = (finalDecision: TJiraApproval["finalDecision"], epochMillis: number): TJiraApproval => ({+ id: String(epochMillis),+ finalDecision,+ createdDate: { epochMillis }+ });+ const jiraError = (status: number) =>+ new AxiosError("Request failed", "ERR_BAD_REQUEST", undefined, undefined, { status } as AxiosResponse);++ const resolveTicket = (constraintIds: string[]) =>+ resolve(+ conn as Parameters<typeof resolve>[0],+ "PAY-123",+ ctx,+ constraintIds,+ {} as Parameters<typeof resolve>[4]+ ) as Promise<TJiraTicketFacts>;++ beforeEach(() => {+ vi.mocked(getJiraIssue).mockReset().mockResolvedValue(issue());+ vi.mocked(listJiraIssueApprovals).mockReset();+ });++ test("uses Jira's newest approval decision, whatever order it arrives in", async () => {+ vi.mocked(listJiraIssueApprovals).mockResolvedValue([approval("declined", 2), approval("approved", 1)]);+ expect((await resolveTicket([JiraTicketConstraint.Approved])).approval).toEqual({+ approved: false,+ reason: "PAY-123 isn't approved in Jira"+ });++ vi.mocked(listJiraIssueApprovals).mockResolvedValue([approval("approved", 2), approval("pending", 1)]);+ expect((await resolveTicket([JiraTicketConstraint.Approved])).approval).toEqual({ approved: true, reason: null });+ });++ test("explains tickets that have no approvals to read", async () => {+ vi.mocked(listJiraIssueApprovals).mockResolvedValue([]);+ expect((await resolveTicket([JiraTicketConstraint.Approved])).approval?.reason).toBe(+ "PAY-123 has no approvals in Jira yet"+ );++ vi.mocked(listJiraIssueApprovals).mockRejectedValue(jiraError(404));+ expect((await resolveTicket([JiraTicketConstraint.Approved])).approval?.reason).toBe(+ "PAY-123 isn't a Jira Service Management request, or the Jira connection can't see its approvals"+ );+ });++ test("fails closed on failed reads without repeating Jira's error", async () => {+ vi.mocked(listJiraIssueApprovals).mockRejectedValue(new Error("upstream detail"));+ expect((await resolveTicket([JiraTicketConstraint.Approved])).approval).toEqual({+ approved: false,+ reason: "Couldn't read Jira approvals on PAY-123"+ });++ vi.mocked(getJiraIssue).mockRejectedValue(jiraError(500));+ await expect(resolveTicket([])).rejects.toThrow(+ new BadRequestError({ message: "Couldn't read Jira ticket PAY-123" })+ );++ vi.mocked(getJiraIssue).mockRejectedValue(jiraError(404));+ await expect(resolveTicket([])).rejects.toThrow(+ "Jira ticket PAY-123 doesn't exist, or the Jira connection can't see it"+ );+ });++ test("matches the assignee only by a visible email address", async () => {+ const assigneeOf = async (assignee: TJiraUser | null) => {+ vi.mocked(getJiraIssue).mockResolvedValue(issue(assignee));+ return (await resolveTicket([JiraTicketConstraint.AssignedToRequester])).assignee;+ };++ expect(await assigneeOf({ emailAddress: "[email protected]" })).toEqual({ matchesRequester: true, reason: null });+ expect((await assigneeOf({ emailAddress: "" }))?.reason).toBe(+ "Jira doesn't share the email address of PAY-123's assignee"+ );+ expect((await assigneeOf({ emailAddress: "[email protected]" }))?.reason).toBe(+ "PAY-123 isn't assigned to the requester"+ );+ expect((await assigneeOf(null))?.reason).toBe("PAY-123 isn't assigned to anyone");+ });++ test("only reads approvals when a rule checks them", async () => {+ const ticket = await resolveTicket([JiraTicketConstraint.Status]);++ expect(listJiraIssueApprovals).not.toHaveBeenCalled();+ expect(ticket.approval).toBeNull();+ expect(ticket.status).toBe("Approved");+ });+});diff --git a/frontend/src/hooks/api/approvalPolicies/types.ts b/frontend/src/hooks/api/approvalPolicies/types.tsindex 102244536e..1e0c46640d 100644--- a/frontend/src/hooks/api/approvalPolicies/types.ts+++ b/frontend/src/hooks/api/approvalPolicies/types.ts@@ -114,6 +114,7 @@ export type TAutoApprovalOption = { value: string; label: string };// A field the request form shows for one of the policy's inputsexport type TAutoApprovalInputDetails = {connectionId: string;+ connectionName: string;subject: string;label: string;placeholder: string;diff --git a/frontend/src/pages/pam/components/auto-approval/AutoApprovalCard.tsx b/frontend/src/pages/pam/components/auto-approval/AutoApprovalCard.tsxindex 197ef65070..5fc96e8f11 100644--- a/frontend/src/pages/pam/components/auto-approval/AutoApprovalCard.tsx+++ b/frontend/src/pages/pam/components/auto-approval/AutoApprovalCard.tsx@@ -30,6 +30,7 @@ import {} from "@app/hooks/api/approvalPolicies";import {+ AUTO_APPROVAL_LIMITS,findSubject,getDefaultRuleConditions,newKey,@@ -63,9 +64,13 @@ export const AutoApprovalCard = ({showErrors,hasApprovers}: Props) => {- const { data: catalog = [], isPending } = useQuery(- approvalPolicyQuery.autoApprovalCatalog({ policyType, scope, scopeId })- );+ const {+ data: catalog = [],+ isPending,+ isError,+ isFetching,+ refetch+ } = useQuery(approvalPolicyQuery.autoApprovalCatalog({ policyType, scope, scopeId }));const availableInputs = catalog.flatMap((connection) =>connection.subjects@@ -106,9 +111,16 @@ export const AutoApprovalCard = ({]});+ const addRuleBlocker =+ draft.rules.length >= AUTO_APPROVAL_LIMITS.rules+ ? `A folder can have at most ${AUTO_APPROVAL_LIMITS.rules} rules.`+ : undefined;+let addInputBlocker: string | undefined;if (catalog.length === 0) {addInputBlocker = "Add an app connection that supports auto-approval.";+ } else if (draft.inputs.length >= AUTO_APPROVAL_LIMITS.inputs) {+ addInputBlocker = `A folder can have at most ${AUTO_APPROVAL_LIMITS.inputs} request form fields.`;} else if (availableInputs.length === 0) {addInputBlocker = "Every available field is already added.";}@@ -123,9 +135,22 @@ export const AutoApprovalCard = ({</CardDescription></CardHeader><CardContent className="flex flex-col gap-6">- {isPending ? (- <Skeleton className="h-24 w-full" />- ) : (+ {isPending && <Skeleton className="h-24 w-full" />}+ {isError && (+ <div className="flex flex-col items-center gap-3 rounded-md border border-border p-8 text-center text-sm text-muted">+ Couldn't load the app connections auto-approval can use.+ <Button+ type="button"+ variant="outline"+ size="sm"+ isPending={isFetching}+ onClick={() => refetch()}+ >+ Retry+ </Button>+ </div>+ )}+ {!isPending && !isError && (<><section className="flex flex-col gap-3"><div className="flex items-start justify-between gap-4">@@ -220,10 +245,18 @@ export const AutoApprovalCard = ({<section className="flex flex-col gap-3"><div className="flex items-center justify-between gap-4"><FieldTitle>Rules</FieldTitle>- <Button type="button" variant="outline" size="sm" onClick={addRule}>- <Plus />- Add Rule- </Button>+ <DisabledReason reason={addRuleBlocker}>+ <Button+ type="button"+ variant="outline"+ size="sm"+ isDisabled={Boolean(addRuleBlocker)}+ onClick={addRule}+ >+ <Plus />+ Add Rule+ </Button>+ </DisabledReason></div>{!hasApprovers && draft.rules.length > 0 && (diff --git a/frontend/src/pages/pam/components/auto-approval/AutoApprovalRequestInputs.tsx b/frontend/src/pages/pam/components/auto-approval/AutoApprovalRequestInputs.tsxindex a3699315cd..78ff1c5003 100644--- a/frontend/src/pages/pam/components/auto-approval/AutoApprovalRequestInputs.tsx+++ b/frontend/src/pages/pam/components/auto-approval/AutoApprovalRequestInputs.tsx@@ -29,10 +29,14 @@ export const AutoApprovalRequestInputs = ({ inputs, values, onChange }: Props) =<>{inputs.map((input) => {const key = getInputKey(input);+ // Connections can ask for the same kind of record, and only the connection tells them apart+ const isAmbiguous = inputs.filter((other) => other.label === input.label).length > 1;return (<Field key={key}><FieldLabel htmlFor={`auto-approval-${key}`}>- {input.label} <span className="font-normal text-muted">(optional)</span>+ {input.label}+ {isAmbiguous && ` from ${input.connectionName}`}{" "}+ <span className="font-normal text-muted">(optional)</span></FieldLabel><FieldContent><Inputdiff --git a/frontend/src/pages/pam/components/auto-approval/AutoApprovalRuleCard.tsx b/frontend/src/pages/pam/components/auto-approval/AutoApprovalRuleCard.tsxindex f900f7c0ea..3cdc8721da 100644--- a/frontend/src/pages/pam/components/auto-approval/AutoApprovalRuleCard.tsx+++ b/frontend/src/pages/pam/components/auto-approval/AutoApprovalRuleCard.tsx@@ -26,6 +26,7 @@ import {import {ASSIGNED_TO_REQUESTER_CONSTRAINT,+ AUTO_APPROVAL_LIMITS,findSubject,getConditionError,getRuleError,@@ -228,6 +229,8 @@ export const AutoApprovalRuleCard = ({let addConditionBlocker: string | undefined;if (choices.length === 0) {addConditionBlocker = "Add a field under Request Form Fields first.";+ } else if (rule.conditions.length >= AUTO_APPROVAL_LIMITS.conditions) {+ addConditionBlocker = `A rule can have at most ${AUTO_APPROVAL_LIMITS.conditions} conditions.`;} else if (menuGroups.length === 0) {addConditionBlocker = "Every available check is already in this rule.";}diff --git a/frontend/src/pages/pam/components/auto-approval/autoApprovalDraft.ts b/frontend/src/pages/pam/components/auto-approval/autoApprovalDraft.tsindex 2ff1e30488..56b0746f48 100644--- a/frontend/src/pages/pam/components/auto-approval/autoApprovalDraft.ts+++ b/frontend/src/pages/pam/components/auto-approval/autoApprovalDraft.ts@@ -23,6 +23,15 @@ export type TAutoApprovalDraft = {rules: TDraftRule[];};+// The API's limits, checked here so an over-limit config is flagged beside its control instead of failing on save+export const AUTO_APPROVAL_LIMITS = {+ inputs: 10,+ rules: 20,+ conditions: 20,+ values: 50,+ valueLength: 255+};+// Mirrors the Jira provider's constraint; other providers name theirs the same wayexport const ASSIGNED_TO_REQUESTER_CONSTRAINT = "assigned-to-requester";@@ -86,6 +95,12 @@ export const getConditionError = (): string | null => {if (!condition.connectionId || !condition.subject) return "Choose what to check";if (!condition.constraint) return "Choose a check";+ if (condition.values.length > AUTO_APPROVAL_LIMITS.values) {+ return `Choose at most ${AUTO_APPROVAL_LIMITS.values} values`;+ }+ if (condition.values.some((value) => value.length > AUTO_APPROVAL_LIMITS.valueLength)) {+ return `Values can be at most ${AUTO_APPROVAL_LIMITS.valueLength} characters`;+ }const constraint = findSubject(catalog,@@ -105,6 +120,9 @@ export const getConditionError = (export const getRuleError = (rule: TDraftRule): string | null => {if (!rule.name.trim()) return "Name this rule";if (rule.conditions.length === 0) return "Add at least one condition";+ if (rule.conditions.length > AUTO_APPROVAL_LIMITS.conditions) {+ return `A rule can have at most ${AUTO_APPROVAL_LIMITS.conditions} conditions`;+ }return null;};