Skip to content

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

chore(pam): trim comments

bernie-g0f9f19d52c9d
diff --git a/backend/src/ee/services/pam-session-recording/pam-recording-secrets.ts b/backend/src/ee/services/pam-session-recording/pam-recording-secrets.ts
index e393193ec1..8aaaf41a00 100644
--- a/backend/src/ee/services/pam-session-recording/pam-recording-secrets.ts
+++ b/backend/src/ee/services/pam-session-recording/pam-recording-secrets.ts
@@ -73,9 +73,8 @@ export const decryptSessionKey = async ({
return decrypted.subarray(32, 32 + SESSION_KEY_LENGTH);
};
-// Every rejection keeps the same client-facing message; only the error name differs, so the
-// branch is recoverable from logs without widening what the caller learns. A malformed token and
-// a token that simply does not match point at completely different causes.
+// The message must stay identical across these: the chunk router substring-matches it to write
+// the upload-token audit event.
export const PamUploadTokenRejection = {
Missing: "PamUploadTokenMissing",
MalformedLength: "PamUploadTokenMalformedLength",
@@ -96,8 +95,7 @@ export const verifyGatewayUploadToken = (
});
}
- // Buffer.from drops invalid base64 characters rather than throwing, so a bad encoding arrives
- // here as a short decode, never as an exception.
+ // Buffer.from drops invalid base64 rather than throwing, so a bad encoding lands here short.
const presentedBuf = Buffer.from(presentedTokenBase64, "base64");
if (presentedBuf.length !== UPLOAD_TOKEN_LENGTH) {
throw new BadRequestError({
diff --git a/backend/src/ee/services/pam-session/pam-session-dal.ts b/backend/src/ee/services/pam-session/pam-session-dal.ts
index abdea44438..98583012a7 100644
--- a/backend/src/ee/services/pam-session/pam-session-dal.ts
+++ b/backend/src/ee/services/pam-session/pam-session-dal.ts
@@ -24,11 +24,8 @@ export const pamSessionDALFactory = (db: TDbClient) => {
return session;
};
- // Sets the recording secrets only if the session has none yet, and returns whichever key is
- // stored afterwards. One statement on the primary, so a caller that loses a concurrent claim
- // still gets the winner's key back; a follow-up read would go to a replica that may not have
- // caught up. COALESCE and CASE both see the pre-update value, so the winner is whoever the row
- // was null for.
+ // Returns whichever key ends up stored, so a caller that loses the claim still gets the
+ // winner's. One statement on the primary, because a follow-up read could hit a lagging replica.
const claimRecordingSecrets = async (
sessionId: string,
encryptedSessionKey: Buffer,
diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.ts
index 125532e945..b7d772244c 100644
--- a/backend/src/ee/services/pam-session/pam-session-service.ts
+++ b/backend/src/ee/services/pam-session/pam-session-service.ts
@@ -322,12 +322,8 @@ export const pamSessionServiceFactory = ({
kmsService
});
- // Claim the mint in a single statement. Concurrent credential fetches for one session are
- // routine -- a gateway fetches per connection -- and the KMS call above widens the gap
- // between check and write to tens of milliseconds. Without the guard both callers mint, the
- // later write wins, and the earlier caller is left holding a session key and upload token the
- // row no longer matches: every chunk upload 400s forever, and whatever did upload is
- // undecryptable at playback.
+ // A gateway fetches credentials per connection, so two can mint at once; without a single
+ // claim the loser keeps a key the row no longer holds and its uploads fail forever.
const claimed = await pamSessionDAL.claimRecordingSecrets(
sessionId,
secrets.encryptedSessionKey,
@@ -346,8 +342,6 @@ export const pamSessionServiceFactory = ({
sessionId
};
} else {
- // Another fetch claimed it first; adopt its key rather than our own discarded one. The
- // upload token stays empty here, same as any other re-fetch.
storedSessionKey = claimed.encryptedSessionKey;
}
}