Skip to content

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

Address Veria review

Carlos Monastyrskiaafc347c9060
diff --git a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts
index 903d7328b2..da8c2fc40d 100644
--- a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts
+++ b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts
@@ -334,18 +334,35 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic
});
let rotationAccountName: string | null = null;
+ let rotationAccountId: string | null = account.rotationAccountId ?? null;
if (account.rotationAccountId === account.id) {
+ // Self-rotation: the rotation account is this account, which the caller already reads.
rotationAccountName = account.name;
} else if (account.rotationAccountId) {
const rotator = await pamAccountDAL.findById(account.rotationAccountId);
- rotationAccountName = rotator?.name ?? null;
+ const canReadRotator =
+ !!rotator &&
+ (await checkAccount(
+ rotator.id,
+ rotator.folderId,
+ projectId,
+ ResourcePermissionPamResourceActions.ReadAccounts,
+ ctx
+ )
+ .then(() => true)
+ .catch(() => false));
+ if (rotator && canReadRotator) {
+ rotationAccountName = rotator.name;
+ } else {
+ rotationAccountId = null;
+ }
}
return {
enabled: settings?.rotation?.enabled ?? false,
intervalSeconds: settings?.rotation?.intervalSeconds ?? null,
passwordRequirements: settings?.passwordRequirements ?? null,
- rotationAccountId: account.rotationAccountId ?? null,
+ rotationAccountId,
rotationAccountName,
lastRotatedAt: account.lastRotatedAt ?? null,
isReady: readiness.ready
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.ts
index 175eb7ca80..a2fd81f58c 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -462,10 +462,29 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
const dependents = (await pamAccountDAL.find({ rotationAccountId: accountId })).filter(
(dependent) => dependent.id !== accountId
);
- const names = dependents.map((dependent) => dependent.name).join(", ");
+ const readChecks = await Promise.all(
+ dependents.map(async (dependent) => ({
+ name: dependent.name,
+ canRead: await checkAccount(
+ dependent.id,
+ dependent.folderId,
+ projectId,
+ ResourcePermissionPamResourceActions.ReadAccounts,
+ ctx
+ )
+ .then(() => true)
+ .catch(() => false)
+ }))
+ );
+ const readableNames = readChecks.filter((c) => c.canRead).map((c) => c.name);
+ const hiddenCount = readChecks.length - readableNames.length;
+ const parts = [
+ ...(readableNames.length ? [readableNames.join(", ")] : []),
+ ...(hiddenCount ? [`${hiddenCount} other account${hiddenCount > 1 ? "s" : ""}`] : [])
+ ];
throw new BadRequestError({
- message: names
- ? `This account is the rotation account for: ${names}. Reassign or clear their rotation account before deleting this one.`
+ message: parts.length
+ ? `This account is the rotation account for: ${parts.join(", and ")}. Reassign or clear their rotation account before deleting this one.`
: "This account is used as the rotation account for another account. Reassign it before deleting this one."
});
}