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
feat(insights): editing a custom role restarts its holders' unused access window
Dimitris Staratzis541b11275e5f
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.mdindex 9946065f7b..d1cb2edd48 100644--- a/backend/CLAUDE.md+++ b/backend/CLAUDE.md@@ -1146,7 +1146,7 @@ owns the two read endpoints and hands `recordRead` / `recordBulkRead` through tostart (the later of the migration that created the table and the project's creation). So in a project tracked forless than 30 days the card already lists access unread since tracking began, and the response's`preliminaryUntil` tells the UI to label it preliminary. Which secrets a change opened up is not recorded, so any- access change restarts the window, and a custom role's rules being edited is not seen at all. The per-secret sheet+ access change restarts the window, including an edit to the rules of a custom role the reader holds. The per-secret sheetshows the plain fact instead: a read, or "No reads". Each card row also carries three counts for its secret,derived from sets the computation already holds: `entitledCount` (everyone who can read the value today,admins included), `unreadCount` (the non-admins among them with no read in the window) anddiff --git a/backend/src/ee/services/secret-read-activity/secret-read-activity-dal.ts b/backend/src/ee/services/secret-read-activity/secret-read-activity-dal.tsindex 74c5806ad9..0588449a81 100644--- a/backend/src/ee/services/secret-read-activity/secret-read-activity-dal.ts+++ b/backend/src/ee/services/secret-read-activity/secret-read-activity-dal.ts@@ -136,13 +136,15 @@ export const secretReadActivityDALFactory = (db: TDbClient) => {};// The last time each user or identity joined the project or had a role, privilege or folder grant created,- // changed or expired. Which secrets a change opened up is not recorded, so any of them restarts the window; an- // expired restrictive folder grant can restore access. Membership updatedAt is left out because logins bump it.+ // changed or expired, or had the rules of a custom role they hold edited. Which secrets a change opened up is+ // not recorded, so any of them restarts the window; an expired restrictive folder grant can restore access.+ // Membership updatedAt is left out because logins bump it.const findAccessChangedAt = async (projectId: string, tx?: Knex) => {try {const [roleChanges, privilegeChanges] = await Promise.all([(tx || db.replicaNode())(TableName.Membership).join(TableName.MembershipRole, `${TableName.Membership}.id`, `${TableName.MembershipRole}.membershipId`)+ .leftJoin(TableName.Role, `${TableName.MembershipRole}.customRoleId`, `${TableName.Role}.id`).where(`${TableName.Membership}.scope`, AccessScope.Project).where(`${TableName.Membership}.scopeProjectId`, projectId).select(@@ -151,7 +153,8 @@ export const secretReadActivityDALFactory = (db: TDbClient) => {db.ref("createdAt").withSchema(TableName.Membership).as("membershipCreatedAt"),db.ref("createdAt").withSchema(TableName.MembershipRole),db.ref("updatedAt").withSchema(TableName.MembershipRole),- db.ref("temporaryAccessEndTime").withSchema(TableName.MembershipRole)+ db.ref("temporaryAccessEndTime").withSchema(TableName.MembershipRole),+ db.ref("updatedAt").withSchema(TableName.Role).as("customRoleUpdatedAt")),(tx || db.replicaNode())(TableName.AdditionalPrivilege).where({ projectId })@@ -165,6 +168,8 @@ export const secretReadActivityDALFactory = (db: TDbClient) => {if (!actorId) return;const dates = [change.createdAt, change.updatedAt];if ("membershipCreatedAt" in change) dates.push(change.membershipCreatedAt as Date);+ if ("customRoleUpdatedAt" in change && change.customRoleUpdatedAt)+ dates.push(change.customRoleUpdatedAt as Date);if (change.temporaryAccessEndTime && new Date(change.temporaryAccessEndTime) <= now) {dates.push(change.temporaryAccessEndTime);}