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
fix(pam): address claude bot review comments — schema enum, empty log check, and logger.warn on silent catches
bernie-g05b2873be3e7
diff --git a/backend/src/ee/services/pam-resource/pam-resource-fns.ts b/backend/src/ee/services/pam-resource/pam-resource-fns.tsindex 0d4d8a57af..daa243e451 100644--- a/backend/src/ee/services/pam-resource/pam-resource-fns.ts+++ b/backend/src/ee/services/pam-resource/pam-resource-fns.ts@@ -1,4 +1,5 @@import { TPamResources } from "@app/db/schemas";+import { logger } from "@app/lib/logger";import { TKmsServiceFactory } from "@app/services/kms/kms-service";import { KmsDataKey } from "@app/services/kms/kms-types";@@ -136,8 +137,8 @@ export const decryptResource = async (connectionId: string;model: string;};- } catch {- // Session summary config is non-essential — fall back to null on KMS failure or corrupted blob+ } catch (err) {+ logger.warn({ err, resourceId: resource.id }, "decryptResource: failed to decrypt sessionSummaryConfig, falling back to null");}}diff --git a/backend/src/ee/services/pam-resource/pam-resource-schemas.ts b/backend/src/ee/services/pam-resource/pam-resource-schemas.tsindex 648dd57933..46779bdbdb 100644--- a/backend/src/ee/services/pam-resource/pam-resource-schemas.ts+++ b/backend/src/ee/services/pam-resource/pam-resource-schemas.ts@@ -21,7 +21,7 @@ export const SessionSummaryConfigSchema = z.object({aiInsightsEnabled: z.boolean(),connectionId: z.string().uuid(),- model: z.string()+ model: z.enum(["claude-opus-4-6", "claude-sonnet-4-6", "claude-haiku-4-5-20251001"])}).nullable().optional();diff --git a/backend/src/ee/services/pam-session/pam-session-ai-summary-queue.ts b/backend/src/ee/services/pam-session/pam-session-ai-summary-queue.tsindex 9663beccc0..7eb2472596 100644--- a/backend/src/ee/services/pam-session/pam-session-ai-summary-queue.ts+++ b/backend/src/ee/services/pam-session/pam-session-ai-summary-queue.ts@@ -268,8 +268,14 @@ export const pamSessionAiSummaryServiceFactory = ({encryptedLogs: session.encryptedLogsBlob,kmsService});- const legacyChars = legacyLogs.reduce((sum, l) => {- const cmd = l as TPamSessionCommandLog;+ const isSshLegacy = resource.resourceType === PamResource.SSH;+ const legacyChars = legacyLogs.reduce((sum, e) => {+ if (isSshLegacy) {+ const termEvent = e as TTerminalEvent;+ if (termEvent.eventType !== "input") return sum;+ return sum + (termEvent.data ? Buffer.from(termEvent.data, "base64").length : 0);+ }+ const cmd = e as TPamSessionCommandLog;return sum + (cmd.input?.length ?? 0) + (cmd.output?.length ?? 0);}, 0);if (legacyChars >= MAX_LOG_CHARS) {@@ -314,6 +320,16 @@ export const pamSessionAiSummaryServiceFactory = ({: 0;const formattedLogs = formatLogsForSummary(logs, resourceType);++ if (!formattedLogs) {+ logger.info(+ { sessionId },+ `${QueueName.PamSessionAiSummary}: no usable log content after formatting, skipping [sessionId=${sessionId}]`+ );+ await pamSessionDAL.updateById(sessionId, { aiInsightsStatus: null });+ return;+ }+const { system, user } = buildSummaryPrompt({resourceType,resourceName: resource.name,diff --git a/backend/src/ee/services/pam-session/pam-session-fns.ts b/backend/src/ee/services/pam-session/pam-session-fns.tsindex f66f84bd3a..48112516cc 100644--- a/backend/src/ee/services/pam-session/pam-session-fns.ts+++ b/backend/src/ee/services/pam-session/pam-session-fns.ts@@ -1,4 +1,5 @@import { TPamSessionEventBatches, TPamSessions } from "@app/db/schemas";+import { logger } from "@app/lib/logger";import { TKmsServiceFactory } from "@app/services/kms/kms-service";import { KmsDataKey } from "@app/services/kms/kms-types";@@ -62,8 +63,8 @@ export const decryptSession = async (summary: string;warnings: { text: string; logIndex?: number }[];};- } catch {- // AI insights are non-essential — fall back to null on KMS failure or corrupted blob+ } catch (err) {+ logger.warn({ err }, "decryptSession: failed to decrypt aiInsights, falling back to null");}}diff --git a/backend/src/ee/services/pam-session/pam-session-summary-fns.ts b/backend/src/ee/services/pam-session/pam-session-summary-fns.tsindex 3e8b19ae3b..691cf55e55 100644--- a/backend/src/ee/services/pam-session/pam-session-summary-fns.ts+++ b/backend/src/ee/services/pam-session/pam-session-summary-fns.ts@@ -87,7 +87,7 @@ const SessionSummarySchema = z.object({warnings: z.array(z.object({text: z.string(),- logIndex: z.number().int().optional()+ logIndex: z.number().int().min(1).optional()}))});