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
refactor(insights): remove the exposure score
Dimitris Staratzisf65fc6dec4b1
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.mdindex cb40a7b509..84ff5a95a7 100644--- a/backend/CLAUDE.md+++ b/backend/CLAUDE.md@@ -1148,21 +1148,15 @@ owns the two read endpoints and hands `recordRead` / `recordBulkRead` through tomembership creation, role or privilege creation, edit or expiry) both predate `judgedFrom`. Which secrets achange opened up is not recorded, so any access change restarts the window, including an edit to the rules ofa custom role the reader holds. The per-secret sheet shows the plain fact- instead: a read, "No reads", or "No reads yet" with the reason. 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,- project admins left out, since a secret is not exposed to someone who can read everything by design),- `unreadCount` (those among them with no read in the window) and- `ghostReaderCount` (readers in the window who can no longer read it, so they still know the value).-- **Exposure score.** `calculateExposureScore` (`secret-read-activity-fns.ts`) turns those three counts into a 0- to 100 score with Low, Elevated, High and Critical bands and whole-point drivers that add up to it (readers up- to 45 on a log scale saturating at 40, ghost readers up to 30 saturating at 4, unused access up to 25 by- share). It is the blast radius prototype's three read-activity terms rescaled; the terms that would need new- queries (syncs, rotation age, cross-project destinations) are deliberately left out. The score, the graph and the ghost readers live only in the secret's access sheet- (`GET /secrets/:name/read-activity`), which also returns, for every reader who can read the value, whether they- count as unused access and why not (`isAdmin`, `accessChangedAt` after `judgedFrom`, or a secret newer than it),- and names each ghost reader from the project's members, else from the user or identity row, else null.+ instead: a read, "No reads", or "No reads yet" with the reason.+- **The access sheet.** The graph lives only in the secret's access sheet (`GET /secrets/:name/read-activity`).+ That endpoint returns, for every reader who can read the value, whether they count as unused access and why not+ (`isAdmin`, `accessChangedAt` after `judgedFrom`, or a secret newer than it), plus three counts: `entitledCount`+ (non-admins who can read the value today), `unreadCount` (those among them counted as unused access) and+ `ghostReaderCount`. It also returns the ghost readers (readers in the window who can no longer read it, named+ from the project's members, else from the user or identity row, else null), which the UI does not show.- **The Insights card is per principal.** `$loadSecretSummarizer` is the one place a secret's readers, unread- readers, ghost readers and score are derived, used by both the per-secret endpoint and the project computation.+ readers and ghost readers are derived, used by both the per-secret endpoint and the project computation.The computation (`$computeUnusedAccess`) walks every secret once and tallies, per user, machine identity andgroup, how many secrets it can read and how many it has not read, the environments involved, its latest read,and how it has the access (roles, additional privileges, groups; custom roles by name, the one lookup beyond thediff --git a/backend/src/ee/routes/v1/secret-router.ts b/backend/src/ee/routes/v1/secret-router.tsindex e68b3c3f45..9d03955310 100644--- a/backend/src/ee/routes/v1/secret-router.ts+++ b/backend/src/ee/routes/v1/secret-router.ts@@ -1,10 +1,6 @@import z from "zod";import { ProjectPermissionSecretActions } from "@app/ee/services/permission/project-permission";-import {- SecretExposureCountsSchema,- SecretExposureSchema-} from "@app/ee/services/secret-read-activity/secret-read-activity-schemas";import { RAW_SECRETS } from "@app/lib/api-docs";import { prefixWithSlash, removeTrailingSlash } from "@app/lib/fn";import { readLimit } from "@app/server/config/rateLimiter";@@ -112,47 +108,47 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {}),response: {200: z.object({- readActivity: z- .object({- trackedSince: z.date().describe(RAW_SECRETS.GET_READ_ACTIVITY.trackedSince),- judgedFrom: z.date().describe(RAW_SECRETS.GET_READ_ACTIVITY.judgedFrom),- reads: z- .object({- actorType: z- .enum([ActorType.USER, ActorType.IDENTITY])- .describe(RAW_SECRETS.GET_READ_ACTIVITY.actorType),- actorId: z.string().describe(RAW_SECRETS.GET_READ_ACTIVITY.actorId),- lastReadAt: z.date().describe(RAW_SECRETS.GET_READ_ACTIVITY.lastReadAt)- })- .array()- .describe(RAW_SECRETS.GET_READ_ACTIVITY.reads),- entitled: z- .object({- actorType: z- .enum([ActorType.USER, ActorType.IDENTITY])- .describe(RAW_SECRETS.GET_READ_ACTIVITY.actorType),- actorId: z.string().describe(RAW_SECRETS.GET_READ_ACTIVITY.actorId),- actorName: z.string().nullable().describe(RAW_SECRETS.GET_READ_ACTIVITY.readerName),- unread: z.boolean().describe(RAW_SECRETS.GET_READ_ACTIVITY.unread),- isAdmin: z.boolean().describe(RAW_SECRETS.GET_READ_ACTIVITY.isAdmin),- accessChangedAt: z.date().nullable().describe(RAW_SECRETS.GET_READ_ACTIVITY.accessChangedAt)- })- .array()- .describe(RAW_SECRETS.GET_READ_ACTIVITY.entitled),- exposure: SecretExposureSchema.describe(RAW_SECRETS.GET_READ_ACTIVITY.exposure),- ghostReaders: z- .object({- actorType: z- .enum([ActorType.USER, ActorType.IDENTITY])- .describe(RAW_SECRETS.GET_READ_ACTIVITY.actorType),- actorId: z.string().describe(RAW_SECRETS.GET_READ_ACTIVITY.actorId),- actorName: z.string().nullable().describe(RAW_SECRETS.GET_READ_ACTIVITY.ghostReaderName),- lastReadAt: z.date().describe(RAW_SECRETS.GET_READ_ACTIVITY.lastReadAt)- })- .array()- .describe(RAW_SECRETS.GET_READ_ACTIVITY.ghostReaders)- })- .merge(SecretExposureCountsSchema)+ readActivity: z.object({+ trackedSince: z.date().describe(RAW_SECRETS.GET_READ_ACTIVITY.trackedSince),+ judgedFrom: z.date().describe(RAW_SECRETS.GET_READ_ACTIVITY.judgedFrom),+ reads: z+ .object({+ actorType: z+ .enum([ActorType.USER, ActorType.IDENTITY])+ .describe(RAW_SECRETS.GET_READ_ACTIVITY.actorType),+ actorId: z.string().describe(RAW_SECRETS.GET_READ_ACTIVITY.actorId),+ lastReadAt: z.date().describe(RAW_SECRETS.GET_READ_ACTIVITY.lastReadAt)+ })+ .array()+ .describe(RAW_SECRETS.GET_READ_ACTIVITY.reads),+ entitled: z+ .object({+ actorType: z+ .enum([ActorType.USER, ActorType.IDENTITY])+ .describe(RAW_SECRETS.GET_READ_ACTIVITY.actorType),+ actorId: z.string().describe(RAW_SECRETS.GET_READ_ACTIVITY.actorId),+ actorName: z.string().nullable().describe(RAW_SECRETS.GET_READ_ACTIVITY.readerName),+ unread: z.boolean().describe(RAW_SECRETS.GET_READ_ACTIVITY.unread),+ isAdmin: z.boolean().describe(RAW_SECRETS.GET_READ_ACTIVITY.isAdmin),+ accessChangedAt: z.date().nullable().describe(RAW_SECRETS.GET_READ_ACTIVITY.accessChangedAt)+ })+ .array()+ .describe(RAW_SECRETS.GET_READ_ACTIVITY.entitled),+ entitledCount: z.number().int().describe(RAW_SECRETS.GET_READ_ACTIVITY.entitledCount),+ unreadCount: z.number().int().describe(RAW_SECRETS.GET_READ_ACTIVITY.unreadCount),+ ghostReaderCount: z.number().int().describe(RAW_SECRETS.GET_READ_ACTIVITY.ghostReaderCount),+ ghostReaders: z+ .object({+ actorType: z+ .enum([ActorType.USER, ActorType.IDENTITY])+ .describe(RAW_SECRETS.GET_READ_ACTIVITY.actorType),+ actorId: z.string().describe(RAW_SECRETS.GET_READ_ACTIVITY.actorId),+ actorName: z.string().nullable().describe(RAW_SECRETS.GET_READ_ACTIVITY.ghostReaderName),+ lastReadAt: z.date().describe(RAW_SECRETS.GET_READ_ACTIVITY.lastReadAt)+ })+ .array()+ .describe(RAW_SECRETS.GET_READ_ACTIVITY.ghostReaders)+ })})}},diff --git a/backend/src/ee/services/secret-read-activity/secret-read-activity-fns.test.ts b/backend/src/ee/services/secret-read-activity/secret-read-activity-fns.test.tsindex bdf60aaa96..dff9a6ad02 100644--- a/backend/src/ee/services/secret-read-activity/secret-read-activity-fns.test.ts+++ b/backend/src/ee/services/secret-read-activity/secret-read-activity-fns.test.ts@@ -3,21 +3,13 @@ import { describe, expect, test } from "vitest";import { ActorType } from "@app/services/auth/auth-type";import {- calculateExposureScore,classifySecretReads,computeSecretReach,coversWholeWindow,getUtcMonthStart,indexSecretReads} from "./secret-read-activity-fns";-import {- SecretExposureBand,- SecretExposureDriver,- SecretReadObjectType,- TReachSecret,- TSecretLastRead,- TSecretReachGraph-} from "./secret-read-activity-types";+import { SecretReadObjectType, TReachSecret, TSecretLastRead, TSecretReachGraph } from "./secret-read-activity-types";const dbPass: TReachSecret = { id: "db-pass", folderId: "shared", key: "DB_PASS" };const dbUrl: TReachSecret = { id: "db-url", folderId: "shared", key: "DB_URL" };@@ -127,66 +119,3 @@ describe("coversWholeWindow", () => {expect(coversWholeWindow(windowStart, new Date("2026-10-10T00:00:00.000Z"), windowStart)).toBe(false);});});--describe("calculateExposureScore", () => {- const pointsOf = (score: ReturnType<typeof calculateExposureScore>) =>- score.drivers.reduce((total, driver) => total + driver.points, 0);-- test("is zero with nothing to drive it", () => {- const exposure = calculateExposureScore({ entitledCount: 0, unreadCount: 0, ghostReaderCount: 0 });- expect(exposure).toEqual({ score: 0, band: SecretExposureBand.Low, drivers: [] });- });-- test("saturates each term at its weight", () => {- const exposure = calculateExposureScore({ entitledCount: 40, unreadCount: 40, ghostReaderCount: 4 });- expect(exposure.score).toBe(100);- expect(exposure.band).toBe(SecretExposureBand.Critical);- expect(exposure.drivers.map(({ kind, points }) => [kind, points])).toEqual([- [SecretExposureDriver.Readers, 45],- [SecretExposureDriver.GhostReaders, 30],- [SecretExposureDriver.UnusedAccess, 25]- ]);- });-- test("weighs a few readers far more than a few more", () => {- const two = calculateExposureScore({ entitledCount: 2, unreadCount: 0, ghostReaderCount: 0 }).score;- const twelve = calculateExposureScore({ entitledCount: 12, unreadCount: 0, ghostReaderCount: 0 }).score;- const fortyTwo = calculateExposureScore({ entitledCount: 42, unreadCount: 0, ghostReaderCount: 0 }).score;- expect(twelve - two).toBeGreaterThan(fortyTwo - twelve);- expect(fortyTwo).toBe(45);- });-- test("lists the drivers largest first, with whole points adding up to the score", () => {- const exposure = calculateExposureScore({ entitledCount: 3, unreadCount: 1, ghostReaderCount: 1 });- expect(exposure.score).toBe(Math.round(45 * (Math.log2(4) / Math.log2(41)) + 30 * 0.25 + 25 * (1 / 3)));- expect(exposure.band).toBe(SecretExposureBand.Elevated);- expect(pointsOf(exposure)).toBe(exposure.score);- expect(exposure.drivers.map((driver) => driver.points)).toEqual(- [...exposure.drivers.map((driver) => driver.points)].sort((a, b) => b - a)- );- expect(exposure.drivers.every((driver) => Number.isInteger(driver.points) && driver.points > 0)).toBe(true);- });-- test("leaves out a term worth nothing", () => {- const exposure = calculateExposureScore({ entitledCount: 5, unreadCount: 0, ghostReaderCount: 0 });- expect(exposure.drivers.map((driver) => driver.kind)).toEqual([SecretExposureDriver.Readers]);- expect(pointsOf(exposure)).toBe(exposure.score);- });-- test("puts the score in its band", () => {- const bandOf = (counts: Parameters<typeof calculateExposureScore>[0]) => calculateExposureScore(counts).band;- expect(bandOf({ entitledCount: 1, unreadCount: 0, ghostReaderCount: 0 })).toBe(SecretExposureBand.Low);- expect(bandOf({ entitledCount: 1, unreadCount: 1, ghostReaderCount: 0 })).toBe(SecretExposureBand.Elevated);- expect(bandOf({ entitledCount: 10, unreadCount: 8, ghostReaderCount: 2 })).toBe(SecretExposureBand.High);- expect(bandOf({ entitledCount: 30, unreadCount: 30, ghostReaderCount: 3 })).toBe(SecretExposureBand.Critical);- });-- test("words each driver with its counts", () => {- const { drivers } = calculateExposureScore({ entitledCount: 1, unreadCount: 1, ghostReaderCount: 1 });- expect(drivers.map((driver) => driver.label)).toEqual([- "1 of 1 has not read it in 30 days",- "1 user or machine identity can read the value",- "1 ghost reader can no longer read it but still knows the value"- ]);- });-});diff --git a/backend/src/ee/services/secret-read-activity/secret-read-activity-fns.ts b/backend/src/ee/services/secret-read-activity/secret-read-activity-fns.tsindex cb0d3f1fd5..30ff99afe1 100644--- a/backend/src/ee/services/secret-read-activity/secret-read-activity-fns.ts+++ b/backend/src/ee/services/secret-read-activity/secret-read-activity-fns.ts@@ -5,12 +5,8 @@ import { TSecretFolderDALFactory } from "@app/services/secret-folder/secret-foldimport { buildFolderIdMap, buildFolderPath } from "@app/services/secret-folder/secret-folder-fns";import {- SecretExposureBand,- SecretExposureDriver,SecretReadObjectType,TReachSecret,- TSecretExposure,- TSecretExposureCounts,TSecretLastRead,TSecretLocation,TSecretReach,@@ -131,64 +127,3 @@ export const classifySecretReads = (reach.folderIds.forEach((folderId) => record(SecretReadObjectType.Folder, folderId));return activity;};--const clamp01 = (value: number) => Math.max(0, Math.min(1, value));--// Counts grow long-tailed: going from 2 to 12 readers matters far more than going from 40 to 50.-const logScale = (value: number, saturateAt: number) => clamp01(Math.log2(value + 1) / Math.log2(saturateAt + 1));--const pluralize = (count: number, singular: string, plural: string) => `${count} ${count === 1 ? singular : plural}`;--// A score from 0 to 100 built from the three facts read activity gives: how many can read the value, how many-// who no longer can still know it, and how many of those who can never do. The weights follow the blast radius-// prototype's proportions for the same three terms, rescaled to add up to 100.-export const calculateExposureScore = ({- entitledCount,- unreadCount,- ghostReaderCount-}: TSecretExposureCounts): TSecretExposure => {- const terms = [- {- kind: SecretExposureDriver.Readers,- points: 45 * logScale(entitledCount, 40),- label: `${pluralize(entitledCount, "user or machine identity", "users and machine identities")} can read the value`- },- {- kind: SecretExposureDriver.GhostReaders,- points: 30 * clamp01(ghostReaderCount / 4),- label: `${pluralize(ghostReaderCount, "ghost reader", "ghost readers")} can no longer read it but still ${- ghostReaderCount === 1 ? "knows" : "know"- } the value`- },- {- kind: SecretExposureDriver.UnusedAccess,- points: 25 * (entitledCount ? unreadCount / entitledCount : 0),- label: `${unreadCount} of ${entitledCount} ${unreadCount === 1 ? "has" : "have"} not read it in ${SECRET_READ_ACTIVITY_WINDOW_DAYS} days`- }- ];- const score = Math.round(terms.reduce((total, term) => total + term.points, 0));-- // Whole numbers that add up to exactly the score, by largest remainder: rounding each term on its own comes- // out a point off the total often enough to look like a bug.- const contributing = terms.filter((term) => term.points > 0).sort((a, b) => b.points - a.points);- const points = contributing.map((term) => Math.floor(term.points));- let remainder = score - points.reduce((total, value) => total + value, 0);- contributing- .map((term, index) => ({ index, fraction: term.points - points[index] }))- .sort((a, b) => b.fraction - a.fraction)- .forEach(({ index }) => {- if (remainder <= 0) return;- points[index] += 1;- remainder -= 1;- });- const drivers = contributing- .map((term, index) => ({ kind: term.kind, points: points[index], label: term.label }))- .filter((driver) => driver.points > 0);-- let band = SecretExposureBand.Low;- if (score >= 85) band = SecretExposureBand.Critical;- else if (score >= 60) band = SecretExposureBand.High;- else if (score >= 30) band = SecretExposureBand.Elevated;-- return { score, band, drivers };-};diff --git a/backend/src/ee/services/secret-read-activity/secret-read-activity-schemas.ts b/backend/src/ee/services/secret-read-activity/secret-read-activity-schemas.tsdeleted file mode 100644index 91a92406bd..0000000000--- a/backend/src/ee/services/secret-read-activity/secret-read-activity-schemas.ts+++ /dev/null@@ -1,24 +0,0 @@-import { z } from "zod";--import { SECRET_EXPOSURE } from "@app/lib/api-docs";--import { SecretExposureBand, SecretExposureDriver } from "./secret-read-activity-types";--export const SecretExposureSchema = z.object({- score: z.number().int().min(0).max(100).describe(SECRET_EXPOSURE.score),- band: z.nativeEnum(SecretExposureBand).describe(SECRET_EXPOSURE.band),- drivers: z- .object({- kind: z.nativeEnum(SecretExposureDriver).describe(SECRET_EXPOSURE.driverKind),- points: z.number().int().describe(SECRET_EXPOSURE.driverPoints),- label: z.string().describe(SECRET_EXPOSURE.driverLabel)- })- .array()- .describe(SECRET_EXPOSURE.drivers)-});--export const SecretExposureCountsSchema = z.object({- entitledCount: z.number().int().describe(SECRET_EXPOSURE.entitledCount),- unreadCount: z.number().int().describe(SECRET_EXPOSURE.unreadCount),- ghostReaderCount: z.number().int().describe(SECRET_EXPOSURE.ghostReaderCount)-});diff --git a/backend/src/ee/services/secret-read-activity/secret-read-activity-service.ts b/backend/src/ee/services/secret-read-activity/secret-read-activity-service.tsindex e2f1c08534..ad8204c1fc 100644--- a/backend/src/ee/services/secret-read-activity/secret-read-activity-service.ts+++ b/backend/src/ee/services/secret-read-activity/secret-read-activity-service.ts@@ -30,7 +30,6 @@ import { TUserDALFactory } from "@app/services/user/user-dal";import { TSecretReadActivityDALFactory } from "./secret-read-activity-dal";import {- calculateExposureScore,classifySecretReads,computeSecretReach,coversWholeWindow,@@ -285,8 +284,7 @@ export const secretReadActivityServiceFactory = ({// How each secret stands, from everyone who can read its value today: unused access is judged on the// non-admins among them, since admins can read everything by design; ghost readers are readers in the window- // who are not among them at all, so their access was since removed; and the exposure score is computed from- // those counts. Groups are judged on their own too: a group's access to a secret is unused when none of its+ // who are not among them at all, so their access was since removed. Groups are judged on their own too: a group's access to a secret is unused when none of its// members read it. Until a project has a full window of reads, it is judged on the reads since tracking began.const $loadSecretSummarizer = async (projectId: string, orgId: string, windowStart: Date) => {const [@@ -370,10 +368,10 @@ export const secretReadActivityServiceFactory = ({).values()];const entitledKeys = new Set(entitled.map((actor) => `${actor.actorType}:${actor.id}`));- // Admins can read everything by design, so a secret is not exposed to them: they are left out of the counts and- // the score, though their reads still show, and a read of theirs is never a ghost's.- const exposedTo = entitled.filter((actor) => !adminActorIds.has(actor.id));- const unread = exposedTo.filter(+ // Admins can read everything by design, so they are left out of the counts, though their reads still show,+ // and a read of theirs is never a ghost's.+ const nonAdmins = entitled.filter((actor) => !adminActorIds.has(actor.id));+ const unread = nonAdmins.filter((actor) =>!reads.has(`${actor.actorType}:${actor.id}`) &&coversWholeWindow(trackedSince, accessChangedAtByActorId.get(actor.id), judgedFrom)@@ -389,16 +387,11 @@ export const secretReadActivityServiceFactory = ({);return {entitled,- exposedTo,+ nonAdmins,unread,ghostReaders,entitledGroups,- unreadGroups,- exposure: calculateExposureScore({- entitledCount: exposedTo.length,- unreadCount: unread.length,- ghostReaderCount: ghostReaders.length- })+ unreadGroups};};return {@@ -454,7 +447,7 @@ export const secretReadActivityServiceFactory = ({message: `Secret with name '${secretName}' not found at path '${secretPath}' in environment '${environment}'`});}- const { entitled, exposedTo, unread, ghostReaders, exposure } = summarize(activity);+ const { entitled, nonAdmins, unread, ghostReaders } = summarize(activity);const unreadKeys = new Set(unread.map((reader) => `${reader.actorType}:${reader.id}`));// A ghost reader may have left the project or been deleted since, and a reader who has the value through a@@ -489,10 +482,9 @@ export const secretReadActivityServiceFactory = ({accessChangedAt: accessChangedAtByActorId.get(reader.id) ?? null})),- entitledCount: exposedTo.length,+ entitledCount: nonAdmins.length,unreadCount: unread.length,ghostReaderCount: ghostReaders.length,- exposure,ghostReaders: ghostReaders.map((read) => ({...read,actorName: actorNames.get(`${read.actorType}:${read.actorId}`) ?? null@@ -569,7 +561,7 @@ export const secretReadActivityServiceFactory = ({projectId,orgId,(activity, summary) => {- summary.exposedTo.forEach((actor) => {+ summary.nonAdmins.forEach((actor) => {statOf(toPrincipalType(actor.actorType), actor.id).entitledCount += 1;});summary.unread.forEach((actor) => markUnread(toPrincipalType(actor.actorType), actor.id, activity));diff --git a/backend/src/ee/services/secret-read-activity/secret-read-activity-types.ts b/backend/src/ee/services/secret-read-activity/secret-read-activity-types.tsindex aa30f7db48..676e7e31dd 100644--- a/backend/src/ee/services/secret-read-activity/secret-read-activity-types.ts+++ b/backend/src/ee/services/secret-read-activity/secret-read-activity-types.ts@@ -92,40 +92,6 @@ export type TReadActivityScope = {secret?: Omit<TGetSecretReadActivityDTO, "projectId">;};-// How a secret stands: everyone who can read its value today, admins included; the non-admins among them with-// no read in the window; and the readers in the window who can no longer read it, so they still know the value.-export type TSecretExposureCounts = {- entitledCount: number;- unreadCount: number;- ghostReaderCount: number;-};--export enum SecretExposureBand {- Low = "low",- Elevated = "elevated",- High = "high",- Critical = "critical"-}--export enum SecretExposureDriver {- Readers = "readers",- GhostReaders = "ghost-readers",- UnusedAccess = "unused-access"-}--export type TSecretExposureDriver = {- kind: SecretExposureDriver;- // Whole points, adding up to the score, so the arithmetic shown beside the number is exact.- points: number;- label: string;-};--export type TSecretExposure = {- score: number;- band: SecretExposureBand;- drivers: TSecretExposureDriver[];-};-// A reader who can read the value today, and whether they count as unused access: no read, with the secret and// their access both older than the judged period. When they do not, the other fields say why.export type TEntitledReader = {diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex f5debe48ef..624da5cc1f 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -1408,22 +1408,6 @@ export const SECRETS = {}} as const;-export const SECRET_EXPOSURE = {- score:- "The exposure score, from 0 to 100, built from how many can read the value, how many who can no longer read it still know it, and how many who can read it never do.",- band: "The band the score falls in: low (0 to 29), elevated (30 to 59), high (60 to 84) or critical (85 to 100).",- drivers: "What makes up the score, largest first. The points add up to the score.",- driverKind:- "Which term the driver is: readers (up to 45 points), ghost-readers (up to 30 points) or unused-access (up to 25 points).",- driverPoints: "The whole points this term contributed to the score.",- driverLabel: "The term in words, with its counts.",- entitledCount:- "How many users and machine identities can read this secret's value today. Project admins are left out: they can read everything by design, so the secret is not exposed to them.",- unreadCount: "How many of those have not read it in the last 30 days.",- ghostReaderCount:- "How many users and machine identities read this secret in the last 30 days but can no longer read it today, for example after leaving the project. They still know the value."-};-export const RAW_SECRETS = {LIST: {expand: "Whether or not to expand secret references.",@@ -1531,7 +1515,10 @@ export const RAW_SECRETS = {actorType: "Whether the reader is a user or a machine identity.",actorId: "The ID of the user or machine identity.",lastReadAt: "When the reader last read the secret, as the first read of that day.",- exposure: "The secret's exposure score, computed from the counts in this response.",+ entitledCount:+ "How many users and machine identities can read the secret's value today, project admins left out since they can read everything by design.",+ unreadCount: "How many of those count as unused access.",+ ghostReaderCount: "How many ghost readers the secret has.",ghostReaders:"The users and machine identities that read the secret since trackedSince but can no longer read it today, for example after leaving the project. They still know the value.",ghostReaderName:diff --git a/frontend/src/components/secrets/SecretAccessGraph/buildAccessGraph.ts b/frontend/src/components/secrets/SecretAccessGraph/buildAccessGraph.tsindex c32259004a..0722cb844a 100644--- a/frontend/src/components/secrets/SecretAccessGraph/buildAccessGraph.ts+++ b/frontend/src/components/secrets/SecretAccessGraph/buildAccessGraph.ts@@ -1,7 +1,5 @@import { Edge, Node } from "@xyflow/react";-import { TSecretExposure } from "@app/hooks/api/secretInsights/types";-export type TAccessGraphActorType = "user" | "identity";export type TAccessGraphReader = {@@ -29,7 +27,6 @@ export type TAccessGraphSecret = {key: string;environment: string;secretPath: string;- exposure?: TSecretExposure;};export type TAccessGraphInput = {@@ -53,7 +50,7 @@ export type TLaneEdgeData = { centerX: number };export const NODE_WIDTH = 240;const READER_NODE_HEIGHT = 74;-const SECRET_NODE_HEIGHT = 104;+const SECRET_NODE_HEIGHT = 64;const BAND_LABEL_HEIGHT = 36;const HEADER_GAP = 8;const COLUMN_GAP = 160;diff --git a/frontend/src/components/secrets/SecretAccessGraph/nodes.tsx b/frontend/src/components/secrets/SecretAccessGraph/nodes.tsxindex cc0a155fa4..c4ec1e6ed3 100644--- a/frontend/src/components/secrets/SecretAccessGraph/nodes.tsx+++ b/frontend/src/components/secrets/SecretAccessGraph/nodes.tsx@@ -10,7 +10,6 @@ import {import { format } from "date-fns";import { HardDriveIcon, KeyIcon, UserIcon, UsersIcon } from "lucide-react";-import { SecretExposureBadge } from "@app/components/secrets/SecretExposureScore";import { formatReadDay } from "@app/components/secrets/SecretReadStatusBadge";import { Badge, Tooltip, TooltipContent, TooltipTrigger } from "@app/components/v3";import { cn } from "@app/components/v3/utils";@@ -119,11 +118,6 @@ export const SecretNode = ({ data }: NodeProps & { data: TSecretNodeData }) => {<p className="truncate text-xs text-muted">{secret.environment} · {secret.secretPath}</p>- {secret.exposure && (- <div className="mt-1 flex items-center gap-1.5 border-t border-secret/25 pt-1.5 text-xs text-muted">- Exposure <SecretExposureBadge exposure={secret.exposure} />- </div>- )}<Handle type="target" position={Position.Left} className={hiddenHandle} /></div>);diff --git a/frontend/src/components/secrets/SecretExposureScore.tsx b/frontend/src/components/secrets/SecretExposureScore.tsxdeleted file mode 100644index 698cca3272..0000000000--- a/frontend/src/components/secrets/SecretExposureScore.tsx+++ /dev/null@@ -1,147 +0,0 @@-import { Badge, Skeleton } from "@app/components/v3";-import { cn } from "@app/components/v3/utils";-import {- SecretExposureBand,- SecretExposureDriver,- TSecretExposure-} from "@app/hooks/api/secretInsights/types";--export const EXPOSURE_BAND_LABEL: Record<SecretExposureBand, string> = {- [SecretExposureBand.Low]: "Low",- [SecretExposureBand.Elevated]: "Elevated",- [SecretExposureBand.High]: "High",- [SecretExposureBand.Critical]: "Critical"-};--export const EXPOSURE_BAND_VARIANT: Record<- SecretExposureBand,- "success" | "info" | "warning" | "danger"-> = {- [SecretExposureBand.Low]: "success",- [SecretExposureBand.Elevated]: "info",- [SecretExposureBand.High]: "warning",- [SecretExposureBand.Critical]: "danger"-};--export const EXPOSURE_BAND_TEXT: Record<SecretExposureBand, string> = {- [SecretExposureBand.Low]: "text-success",- [SecretExposureBand.Elevated]: "text-info",- [SecretExposureBand.High]: "text-warning",- [SecretExposureBand.Critical]: "text-danger"-};--const EXPOSURE_BAND_FILL: Record<SecretExposureBand, string> = {- [SecretExposureBand.Low]: "bg-success",- [SecretExposureBand.Elevated]: "bg-info",- [SecretExposureBand.High]: "bg-warning",- [SecretExposureBand.Critical]: "bg-danger"-};--const DRIVER_TONE: Record<SecretExposureDriver, string> = {- [SecretExposureDriver.Readers]: "text-accent",- [SecretExposureDriver.GhostReaders]: "text-warning",- [SecretExposureDriver.UnusedAccess]: "text-warning"-};--// Ascending, so the meter, the caption and the card's summary come from one list.-export const EXPOSURE_BANDS = [- { band: SecretExposureBand.Low, range: "0-29" },- { band: SecretExposureBand.Elevated, range: "30-59" },- { band: SecretExposureBand.High, range: "60-84" },- { band: SecretExposureBand.Critical, range: "85-100" }-];--export const SecretExposureBadge = ({ exposure }: { exposure: TSecretExposure }) => (- <Badge variant={EXPOSURE_BAND_VARIANT[exposure.band]} className="gap-1.5">- <span className="font-mono">{exposure.score}</span>- <span>{EXPOSURE_BAND_LABEL[exposure.band]}</span>- </Badge>-);--type PanelProps = {- exposure?: TSecretExposure;- className?: string;-};--// The score with its arithmetic beside it: each driver carries the whole points it contributed, and they-// add up to the number shown.-export const SecretExposurePanel = ({ exposure, className }: PanelProps) => {- if (!exposure) {- return (- <div className={cn("flex gap-6 rounded-md border border-border bg-container p-4", className)}>- <Skeleton className="h-20 w-44" />- <Skeleton className="h-20 flex-1" />- </div>- );- }-- return (- <div- className={cn(- "flex flex-wrap gap-x-6 gap-y-3 rounded-md border border-border bg-container p-4",- className- )}- >- <div className="flex w-44 shrink-0 flex-col gap-1.5">- <span className="text-xs text-muted">Exposure</span>- <div className="flex items-baseline gap-2">- <span- className={cn("text-4xl leading-none font-semibold", EXPOSURE_BAND_TEXT[exposure.band])}- >- {exposure.score}- </span>- <span className={cn("text-sm", EXPOSURE_BAND_TEXT[exposure.band])}>- {EXPOSURE_BAND_LABEL[exposure.band]}- </span>- </div>- {/* Four segments rather than a continuous bar: the band is what decides whether anyone acts. */}- <div className="flex gap-1" aria-hidden>- {EXPOSURE_BANDS.map((entry) => (- <span- key={entry.band}- className={cn(- "h-1 flex-1 rounded-full",- entry.band === exposure.band ? EXPOSURE_BAND_FILL[exposure.band] : "bg-border"- )}- />- ))}- </div>- <p className="text-xs leading-relaxed text-muted">- {EXPOSURE_BANDS.map((entry) => `${EXPOSURE_BAND_LABEL[entry.band]} ${entry.range}`).join(- " · "- )}- </p>- </div>-- <div className="flex min-w-0 flex-1 flex-col gap-2 border-border sm:border-l sm:pl-6">- {exposure.drivers.length ? (- <div className="flex flex-col gap-1.5">- {exposure.drivers.map((driver) => (- <div key={driver.kind} className="flex gap-2.5">- <span- className={cn(- "w-7 shrink-0 font-mono text-xs leading-relaxed",- DRIVER_TONE[driver.kind]- )}- >- +{driver.points}- </span>- <p className="text-xs leading-relaxed text-foreground">{driver.label}</p>- </div>- ))}- </div>- ) : (- <p className="text-xs text-accent">- Only project admins can read this secret's value, so nothing drives the score.- </p>- )}- <p className="text-xs text-muted">- Up to 45 points for how many can read the value (project admins aside), 30 for ghost- readers who still know it, and 25 for the share who have not read it in the last 30 days.- That last part only counts once the project has 30 days of reads; before then it is too- early to judge.- </p>- </div>- </div>- );-};diff --git a/frontend/src/hooks/api/secretInsights/index.ts b/frontend/src/hooks/api/secretInsights/index.tsindex 055c0b837d..2b3e92f12f 100644--- a/frontend/src/hooks/api/secretInsights/index.ts+++ b/frontend/src/hooks/api/secretInsights/index.ts@@ -54,10 +54,8 @@ export type {TSearchSecretsByValueResponse,TSecretAccessVolumeActor,TSecretAccessVolumeDay,- TSecretExposure,- TSecretExposureCounts,TSecretValueMatch,TUnusedAccessPrincipal,TUnusedSecret} from "./types";-export { SecretExposureBand, SecretExposureDriver, UnusedAccessPrincipalType } from "./types";+export { UnusedAccessPrincipalType } from "./types";diff --git a/frontend/src/hooks/api/secretInsights/types.ts b/frontend/src/hooks/api/secretInsights/types.tsindex b1e4d7d688..db3e293a59 100644--- a/frontend/src/hooks/api/secretInsights/types.ts+++ b/frontend/src/hooks/api/secretInsights/types.ts@@ -51,34 +51,6 @@ export type TGetSecretAccessVolumeDTO = {projectId: string;};-// How a secret stands: everyone who can read its value today, admins included; the non-admins among them with-// no read in the last 30 days; and the readers who can no longer read it, so they still know the value.-export type TSecretExposureCounts = {- entitledCount: number;- unreadCount: number;- ghostReaderCount: number;-};--export enum SecretExposureBand {- Low = "low",- Elevated = "elevated",- High = "high",- Critical = "critical"-}--export enum SecretExposureDriver {- Readers = "readers",- GhostReaders = "ghost-readers",- UnusedAccess = "unused-access"-}--export type TSecretExposure = {- score: number;- band: SecretExposureBand;- // Whole points that add up to the score, largest first.- drivers: { kind: SecretExposureDriver; points: number; label: string }[];-};-export enum UnusedAccessPrincipalType {User = "user",Identity = "identity",diff --git a/frontend/src/hooks/api/secrets/types.ts b/frontend/src/hooks/api/secrets/types.tsindex 64b386e40a..af34db7f28 100644--- a/frontend/src/hooks/api/secrets/types.ts+++ b/frontend/src/hooks/api/secrets/types.ts@@ -2,7 +2,6 @@ import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionCoimport { Reminder } from "@app/hooks/api/reminders/types";import { PendingAction } from "../secretFolders/types";-import { TSecretExposure, TSecretExposureCounts } from "../secretInsights/types";import type { WsTag } from "../tags/types";export enum SecretType {@@ -163,7 +162,7 @@ export type TGetSecretAccessListDTO = {export type TGetSecretReadActivityDTO = Omit<TGetSecretAccessListDTO, "includeAllEntities">;-export type TSecretReadActivity = TSecretExposureCounts & {+export type TSecretReadActivity = {trackedSince: string;// The start of the period unused access is judged on; a reader counts only once the secret and their// access both predate it.@@ -181,7 +180,10 @@ export type TSecretReadActivity = TSecretExposureCounts & {isAdmin: boolean;accessChangedAt: string | null;}[];- exposure: TSecretExposure;+ // Non-admins who can read the value, how many of them count as unused access, and the ghost readers.+ entitledCount: number;+ unreadCount: number;+ ghostReaderCount: number;ghostReaders: {actorType: "user" | "identity";actorId: string;diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsxindex d1a30ed3fd..0791f2db78 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx@@ -620,7 +620,7 @@ export function SecretAccessInsights({});const readers = [...directReaders, ...groupOnlyReaders];return {- secret: { key: secretKey, environment, secretPath, exposure: readActivity?.exposure },+ secret: { key: secretKey, environment, secretPath },readers,// Every group that grants the value is drawn, including one whose members also have it directly.groups: groups.map((group) => ({