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(pam): add command blocking and session log masking support (#7004)
Saif Ur Rahmanb4f64ed0e163
diff --git a/backend/src/db/migrations/20260603030053_pam-revamp.ts b/backend/src/db/migrations/20260612142201_pam-revamp.tssimilarity index 100%rename from backend/src/db/migrations/20260603030053_pam-revamp.tsrename to backend/src/db/migrations/20260612142201_pam-revamp.tsdiff --git a/backend/src/ee/routes/v1/pam-routers/pam-account-template-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-account-template-router.tsindex 3e8938b75b..d327fe85c5 100644--- a/backend/src/ee/routes/v1/pam-routers/pam-account-template-router.ts+++ b/backend/src/ee/routes/v1/pam-routers/pam-account-template-router.ts@@ -3,7 +3,7 @@ import z from "zod";import { PamAccountTemplatesSchema } from "@app/db/schemas";import { EventType } from "@app/ee/services/audit-log/audit-log-types";import { PamAccountType } from "@app/ee/services/pam/pam-enums";-import { PamTemplateSettingsSchema } from "@app/ee/services/pam-account-template/pam-account-template-schemas";+import { PamTemplateSettingsInputSchema } from "@app/ee/services/pam-account-template/pam-account-template-schemas";import { ApiDocsTags } from "@app/lib/api-docs/constants";import { readLimit, writeLimit } from "@app/server/config/rateLimiter";import { slugSchema } from "@app/server/lib/schemas";@@ -105,7 +105,7 @@ export const registerPamAccountTemplateRouter = async (server: FastifyZodProvidedescription: z.string().trim().max(256).optional().describe("Optional description"),type: z.nativeEnum(PamAccountType).describe("The account type this template applies to"),policies: z.record(z.unknown()).optional().describe("Policy values keyed by policy type"),- settings: PamTemplateSettingsSchema.optional().describe("Template settings"),+ settings: PamTemplateSettingsInputSchema.optional().describe("Template settings"),gatewayId: z.string().uuid().optional().describe("Default gateway ID for accounts using this template"),gatewayPoolId: z.string().uuid().optional().describe("Default gateway pool ID"),recordingConnectionId: z.string().uuid().optional().describe("Recording storage connection ID")@@ -173,7 +173,7 @@ export const registerPamAccountTemplateRouter = async (server: FastifyZodProvidename: slugSchema({ field: "Name" }).optional().describe("New name"),description: z.string().trim().max(256).nullable().optional().describe("New description"),policies: z.record(z.unknown()).optional().describe("Policy values keyed by policy type"),- settings: PamTemplateSettingsSchema.optional().describe("Updated settings"),+ settings: PamTemplateSettingsInputSchema.optional().describe("Updated settings"),gatewayId: z.string().uuid().nullable().optional().describe("New gateway ID"),gatewayPoolId: z.string().uuid().nullable().optional().describe("New gateway pool ID"),recordingConnectionId: z.string().uuid().nullable().optional().describe("New recording connection ID")diff --git a/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-session-router.tsindex b4a3aa739c..675d549b7e 100644--- a/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts+++ b/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts@@ -4,6 +4,7 @@ import z from "zod";import { PamSessionsSchema } from "@app/db/schemas";import { EventType, UserAgentType } from "@app/ee/services/audit-log/audit-log-types";import { PamAccountType, PamSessionStatus } from "@app/ee/services/pam/pam-enums";+import { PamPolicyRulesSchema } from "@app/ee/services/pam/pam-policies";import { PamRecordingStorageBackend } from "@app/ee/services/pam-session-recording/pam-recording-enums";import { ApiDocsTags } from "@app/lib/api-docs/constants";import { BadRequestError, NotFoundError } from "@app/lib/errors";@@ -139,7 +140,8 @@ export const registerPamSessionRouter = async (server: FastifyZodProvider) => {projectId: z.string(),sessionId: z.string()})- .nullable()+ .nullable(),+ policyRules: PamPolicyRulesSchema})}},@@ -177,7 +179,8 @@ export const registerPamSessionRouter = async (server: FastifyZodProvider) => {return {credentials: result.credentials,- recording: result.recording+ recording: result.recording,+ policyRules: result.policyRules ?? null};}});diff --git a/backend/src/ee/services/pam-account-template/pam-account-template-schemas.ts b/backend/src/ee/services/pam-account-template/pam-account-template-schemas.tsindex 6a7e38ff2b..b00fbcf4fa 100644--- a/backend/src/ee/services/pam-account-template/pam-account-template-schemas.ts+++ b/backend/src/ee/services/pam-account-template/pam-account-template-schemas.ts@@ -2,6 +2,7 @@ import { z } from "zod";import { AWSRegion } from "@app/services/app-connection/app-connection-enums";+import { patternsStringSchema } from "../pam/pam-policies";import { PamRecordingStorageBackend } from "../pam-session-recording/pam-recording-enums";export const PamPasswordConstraintsSchema = z.object({@@ -28,7 +29,11 @@ export const PamTemplateSettingsSchema = z.object({recordingStorageBackend: z.nativeEnum(PamRecordingStorageBackend).default(PamRecordingStorageBackend.Postgres),recordingS3Config: PamRecordingS3ConfigSchema.optional(),passwordConstraints: PamPasswordConstraintsSchema.optional(),- sessionLogMaskingPatterns: z.array(z.string().min(1).max(500)).max(20).optional()+ sessionLogMaskingPatterns: z.string().optional()+});++export const PamTemplateSettingsInputSchema = PamTemplateSettingsSchema.extend({+ sessionLogMaskingPatterns: patternsStringSchema().optional()});export type TPamTemplateSettings = z.infer<typeof PamTemplateSettingsSchema>;diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.tsindex 94f7c613c8..3437e5f47b 100644--- a/backend/src/ee/services/pam-session/pam-session-service.ts+++ b/backend/src/ee/services/pam-session/pam-session-service.ts@@ -28,7 +28,14 @@ import {TActorContext,verifyProductMembership} from "../pam/pam-permission";-import { resolveAccessControls } from "../pam/pam-policies";+import {+ PamPolicyType,+ PamSettingType,+ policyAppliesTo,+ resolveAccessControls,+ resolvePolicy,+ splitPatternString+} from "../pam/pam-policies";import { TPamAccountDALFactory } from "../pam-account/pam-account-dal";import {extractGatewayTarget,@@ -244,6 +251,28 @@ export const pamSessionServiceFactory = ({};}+ const commandBlockingPatterns = policyAppliesTo(+ PamPolicyType.CommandBlocking,+ account.accountType as PamAccountType+ )+ ? splitPatternString(resolvePolicy(account.templatePolicies, PamPolicyType.CommandBlocking))+ : [];++ const parsedSettings = PamTemplateSettingsSchema.safeParse(account.templateSettings ?? {});+ const maskingPatterns = parsedSettings.success+ ? splitPatternString(parsedSettings.data.sessionLogMaskingPatterns)+ : [];++ const policyRules =+ commandBlockingPatterns.length > 0 || maskingPatterns.length > 0+ ? {+ ...(commandBlockingPatterns.length > 0+ ? { [PamPolicyType.CommandBlocking]: { patterns: commandBlockingPatterns } }+ : {}),+ ...(maskingPatterns.length > 0 ? { [PamSettingType.SessionLogMasking]: { patterns: maskingPatterns } } : {})+ }+ : null;+const normalizedConnectionDetails = validateConnectionDetails(account.accountType as PamAccountType,connectionDetails@@ -256,6 +285,7 @@ export const pamSessionServiceFactory = ({return {credentials: { ...normalizedConnectionDetails, ...credentials },recording,+ policyRules,projectId: session.projectId,accountId: session.accountId,accountName: session.accountName,diff --git a/backend/src/ee/services/pam/CLAUDE.md b/backend/src/ee/services/pam/CLAUDE.mdindex f8c70bd50e..11e3e7241f 100644--- a/backend/src/ee/services/pam/CLAUDE.md+++ b/backend/src/ee/services/pam/CLAUDE.md@@ -136,15 +136,21 @@ A registry entry flows automatically to:- **`GET /pam/accounts/types`** (`applicablePolicies`), so the frontend renders the right editors per account type with no per-type wiring.- **`validatePolicyValues`**, used by template create/update to reject policies that don't apply to the type or fail their schema (returns a result object; the caller maps `ok: false` to a `BadRequestError`).-Every current policy is server-enforced: `resolveAccessControls` reads the reason/MFA/duration gates and they're applied in `pam-session`/`pam-web-access`. A gateway-enforced policy would instead pass its value to the gateway in `getSessionCredentials` (not currently wired, no policy needs it yet).+Policies are either server-enforced or gateway-enforced:+- **Server-enforced** (MFA, reason, duration): `resolveAccessControls` reads the values and they're applied in `pam-session`/`pam-web-access` before the session starts.+- **Gateway-enforced** (command blocking): the value is read via `resolvePolicy` in `getSessionCredentials` and included in the `policyRules` response. The gateway compiles the patterns and enforces them during the session.++Command blocking (`PamPolicyType.CommandBlocking`) is the first gateway-enforced policy. It applies only to SSH (`appliesTo: [PamAccountType.SSH]`). Stored as a newline-separated string of regex patterns, split into an array at the credentials endpoint before sending to the gateway.++Session log masking (`sessionLogMaskingPatterns`) is a **setting**, not a policy. It lives in `PamTemplateSettingsSchema` and is read from `account.templateSettings` in `getSessionCredentials`. It also flows to the gateway via the `policyRules` response alongside command blocking patterns.### Adding a New Policy1. Add the value to `PamPolicyType` and an entry to `PAM_POLICY_DEFINITIONS` in `pam/pam-policies.ts` (`label`, `description`, `appliesTo`, `schema`). Mirror the enum value in `frontend/src/hooks/api/pam/enums.ts`.2. Register the policy in `POLICY_EDITORS` (`frontend/src/pages/pam/components/policyEditors/`), keyed by the new `PamPolicyType`. Reuse an existing editor when the value shape matches (`BooleanPolicyEditor` for a `z.boolean()`, `DurationPolicyEditor` for a number); only write a new editor component for a novel value shape. Each editor receives `{ label, description, value, onChange }` and owns its own layout, booleans render inline, others vertical.-3. Enforcement: read it where it's enforced. A server-enforced policy extends `resolveAccessControls` and is applied in `pam-session`/`pam-web-access`. A gateway-enforced policy passes its value to the gateway in `getSessionCredentials`.+3. Enforcement: read it where it's enforced. A server-enforced policy extends `resolveAccessControls` and is applied in `pam-session`/`pam-web-access`. A gateway-enforced policy is read via `resolvePolicy` in `getSessionCredentials`, split/transformed as needed, and included in the `policyRules` response (see command blocking for the pattern). Both the service return and the router response schema must be updated atomically -- Fastify's Zod serializer strips unknown keys.-No migration, no router or response-schema change, and no DB default.+No migration, no router or response-schema change (beyond `policyRules` for gateway-enforced policies), and no DB default.## Session Lifecyclediff --git a/backend/src/ee/services/pam/pam-policies.test.ts b/backend/src/ee/services/pam/pam-policies.test.tsindex e64b8618e3..9688f26181 100644--- a/backend/src/ee/services/pam/pam-policies.test.ts+++ b/backend/src/ee/services/pam/pam-policies.test.ts@@ -10,6 +10,17 @@ describe("getApplicablePolicies", () => {expect(keys).toContain(PamPolicyType.RequireReason);expect(keys).toContain(PamPolicyType.MaxSessionDuration);});++ test("returns command blocking only for SSH", () => {+ const sshKeys = getApplicablePolicies(PamAccountType.SSH).map((p) => p.key);+ expect(sshKeys).toContain(PamPolicyType.CommandBlocking);++ const pgKeys = getApplicablePolicies(PamAccountType.Postgres).map((p) => p.key);+ expect(pgKeys).not.toContain(PamPolicyType.CommandBlocking);++ const mysqlKeys = getApplicablePolicies(PamAccountType.MySQL).map((p) => p.key);+ expect(mysqlKeys).not.toContain(PamPolicyType.CommandBlocking);+ });});describe("validatePolicyValues", () => {@@ -38,6 +49,40 @@ describe("validatePolicyValues", () => {expect(validatePolicyValues(PamAccountType.SSH, { [PamPolicyType.RequireMfa]: "nope" }).ok).toBe(false);expect(validatePolicyValues(PamAccountType.SSH, { [PamPolicyType.MaxSessionDuration]: 10 }).ok).toBe(false);});++ test("accepts valid command blocking patterns for SSH", () => {+ const result = validatePolicyValues(PamAccountType.SSH, {+ [PamPolicyType.CommandBlocking]: "rm -rf.*\nsudo su\nshutdown"+ });+ expect(result.ok).toBe(true);+ });++ test("rejects command blocking for non-SSH types", () => {+ const result = validatePolicyValues(PamAccountType.Postgres, {+ [PamPolicyType.CommandBlocking]: "rm -rf.*"+ });+ expect(result.ok).toBe(false);+ });++ test("rejects non-string command blocking values", () => {+ expect(validatePolicyValues(PamAccountType.SSH, { [PamPolicyType.CommandBlocking]: ["rm"] }).ok).toBe(false);+ expect(validatePolicyValues(PamAccountType.SSH, { [PamPolicyType.CommandBlocking]: true }).ok).toBe(false);+ });++ test("rejects command blocking with too many patterns", () => {+ const tooMany = Array.from({ length: 21 }, (_, i) => `pattern${i}`).join("\n");+ expect(validatePolicyValues(PamAccountType.SSH, { [PamPolicyType.CommandBlocking]: tooMany }).ok).toBe(false);+ });++ test("rejects command blocking with a pattern exceeding 500 chars", () => {+ const longPattern = "a".repeat(501);+ expect(validatePolicyValues(PamAccountType.SSH, { [PamPolicyType.CommandBlocking]: longPattern }).ok).toBe(false);+ });++ test("rejects invalid regex patterns", () => {+ expect(validatePolicyValues(PamAccountType.SSH, { [PamPolicyType.CommandBlocking]: "[unclosed" }).ok).toBe(false);+ expect(validatePolicyValues(PamAccountType.SSH, { [PamPolicyType.CommandBlocking]: "(unmatched" }).ok).toBe(false);+ });});describe("resolveAccessControls", () => {diff --git a/backend/src/ee/services/pam/pam-policies.ts b/backend/src/ee/services/pam/pam-policies.tsindex 9c21af15ca..cd48d4e450 100644--- a/backend/src/ee/services/pam/pam-policies.ts+++ b/backend/src/ee/services/pam/pam-policies.ts@@ -1,3 +1,4 @@+import RE2 from "re2";import { z } from "zod";import { PamAccountType } from "./pam-enums";@@ -5,9 +6,49 @@ import { PamAccountType } from "./pam-enums";export enum PamPolicyType {RequireMfa = "require-mfa",RequireReason = "require-reason",- MaxSessionDuration = "max-session-duration"+ MaxSessionDuration = "max-session-duration",+ CommandBlocking = "command-blocking"}+export enum PamSettingType {+ SessionLogMasking = "session-log-masking"+}++export const splitPatternString = (raw: unknown): string[] => {+ if (typeof raw !== "string" || !raw.trim()) return [];+ return raw+ .split(/\r?\n/)+ .map((p) => p.trim())+ .filter(Boolean);+};++export const patternsStringSchema = (maxPatterns = 20, maxPatternLength = 500) =>+ z+ .string()+ .max(maxPatterns * (maxPatternLength + 1))+ .refine(+ (val) => {+ const patterns = splitPatternString(val);+ return patterns.length <= maxPatterns && patterns.every((p) => p.length <= maxPatternLength);+ },+ { message: `Maximum ${maxPatterns} patterns, each up to ${maxPatternLength} characters` }+ )+ .refine(+ (val) => {+ const patterns = splitPatternString(val);+ return patterns.every((p) => {+ try {+ // eslint-disable-next-line no-new+ new RE2(p);+ return true;+ } catch {+ return false;+ }+ });+ },+ { message: "One or more patterns are not valid regular expressions" }+ );+type TPamPolicyDefinition = {label: string;description: string;@@ -33,6 +74,12 @@ export const PAM_POLICY_DEFINITIONS: Record<PamPolicyType, TPamPolicyDefinition>description: "Maximum session length in seconds (60 to 86400).",appliesTo: "all",schema: z.number().int().min(60).max(86400)+ },+ [PamPolicyType.CommandBlocking]: {+ label: "Command Blocking",+ description: "Matching commands will be rejected (one regex per line).",+ appliesTo: [PamAccountType.SSH],+ schema: patternsStringSchema()}};@@ -92,7 +139,7 @@ export const validatePolicyValues = (return { ok: true, data };};-const resolvePolicy = (policyMap: unknown, policy: PamPolicyType): unknown => {+export const resolvePolicy = (policyMap: unknown, policy: PamPolicyType): unknown => {if (!policyMap || typeof policyMap !== "object") return null;const parsed = PAM_POLICY_DEFINITIONS[policy].schema.safeParse((policyMap as Record<string, unknown>)[policy]);return parsed.success ? parsed.data : null;@@ -104,6 +151,16 @@ export type TPamAccessControls = {maxSessionDurationSeconds: number | null;};+const PamPolicyRulePatternSchema = z.object({ patterns: z.array(z.string()) });++export const PamPolicyRulesSchema = z+ .object({+ [PamPolicyType.CommandBlocking]: PamPolicyRulePatternSchema.optional(),+ [PamSettingType.SessionLogMasking]: PamPolicyRulePatternSchema.optional()+ })+ .nullable()+ .optional();+export const resolveAccessControls = (policyMap: unknown): TPamAccessControls => {const duration = resolvePolicy(policyMap, PamPolicyType.MaxSessionDuration);return {diff --git a/frontend/src/hooks/api/pam/enums.ts b/frontend/src/hooks/api/pam/enums.tsindex 3a9ed47aca..7d33f217e0 100644--- a/frontend/src/hooks/api/pam/enums.ts+++ b/frontend/src/hooks/api/pam/enums.ts@@ -15,7 +15,8 @@ export enum PamAccountType {export enum PamPolicyType {RequireMfa = "require-mfa",RequireReason = "require-reason",- MaxSessionDuration = "max-session-duration"+ MaxSessionDuration = "max-session-duration",+ CommandBlocking = "command-blocking"}export enum SessionChannelType {diff --git a/frontend/src/hooks/api/pam/mutations.tsx b/frontend/src/hooks/api/pam/mutations.tsxindex b1df4f59ed..ab8c135d4b 100644--- a/frontend/src/hooks/api/pam/mutations.tsx+++ b/frontend/src/hooks/api/pam/mutations.tsx@@ -164,9 +164,10 @@ export const useCreatePamAccountTemplate = () => {});};-export const useUpdatePamAccountTemplate = () => {+export const useUpdatePamAccountTemplate = ({ skipValidationToast = false } = {}) => {const queryClient = useQueryClient();return useMutation({+ meta: skipValidationToast ? { skipValidationToast: true } : undefined,mutationFn: async ({ templateId, ...params }: TUpdatePamAccountTemplateDTO) => {const { data } = await apiRequest.patch<{template: TPamAccountTemplate;diff --git a/frontend/src/pages/pam/PamSessionsPage/components/SessionDetailSheet.tsx b/frontend/src/pages/pam/PamSessionsPage/components/SessionDetailSheet.tsxindex 99d6b8e62e..baa2f7171b 100644--- a/frontend/src/pages/pam/PamSessionsPage/components/SessionDetailSheet.tsx+++ b/frontend/src/pages/pam/PamSessionsPage/components/SessionDetailSheet.tsx@@ -58,7 +58,12 @@ const getLogText = (log: TPamSessionLog): string => {return [log.input, log.output].filter(Boolean).join(" ");}if ("data" in log) {- return log.data;+ try {+ const bytes = Uint8Array.from(atob(log.data), (c) => c.charCodeAt(0));+ return new TextDecoder("utf-8").decode(bytes);+ } catch {+ return log.data;+ }}if ("method" in log) {return `${log.method} ${log.url}`;diff --git a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsxindex 6350791342..5f957a74bb 100644--- a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx+++ b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx@@ -1,6 +1,7 @@import { useEffect, useState } from "react";import { Controller, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";+import axios from "axios";import { AlertTriangleIcon, Ban } from "lucide-react";import { z } from "zod";@@ -38,6 +39,7 @@ import {usePamAccountTypeMap,useUpdatePamAccountTemplate} from "@app/hooks/api/pam";+import { ApiErrorTypes, TApiErrors } from "@app/hooks/api/types";import { PamSheetTab, usePamSheetState } from "@app/hooks/usePamSheetState";import { formatDetailDate, PamDetailSheet } from "../../components/PamDetailSheet";@@ -62,7 +64,10 @@ const settingsSchema = zs3Bucket: z.string().optional(),s3Region: z.string().optional(),s3KeyPrefix: z.string().optional(),- policies: z.record(z.unknown())+ policies: z.record(z.unknown()),+ settings: z.object({+ sessionLogMaskingPatterns: z.string().optional()+ })}).superRefine((data, ctx) => {if (data.recordingStorageBackend !== "aws-s3") return;@@ -203,7 +208,7 @@ const SettingsTab = ({onDirtyChange?: (isDirty: boolean) => void;}) => {const { data: template, isLoading } = useGetPamAccountTemplate(templateId);- const updateTemplate = useUpdatePamAccountTemplate();+ const updateTemplate = useUpdatePamAccountTemplate({ skipValidationToast: true });const { currentProject } = useProject();const { data: awsConnections = [] } = useListAvailableAppConnections(AppConnection.AWS,@@ -215,6 +220,7 @@ const SettingsTab = ({control,handleSubmit,reset,+ setError,setValue,watch,formState: { isDirty }@@ -228,7 +234,8 @@ const SettingsTab = ({s3Bucket: "",s3Region: "",s3KeyPrefix: "",- policies: {}+ policies: {},+ settings: { sessionLogMaskingPatterns: "" }}});@@ -250,7 +257,10 @@ const SettingsTab = ({s3Bucket: s3Config.bucket ?? "",s3Region: s3Config.region ?? "",s3KeyPrefix: s3Config.keyPrefix ?? "",- policies: (template.policies as Record<string, unknown>) ?? {}+ policies: (template.policies as Record<string, unknown>) ?? {},+ settings: {+ sessionLogMaskingPatterns: (settings.sessionLogMaskingPatterns as string) ?? ""+ }});}}, [template, reset]);@@ -293,6 +303,13 @@ const SettingsTab = ({delete settings.recordingS3Config;}+ const maskingPatterns = data.settings.sessionLogMaskingPatterns?.trim();+ if (maskingPatterns) {+ settings.sessionLogMaskingPatterns = maskingPatterns;+ } else {+ delete settings.sessionLogMaskingPatterns;+ }+updateTemplate.mutate({templateId,@@ -304,6 +321,30 @@ const SettingsTab = ({data.recordingStorageBackend === "aws-s3" ? data.recordingConnectionId : null},{+ onError: (error) => {+ if (axios.isAxiosError(error)) {+ const responseData = error.response?.data as TApiErrors | undefined;+ if (responseData?.error === ApiErrorTypes.ValidationError) {+ const maskingIssue = responseData.message.find((issue) =>+ issue.path.join(".").includes("sessionLogMaskingPatterns")+ );+ if (maskingIssue) {+ setError("settings.sessionLogMaskingPatterns", {+ type: "server",+ message: maskingIssue.message+ });+ return;+ }+ }+ const msg = (error.response?.data as { message?: string })?.message;+ createNotification({+ type: "error",+ text: typeof msg === "string" ? msg : "Failed to update template"+ });+ return;+ }+ createNotification({ type: "error", text: "Failed to update template" });+ },onSuccess: async (result) => {createNotification({ type: "success", text: "Template updated" });const { corsProbeUrl } = result as { corsProbeUrl?: string | null };@@ -527,6 +568,32 @@ const SettingsTab = ({/></>)}++ <Controller+ control={control}+ name="settings.sessionLogMaskingPatterns"+ render={({ field, fieldState }) => (+ <Field>+ <FieldLabel>Session Log Masking</FieldLabel>+ <FieldContent>+ <TextArea+ rows={5}+ placeholder={"rm\\s+-rf.*\npassword\\s*=\\s*\\S+\n\\b\\d{3}-\\d{2}-\\d{4}\\b"}+ value={field.value ?? ""}+ isError={!!fieldState.error}+ onChange={(e) => {+ const val = e.target.value;+ field.onChange(val.trim() ? val : "");+ }}+ />+ <FieldDescription>+ Matching content in session recordings will be masked (one regex per line).+ </FieldDescription>+ <FieldError>{fieldState.error?.message}</FieldError>+ </FieldContent>+ </Field>+ )}+ /></CardContent></Card>diff --git a/frontend/src/pages/pam/components/policyEditors/TextAreaPolicyEditor.tsx b/frontend/src/pages/pam/components/policyEditors/TextAreaPolicyEditor.tsxnew file mode 100644index 0000000000..f6e73f9ed6--- /dev/null+++ b/frontend/src/pages/pam/components/policyEditors/TextAreaPolicyEditor.tsx@@ -0,0 +1,31 @@+import { Field, FieldContent, FieldDescription, FieldLabel, TextArea } from "@app/components/v3";++import { PolicyEditorProps } from "./types";++export const TextAreaPolicyEditor = ({+ label,+ description,+ value,+ onChange,+ placeholder+}: PolicyEditorProps & { placeholder?: string }) => {+ const text = typeof value === "string" ? value : "";++ return (+ <Field>+ <FieldLabel>{label}</FieldLabel>+ <FieldContent>+ <TextArea+ rows={5}+ placeholder={placeholder}+ value={text}+ onChange={(e) => {+ const val = e.target.value;+ onChange(val.trim() ? val : null);+ }}+ />+ <FieldDescription>{description}</FieldDescription>+ </FieldContent>+ </Field>+ );+};diff --git a/frontend/src/pages/pam/components/policyEditors/index.tsx b/frontend/src/pages/pam/components/policyEditors/index.tsxindex 041f4a1f66..6939a161f1 100644--- a/frontend/src/pages/pam/components/policyEditors/index.tsx+++ b/frontend/src/pages/pam/components/policyEditors/index.tsx@@ -4,12 +4,21 @@ import { PamPolicyType } from "@app/hooks/api/pam";import { BooleanPolicyEditor } from "./BooleanPolicyEditor";import { DurationPolicyEditor } from "./DurationPolicyEditor";+import { TextAreaPolicyEditor } from "./TextAreaPolicyEditor";import { PolicyEditorProps } from "./types";+const DEFAULT_PATTERN_PLACEHOLDER =+ "rm\\s+-rf.*\npassword\\s*=\\s*\\S+\n\\b\\d{3}-\\d{2}-\\d{4}\\b";++const CommandBlockingEditor = (props: PolicyEditorProps) => (+ <TextAreaPolicyEditor {...props} placeholder={DEFAULT_PATTERN_PLACEHOLDER} />+);+export const POLICY_EDITORS: Partial<Record<PamPolicyType, ComponentType<PolicyEditorProps>>> = {[PamPolicyType.RequireMfa]: BooleanPolicyEditor,[PamPolicyType.RequireReason]: BooleanPolicyEditor,- [PamPolicyType.MaxSessionDuration]: DurationPolicyEditor+ [PamPolicyType.MaxSessionDuration]: DurationPolicyEditor,+ [PamPolicyType.CommandBlocking]: CommandBlockingEditor};export type { PolicyEditorProps } from "./types";