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
add to missing pam
Thiago Araujo da Silva3adc21f50fbb
diff --git a/backend/src/server/lib/audit-safe-text-schema.test.ts b/backend/src/server/lib/audit-safe-text-schema.test.tsindex c0b3fb7590..60be390881 100644--- a/backend/src/server/lib/audit-safe-text-schema.test.ts+++ b/backend/src/server/lib/audit-safe-text-schema.test.ts@@ -4,6 +4,11 @@ import path from "node:path";import { describe, expect, test } from "vitest";import { z } from "zod";+import {+ CreatePamAccessRequestSchema,+ PamAccessRequestSchema+} from "@app/services/approval-policy/pam-access/pam-access-policy-schemas";+import { auditSafeText } from "./schemas";// Tests the wiring, not the sanitizer. Drop the wrapper or flip the multiline flag and the sanitizer@@ -88,3 +93,24 @@ describe("routes that feed audit metadata keep the wrapper", () => {expect(wrapped.length).toBeGreaterThanOrEqual(expected);});});++describe("PAM access requests on the generic approvals endpoint", () => {+ const requestData = (reason: string) => ({+ accountId: "00000000-0000-4000-8000-000000000001",+ folderId: "00000000-0000-4000-8000-000000000002",+ duration: "1h",+ reason+ });+ const createRequestData = CreatePamAccessRequestSchema.shape.requestData;++ test("create rejects unsafe reasons and keeps multiline ones", () => {+ expect(createRequestData.safeParse(requestData(`${ESC}[31mred`)).success).toBe(false);+ expect(createRequestData.safeParse(requestData(`x${String.fromCodePoint(0x202e)}y`)).success).toBe(false);+ expect(createRequestData.safeParse(requestData(`line one${LF}line two`)).success).toBe(true);+ });++ test("the response still parses a stored reason that predates the check", () => {+ const stored = PamAccessRequestSchema.shape.requestData.shape.requestData;+ expect(stored.safeParse(requestData(`${ESC}[31mred`)).success).toBe(true);+ });+});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 0d44d68559..211d62b6ca 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@@ -1,6 +1,7 @@import { z } from "zod";import { ms } from "@app/lib/ms";+import { auditSafeText } from "@app/server/lib/schemas";import {BaseApprovalPolicySchema,@@ -87,7 +88,9 @@ export const PamAccessRequestSchema = BaseApprovalRequestSchema.extend({});export const CreatePamAccessRequestSchema = BaseCreateApprovalRequestSchema.extend({- requestData: PamAccessPolicyRequestDataSchema+ requestData: PamAccessPolicyRequestDataSchema.extend({+ reason: auditSafeText(z.string().trim().max(1024), { allowMultiline: true }).optional()+ })});// Grants