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
address reviews
x032205b8f175a43dac
diff --git a/frontend/src/hooks/api/pam/session-playback/queries.tsx b/frontend/src/hooks/api/pam/session-playback/queries.tsxindex ced1e5816b..ff1319ce62 100644--- a/frontend/src/hooks/api/pam/session-playback/queries.tsx+++ b/frontend/src/hooks/api/pam/session-playback/queries.tsx@@ -4,7 +4,6 @@ import { useQuery } from "@tanstack/react-query";import { apiRequest } from "@app/config/request";import {- DecryptedChunkResult,decryptOneChunk,detectChunkGaps,importSessionKeyFromBase64,@@ -63,36 +62,6 @@ export type PlaybackDecryptState = {const fallbackUrlBuilderFor = (sessionId: string) => (chunkIndex: number) =>`/api/v1/pam/sessions/${sessionId}/chunks/${chunkIndex}/ciphertext`;-const collectChunkResult = (- r: Awaited<DecryptedChunkResult>,- events: unknown[],- brokenChunks: TBrokenChunkMarker[],- inlineMarkers = false-): boolean => {- if (r.ok) {- events.push(...r.events);- if (events.length > PAM_PLAYBACK_MAX_TOTAL_EVENTS) {- brokenChunks.push({- __brokenChunk: true,- chunkIndex: r.chunkIndex,- reason: "limit",- message: `Total event count exceeds playback limit of ${PAM_PLAYBACK_MAX_TOTAL_EVENTS}; remaining chunks skipped`- });- return true;- }- } else {- const marker: TBrokenChunkMarker = {- __brokenChunk: true,- chunkIndex: r.chunkIndex,- reason: r.reason,- message: r.message- };- brokenChunks.push(marker);- if (inlineMarkers) events.push(marker);- }- return false;-};-export const useDecryptedSessionLogs = (sessionId: string,enabled = true,@@ -115,14 +84,16 @@ export const useDecryptedSessionLogs = (// Refs for incremental decryption across poll cycles (active sessions only)const sessionKeyRef = useRef<CryptoKey | null>(null);const decryptedIndicesRef = useRef(new Set<number>());- const accEventsRef = useRef<unknown[]>([]);+ const accChunkEventsRef = useRef(new Map<number, unknown[]>());+ const accEventCountRef = useRef(0);const accBrokenRef = useRef<TBrokenChunkMarker[]>([]);const prevSessionIdRef = useRef(sessionId);if (prevSessionIdRef.current !== sessionId) {sessionKeyRef.current = null;decryptedIndicesRef.current = new Set();- accEventsRef.current = [];+ accChunkEventsRef.current = new Map();+ accEventCountRef.current = 0;accBrokenRef.current = [];prevSessionIdRef.current = sessionId;}@@ -205,6 +176,7 @@ export const useDecryptedSessionLogs = (if (cancelled) return;const chunk = newChunks[ci];+ decryptedIndicesRef.current.add(chunk.chunkIndex);// eslint-disable-next-line no-await-in-loopconst r = await decryptOneChunk({chunk,@@ -214,22 +186,63 @@ export const useDecryptedSessionLogs = (fallbackUrlBuilder});- decryptedIndicesRef.current.add(chunk.chunkIndex);+ if (cancelled) return;- if (collectChunkResult(r, accEventsRef.current, accBrokenRef.current)) break;+ if (r.ok) {+ accChunkEventsRef.current.set(chunk.chunkIndex, r.events);+ accEventCountRef.current += r.events.length;+ if (accEventCountRef.current > PAM_PLAYBACK_MAX_TOTAL_EVENTS) {+ accBrokenRef.current.push({+ __brokenChunk: true,+ chunkIndex: r.chunkIndex,+ reason: "limit",+ message: `Total event count exceeds playback limit of ${PAM_PLAYBACK_MAX_TOTAL_EVENTS}; remaining chunks skipped`+ });+ break;+ }+ } else {+ const marker: TBrokenChunkMarker = {+ __brokenChunk: true,+ chunkIndex: r.chunkIndex,+ reason: r.reason,+ message: r.message+ };+ accBrokenRef.current.push(marker);+ accChunkEventsRef.current.set(chunk.chunkIndex, [marker]);+ }}- if (!cancelled) {- setState({- legacy: false,- loading: isActive && !bundle.sessionComplete,- events: [...accEventsRef.current],- brokenChunks: [...accBrokenRef.current],- missingChunks,- totalChunks: sortedChunks.length,- totalDurationMs- });+ if (cancelled) return;++ if (bundle.sessionComplete) {+ for (let mi = 0; mi < missingChunks.length; mi += 1) {+ const idx = missingChunks[mi];+ if (!accChunkEventsRef.current.has(idx)) {+ const marker: TBrokenChunkMarker = {+ __brokenChunk: true,+ chunkIndex: idx,+ reason: "missing",+ message: `Chunk ${idx} was not found in the recording`+ };+ accBrokenRef.current.push(marker);+ accChunkEventsRef.current.set(idx, [marker]);+ }+ }}++ const orderedEvents = [...accChunkEventsRef.current.keys()]+ .sort((a, b) => a - b)+ .flatMap((key) => accChunkEventsRef.current.get(key) ?? []);++ setState({+ legacy: false,+ loading: isActive && !bundle.sessionComplete,+ events: orderedEvents,+ brokenChunks: [...accBrokenRef.current],+ missingChunks,+ totalChunks: sortedChunks.length,+ totalDurationMs+ });} else {// Full path: decrypt all chunks with gap markers (completed sessions)const missingSet = new Set(missingChunks);@@ -268,7 +281,27 @@ export const useDecryptedSessionLogs = (fallbackUrlBuilder});chunkIdx += 1;- if (collectChunkResult(r, events, brokenChunks, true)) break;+ if (r.ok) {+ events.push(...r.events);+ if (events.length > PAM_PLAYBACK_MAX_TOTAL_EVENTS) {+ brokenChunks.push({+ __brokenChunk: true,+ chunkIndex: r.chunkIndex,+ reason: "limit",+ message: `Total event count exceeds playback limit of ${PAM_PLAYBACK_MAX_TOTAL_EVENTS}; remaining chunks skipped`+ });+ break;+ }+ } else {+ const marker: TBrokenChunkMarker = {+ __brokenChunk: true,+ chunkIndex: r.chunkIndex,+ reason: r.reason,+ message: r.message+ };+ events.push(marker);+ brokenChunks.push(marker);+ }}setState({diff --git a/frontend/src/pages/pam/PamSessionsByIDPage/PamSessionByIDPage.tsx b/frontend/src/pages/pam/PamSessionsByIDPage/PamSessionByIDPage.tsxindex 154df66988..51b3252c75 100644--- a/frontend/src/pages/pam/PamSessionsByIDPage/PamSessionByIDPage.tsx+++ b/frontend/src/pages/pam/PamSessionsByIDPage/PamSessionByIDPage.tsx@@ -61,10 +61,9 @@ const Page = () => {const bundleQuery = useGetPamSessionPlaybackBundle(sessionId, !!session);const sessionComplete = bundleQuery.data?.sessionComplete ?? false;- const isActive =- (session?.status === PamSessionStatus.Active ||- session?.status === PamSessionStatus.Starting) &&- !sessionComplete;+ const activeOrStarting =+ session?.status === PamSessionStatus.Active || session?.status === PamSessionStatus.Starting;+ const isActive = activeOrStarting && !sessionComplete;const isGatewaySession = !!session?.gatewayIdentityId || !!session?.gatewayId;return (<div className="mx-auto flex flex-col justify-between bg-bunker-800 text-white">@@ -122,7 +121,9 @@ const Page = () => {<div className="mr-4 flex h-fit w-96 shrink-0"><PamSessionDetailsSectionsession={session}- statusOverride={sessionComplete ? PamSessionStatus.Ended : undefined}+ statusOverride={+ activeOrStarting && sessionComplete ? PamSessionStatus.Ended : undefined+ }/></div><div className="flex min-w-0 flex-1 flex-col gap-4">diff --git a/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsx b/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsxindex 9ad67a4d86..16a3ffde3e 100644--- a/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsx+++ b/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsx@@ -108,7 +108,7 @@ export const PamSessionLogsSection = ({ session, scrollToLogIndex }: Props) => {><RdpReplayViewevents={logs as TSessionEvent[]}- isStreaming={isLoading}+ isStreaming={isLive}totalDurationMs={isLegacyOrNoChunks ? undefined : playback.totalDurationMs}/></Suspense>