Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(pam): size-check legacy log blob, log findById warn, guard SSH warning button

bernie-g19f28ae89023
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.ts
index 3b0c918634..9663beccc0 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
@@ -263,7 +263,24 @@ export const pamSessionAiSummaryServiceFactory = ({
if (accumulatedLogs.length > 0) {
logs = accumulatedLogs;
} else if (session.encryptedLogsBlob) {
- logs = await decryptSessionCommandLogs({ projectId, encryptedLogs: session.encryptedLogsBlob, kmsService });
+ const legacyLogs = await decryptSessionCommandLogs({
+ projectId,
+ encryptedLogs: session.encryptedLogsBlob,
+ kmsService
+ });
+ const legacyChars = legacyLogs.reduce((sum, l) => {
+ const cmd = l as TPamSessionCommandLog;
+ return sum + (cmd.input?.length ?? 0) + (cmd.output?.length ?? 0);
+ }, 0);
+ if (legacyChars >= MAX_LOG_CHARS) {
+ logger.info(
+ { sessionId },
+ `${QueueName.PamSessionAiSummary}: legacy session logs exceed size limit, skipping AI summary [sessionId=${sessionId}]`
+ );
+ await pamSessionDAL.updateById(sessionId, { aiInsightsStatus: null });
+ return;
+ }
+ logs = legacyLogs;
} else {
logger.info(
{ sessionId },
diff --git a/backend/src/services/pam-session-expiration/pam-session-expiration-queue.ts b/backend/src/services/pam-session-expiration/pam-session-expiration-queue.ts
index dcb941fff8..b5e0991b73 100644
--- a/backend/src/services/pam-session-expiration/pam-session-expiration-queue.ts
+++ b/backend/src/services/pam-session-expiration/pam-session-expiration-queue.ts
@@ -29,7 +29,16 @@ export const pamSessionExpirationServiceFactory = ({
try {
logger.info({ sessionId }, `${QueueName.PamSessionExpiration}: expiring session [sessionId=${sessionId}]`);
const updated = await pamSessionDAL.expireSessionById(sessionId);
- const session = updated > 0 ? await pamSessionDAL.findById(sessionId).catch(() => null) : null;
+ const session =
+ updated > 0
+ ? await pamSessionDAL.findById(sessionId).catch((err) => {
+ logger.warn(
+ { sessionId, err },
+ `${QueueName.PamSessionExpiration}: failed to fetch session for AI summary, skipping [sessionId=${sessionId}]`
+ );
+ return null;
+ })
+ : null;
if (updated > 0) {
logger.info(
{ sessionId },
diff --git a/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionAiInsightsSection.tsx b/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionAiInsightsSection.tsx
index bba9532a28..d71b825c26 100644
--- a/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionAiInsightsSection.tsx
+++ b/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionAiInsightsSection.tsx
@@ -7,7 +7,7 @@ import {
} from "lucide-react";
import { Spinner } from "@app/components/v2";
-import { PamSessionStatus, TPamSession } from "@app/hooks/api/pam";
+import { PamResourceType, PamSessionStatus, TPamSession } from "@app/hooks/api/pam";
type Props = {
session: TPamSession;
@@ -62,7 +62,7 @@ export const PamSessionAiInsightsSection = ({ session, onWarningClick }: Props)
{aiInsights.warnings.map((warning, i) => (
// eslint-disable-next-line react/no-array-index-key
<li key={i} className="text-xs text-amber-300">
- {warning.logIndex != null && onWarningClick ? (
+ {warning.logIndex != null && onWarningClick && session.resourceType !== PamResourceType.SSH ? (
<button
type="button"
className="inline-flex items-center gap-1.5 text-left underline decoration-dotted underline-offset-2 hover:decoration-solid"