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): judge unused access only once a project has 30 days of tracked reads
Dimitris Staratzisf1292451c814
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.mdindex 669f39f573..d6ab72cf09 100644--- a/backend/CLAUDE.md+++ b/backend/CLAUDE.md@@ -1149,10 +1149,12 @@ owns the two read endpoints and hands `recordRead` / `recordBulkRead` through to(`KeyStoreTtls.InsightsUnusedAccessCacheInSeconds`), grouping actors by identical rules so each rule set is checked onceper secret. The per-secret endpoint checks the caller's access to the secret before building its reach, whichdecrypts every secret that could reference it.-- **The card judges a full window, or everything since tracking began.** Tracking starts at the later of the- migration that created the table and the project's creation. In a project tracked for less than 30 days, the- window starts when tracking did (`judgedFrom`). The card's responses carry it as `periodStart`, stored with the- cached computation, so the UI words the period "since <date>" while it is under 30 days old. The card leaves out project admins (users+- **Only a full window is judged.** Tracking starts at the later of the migration that created the table and the+ project's creation, and reads from before it are unknown, so nothing counts as unused access until tracking has run+ 30 days (`getUnusedAccessFrom`). `judgedFrom` is always the start of the last 30 days, and a secret's `trackedSince`+ starts no earlier than tracking did, so before then no secret covers the window; the card skips the scan and+ caches nothing, and the access sheet gives the `tracking-too-new` reason. Every response carries `unusedAccessFrom`+ so the UI can say when results start. The card leaves out project admins (usersand identities with the Admin role, directly or through a group, from `findAdminActorIds`): they can readeverything by design. Their reads are still recorded, so the access sheet's Last Read stays true for them. Apair is listed once the secret (`trackedSince`) and the actor's access to that secret both predate `judgedFrom`.diff --git a/backend/src/ee/services/insights/insights-schemas.ts b/backend/src/ee/services/insights/insights-schemas.tsindex 1d48da0460..497a69905b 100644--- a/backend/src/ee/services/insights/insights-schemas.ts+++ b/backend/src/ee/services/insights/insights-schemas.ts@@ -118,13 +118,13 @@ const UnusedAccessActorRowSchema = z.object({export const UnusedAccessSchema = z.object({totalCount: z.number().int().describe(INSIGHTS.GET_UNUSED_ACCESS.totalCount),- periodStart: z.date().describe(INSIGHTS.GET_UNUSED_ACCESS.periodStart),+ unusedAccessFrom: z.date().describe(INSIGHTS.GET_UNUSED_ACCESS.unusedAccessFrom),actors: UnusedAccessActorRowSchema.array().describe(INSIGHTS.GET_UNUSED_ACCESS.actors)});export const UnusedAccessActorSchema = z.object({actor: UnusedAccessActorRowSchema,- periodStart: z.date().describe(INSIGHTS.GET_UNUSED_ACCESS.periodStart),+ unusedAccessFrom: z.date().describe(INSIGHTS.GET_UNUSED_ACCESS.unusedAccessFrom),secrets: z.object({secretKey: z.string().describe(INSIGHTS.GET_UNUSED_ACCESS_ACTOR.secretKey),@@ -137,7 +137,7 @@ export const UnusedAccessActorSchema = z.object({export const SecretReadActivitySchema = z.object({readsTrackedSince: z.date().describe(INSIGHTS.GET_SECRET_READ_ACTIVITY.readsTrackedSince),- unusedAccessJudgedFrom: z.date().describe(INSIGHTS.GET_SECRET_READ_ACTIVITY.unusedAccessJudgedFrom),+ unusedAccessFrom: z.date().describe(INSIGHTS.GET_SECRET_READ_ACTIVITY.unusedAccessFrom),actors: z.object({actorType: z.enum([ActorType.USER, ActorType.IDENTITY]).describe(INSIGHTS.GET_SECRET_READ_ACTIVITY.actorType),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 5231d35220..38bcc66a42 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@@ -208,6 +208,7 @@ describe("getReadStatus", () => {isProjectAdmin: false,accessSince: sept,judgedFrom: day("2026-09-15"),+ trackingStartedAt: day("2026-08-01"),...overrides});const notJudged = (notJudgedReason: SecretReadNotJudgedReason) => ({@@ -215,7 +216,7 @@ describe("getReadStatus", () => {notJudgedReason});- test("is read, unused, or not judged for one of three reasons", () => {+ test("is read, unused, or not judged for one of four reasons", () => {expect(status({ lastReadAt: oct, isProjectAdmin: true })).toEqual({readStatus: SecretReadStatus.Read,notJudgedReason: null@@ -224,6 +225,9 @@ describe("getReadStatus", () => {expect(status({ isProjectAdmin: true, accessSince: oct })).toEqual(notJudged(SecretReadNotJudgedReason.ProjectAdmin));+ expect(status({ trackingStartedAt: oct, accessSince: oct })).toEqual(+ notJudged(SecretReadNotJudgedReason.TrackingTooNew)+ );expect(status({ accessSince: oct })).toEqual(notJudged(SecretReadNotJudgedReason.AccessTooNew));expect(status()).toEqual(notJudged(SecretReadNotJudgedReason.SecretTooNew));});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 07764bc1d5..ac12388ee5 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@@ -41,6 +41,10 @@ export const SECRET_READ_ACTIVITY_WINDOW_DAYS = 30;export const getReadActivityWindowStart = () => new Date(Date.now() - SECRET_READ_ACTIVITY_WINDOW_DAYS * DAY_IN_MS);+// Reads from before tracking began are unknown, so unused access is only judged once a whole window has been tracked.+export const getUnusedAccessFrom = (trackingStartedAt: Date) =>+ new Date(trackingStartedAt.getTime() + SECRET_READ_ACTIVITY_WINDOW_DAYS * DAY_IN_MS);+export const loadProjectFolderTree = async ({folderDAL,@@ -256,18 +260,21 @@ export const getReadStatus = ({isUnused,isProjectAdmin,accessSince,- judgedFrom+ judgedFrom,+ trackingStartedAt}: {lastReadAt: Date | null;isUnused: boolean;isProjectAdmin: boolean;accessSince: Date;judgedFrom: Date;+ trackingStartedAt: Date;}) => {if (lastReadAt) return { readStatus: SecretReadStatus.Read, notJudgedReason: null };if (isUnused) return { readStatus: SecretReadStatus.Unused, notJudgedReason: null };let notJudgedReason = SecretReadNotJudgedReason.SecretTooNew;if (isProjectAdmin) notJudgedReason = SecretReadNotJudgedReason.ProjectAdmin;+ else if (trackingStartedAt > judgedFrom) notJudgedReason = SecretReadNotJudgedReason.TrackingTooNew;else if (accessSince > judgedFrom) notJudgedReason = SecretReadNotJudgedReason.AccessTooNew;return { readStatus: SecretReadStatus.NotJudged, notJudgedReason };};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 1e6fdb8ef9..c2f8b9bf6a 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@@ -41,6 +41,7 @@ import {createAccessDating,getReadActivityWindowStart,getReadStatus,+ getUnusedAccessFrom,indexSecretReads,loadProjectFolderTree,summarizeSecretAccess,@@ -461,7 +462,10 @@ export const secretReadActivityServiceFactory = ({sourceDates.folderReopenedAt,accessReopenedAt),- judgedFrom: trackingStartedAt > windowStart ? trackingStartedAt : windowStart,+ // A secret's tracked period starts no earlier than tracking did, so until a whole window has been tracked no+ // secret covers it and nobody counts as unused access.+ judgedFrom: windowStart,+ trackingStartedAt,nameOf,directMembers,groupMembershipsByActorId,@@ -527,14 +531,15 @@ export const secretReadActivityServiceFactory = ({isUnused: unusedActorIds.has(reader.actorId),isProjectAdmin,accessSince,- judgedFrom: access.judgedFrom+ judgedFrom: access.judgedFrom,+ trackingStartedAt: access.trackingStartedAt})};});return {readsTrackedSince: activity.trackedSince,- unusedAccessJudgedFrom: access.judgedFrom,+ unusedAccessFrom: getUnusedAccessFrom(access.trackingStartedAt),actors: actors.sort((a, b) => a.name.localeCompare(b.name))};};@@ -620,11 +625,19 @@ export const secretReadActivityServiceFactory = ({const details = Object.fromEntries(ranked.slice(0, UNUSED_ACCESS_DETAIL_MAX_ACTORS).map((tally) => [tally.actorId, tally.unusedSecretIds]));- return { rows, details, periodStart: access.judgedFrom };+ return { rows, details };};// The whole project is computed once a day and cached, so paging through it is cheap.const $getCachedUnusedAccess = async (projectId: string, orgId: string) => {+ const unusedAccessFrom = getUnusedAccessFrom((await $getProjectTrackingStartedAt(projectId)).trackingStartedAt);+ // Before then nobody can count as unused access, so the project is not scanned, and no empty result is cached to+ // outlive the wait.+ if (unusedAccessFrom > new Date()) {+ const summary: TUnusedAccessSummary = { rows: [], details: {} };+ return { ...summary, unusedAccessFrom, remainingTTL: -1 };+ }+const cacheKey = KeyStorePrefixes.InsightsCache(projectId, "unused-access");const summary = await withCache({keyStore,@@ -662,8 +675,7 @@ export const secretReadActivityServiceFactory = ({}});const remainingTTL = await getCacheTtl(keyStore, cacheKey);- // Dates come back from the cache as strings.- return { ...summary, periodStart: new Date(summary.periodStart), remainingTTL };+ return { ...summary, unusedAccessFrom, remainingTTL };};const listUnusedAccess = async (@@ -671,11 +683,11 @@ export const secretReadActivityServiceFactory = ({actor: OrgServiceActor) => {await checkInsightsPermission(permissionService, licenseService, projectId, actor);- const { rows, periodStart, remainingTTL } = await $getCachedUnusedAccess(projectId, actor.orgId);+ const { rows, unusedAccessFrom, remainingTTL } = await $getCachedUnusedAccess(projectId, actor.orgId);const needle = search?.trim().toLowerCase();const matching = needle ? rows.filter((row) => row.name.toLowerCase().includes(needle)) : rows;return {- result: { actors: matching.slice(offset, offset + limit), totalCount: matching.length, periodStart },+ result: { actors: matching.slice(offset, offset + limit), totalCount: matching.length, unusedAccessFrom },remainingTTL};};@@ -685,7 +697,7 @@ export const secretReadActivityServiceFactory = ({actor: OrgServiceActor) => {const { permission } = await checkInsightsPermission(permissionService, licenseService, projectId, actor);- const { rows, details, periodStart, remainingTTL } = await $getCachedUnusedAccess(projectId, actor.orgId);+ const { rows, details, unusedAccessFrom, remainingTTL } = await $getCachedUnusedAccess(projectId, actor.orgId);const unusedAccessActor = rows.find((row) => row.actorType === actorType && row.actorId === actorId);if (!unusedAccessActor) {throw new NotFoundError({@@ -728,7 +740,7 @@ export const secretReadActivityServiceFactory = ({a.secretPath.localeCompare(b.secretPath) ||a.secretKey.localeCompare(b.secretKey));- return { result: { actor: unusedAccessActor, secrets, periodStart }, remainingTTL };+ return { result: { actor: unusedAccessActor, secrets, unusedAccessFrom }, remainingTTL };};return {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 d3aee19b6c..d44be21638 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@@ -166,6 +166,7 @@ export enum SecretReadStatus {export enum SecretReadNotJudgedReason {ProjectAdmin = "project-admin",+ TrackingTooNew = "tracking-too-new",AccessTooNew = "access-too-new",SecretTooNew = "secret-too-new"}@@ -221,8 +222,6 @@ export type TUnusedAccessSummary = {rows: TUnusedAccessActor[];// The unused secret ids of the top actors, by actor id.details: Record<string, string[]>;- // Unused means no read since this date: 30 days before the computation, or when tracking began if later.- periodStart: Date;};export type TUnusedSecret = TSecretLocation & { secretKey: string };diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 6b04a0215c..c53500524f 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -953,13 +953,13 @@ export const INSIGHTS = {limit: "The maximum number of actors to return per page.",search: "Only actors whose name contains this text, ignoring case.",actors:- "The users and machine identities that can read secrets they have not read in the last 30 days (since tracking began, in a project tracked for less), those with the most such secrets first. Project admins are left out: they can read everything by design.",+ "The users and machine identities that can read secrets they have not read in the last 30 days, those with the most such secrets first. Project admins are left out: they can read everything by design. Empty until unusedAccessFrom.",actorType: "Whether the actor is a user or a machine identity.",actorId: "The ID of the user or machine identity.",name: "The username of the user, or the name of the machine identity.",accessibleSecretCount: "How many secrets the actor can read the value of today.",unusedSecretCount:- "How many of those it has not read, or an import or reference of, since periodStart. A secret only counts once it and the actor's access both predate periodStart.",+ "How many of those it has not read, or an import or reference of, in the last 30 days. A secret only counts once it and the actor's access are both older than that.",environments: "The slugs of the environments holding the unread secrets.",accessPaths: "How the actor has its access to the project's secrets.",roles: "The project roles the actor holds directly, not through a group.",@@ -982,15 +982,15 @@ export const INSIGHTS = {folderSecretPath: "The path of the folder.",folderRole: "The access level granted on the folder: list, read, edit, manage or full-access.",totalCount: "The number of actors the caller can page through.",- periodStart:- "Unused means no read since this date: 30 days before the results were computed, or when reads started being tracked for the project if that is later. Results are recomputed once a day."+ unusedAccessFrom:+ "When unused access starts being judged for the project: 30 days after reads started being tracked for it. Nothing is listed before then, since reads from before tracking began are unknown. Results are recomputed once a day."},GET_UNUSED_ACCESS_ACTOR: {projectId: "The ID of the project.",actorType: "Whether the actor is a user or a machine identity.",actorId: "The ID of the user or machine identity.",secrets:- "The secrets the actor can read but has not read since periodStart, ordered by environment and path. The list can be shorter than the actor's unusedSecretCount: it holds at most 200, only those the caller can see, and none deleted since the results were computed.",+ "The secrets the actor can read but has not read in the last 30 days, ordered by environment and path. The list can be shorter than the actor's unusedSecretCount: it holds at most 200, only those the caller can see, and none deleted since the results were computed.",secretKey: "The key of the secret.",environment: "The slug of the environment the secret is in.",secretPath: "The path of the folder the secret is in."@@ -1002,8 +1002,8 @@ export const INSIGHTS = {secretPath: "The folder path where the secret is located.",readsTrackedSince:"Reads are reported from this date: the latest of 30 days ago, when reads started being tracked for the project, and when the secret and its folder were created.",- unusedAccessJudgedFrom:- "Unused access is judged from this date: the later of 30 days ago and when reads started being tracked for the project. An actor without a read only counts as unused access once the secret and their access both predate it.",+ unusedAccessFrom:+ "When unused access starts being judged for the project: 30 days after reads started being tracked for it. Before then no actor counts as unused access.",actors:"One entry for each user or machine identity that can read the secret's value today, directly or through a group, ordered by name. Project admins are included so their reads show.",actorType: "Whether the actor is a user or a machine identity.",@@ -1016,9 +1016,9 @@ export const INSIGHTS = {accessSince:"When the actor got access to this secret: the oldest of their roles, groups, privileges and folder grants that gives it on its own, from when it was last created or changed. An edit to a custom role's rules counts for every secret the role gives, since which secrets an edit opened is not recorded.",readStatus:- "read: the actor read the secret since readsTrackedSince. unused: no read, and the secret and their access both predate unusedAccessJudgedFrom, so it counts as unused access. not-judged: no read, but it does not count yet; notJudgedReason says why.",+ "read: the actor read the secret since readsTrackedSince. unused: no read, and the secret and their access are both older than 30 days, so it counts as unused access. not-judged: no read, but it does not count yet; notJudgedReason says why.",notJudgedReason:- "Why an actor without a read is not counted as unused access. project-admin: admins are never counted. access-too-new: they got access to the secret after unusedAccessJudgedFrom. secret-too-new: the secret is newer than unusedAccessJudgedFrom. Null unless readStatus is not-judged."+ "Why an actor without a read is not counted as unused access. project-admin: admins are never counted. tracking-too-new: reads have been tracked for less than 30 days, until unusedAccessFrom. access-too-new: they got access to the secret in the last 30 days. secret-too-new: the secret is newer than 30 days. Null unless readStatus is not-judged."},GET_SECRETS_ACCESS_VOLUME: {days: "One entry for each of the last seven days, oldest first. Days with no secret access are included with a total of zero.",diff --git a/frontend/src/hooks/api/secretInsights/types.ts b/frontend/src/hooks/api/secretInsights/types.tsindex a4fadc1188..d5271802cf 100644--- a/frontend/src/hooks/api/secretInsights/types.ts+++ b/frontend/src/hooks/api/secretInsights/types.ts@@ -98,8 +98,8 @@ export type TGetUnusedAccessDTO = {export type TGetUnusedAccessResponse = {actors: TUnusedAccessActor[];totalCount: number;- // Unused means no read since this date: 30 days ago, or when tracking began if later.- periodStart: string;+ // Nothing is judged before this date: 30 days after tracking began.+ unusedAccessFrom: string;remainingTtl: number;};@@ -118,7 +118,7 @@ export type TUnusedSecret = {export type TGetUnusedAccessActorResponse = {actor: TUnusedAccessActor;secrets: TUnusedSecret[];- periodStart: string;+ unusedAccessFrom: string;remainingTtl: number;};@@ -130,6 +130,7 @@ export enum SecretReadStatus {export enum SecretReadNotJudgedReason {ProjectAdmin = "project-admin",+ TrackingTooNew = "tracking-too-new",AccessTooNew = "access-too-new",SecretTooNew = "secret-too-new"}@@ -155,7 +156,7 @@ export type TSecretReadActivityActor = {export type TSecretReadActivity = {readsTrackedSince: string;- unusedAccessJudgedFrom: string;+ unusedAccessFrom: string;actors: TSecretReadActivityActor[];};diff --git a/frontend/src/pages/secret-manager/InsightsPage/components/UnusedAccessActorSheet.tsx b/frontend/src/pages/secret-manager/InsightsPage/components/UnusedAccessActorSheet.tsxindex 5ab1ffcbad..40788904c6 100644--- a/frontend/src/pages/secret-manager/InsightsPage/components/UnusedAccessActorSheet.tsx+++ b/frontend/src/pages/secret-manager/InsightsPage/components/UnusedAccessActorSheet.tsx@@ -29,7 +29,7 @@ import {useGetUnusedAccessActor} from "@app/hooks/api/secretInsights";-import { ACTOR_TYPE_CONFIG, describeReadPeriod } from "./unusedAccessHelpers";+import { ACTOR_TYPE_CONFIG } from "./unusedAccessHelpers";// Rows shown per environment before "N more" opens the rest.const PREVIEW_ROWS = 5;@@ -182,8 +182,8 @@ export const UnusedAccessActorSheet = ({ actor, onClose }: Props) => {</SheetTitle><SheetDescription>Has not read {actor.unusedSecretCount} of the {actor.accessibleSecretCount}{" "}- {actor.accessibleSecretCount === 1 ? "secret" : "secrets"} it can access{" "}- {data ? describeReadPeriod(data.periodStart) : "in the last 30 days"}.+ {actor.accessibleSecretCount === 1 ? "secret" : "secrets"} it can access in the last+ 30 days.</SheetDescription></SheetHeader>)}diff --git a/frontend/src/pages/secret-manager/InsightsPage/components/UnusedAccessCard.tsx b/frontend/src/pages/secret-manager/InsightsPage/components/UnusedAccessCard.tsxindex aac924fac7..5eaf9a412e 100644--- a/frontend/src/pages/secret-manager/InsightsPage/components/UnusedAccessCard.tsx+++ b/frontend/src/pages/secret-manager/InsightsPage/components/UnusedAccessCard.tsx@@ -1,5 +1,6 @@import { useState } from "react";import axios from "axios";+import { format } from "date-fns";import { ChevronRightIcon, InfoIcon, SearchIcon } from "lucide-react";import {@@ -39,7 +40,6 @@ import { UnusedAccessActorSheet } from "./UnusedAccessActorSheet";import {accessPathBadges,ACTOR_TYPE_CONFIG,- describeReadPeriod,formatRemainingTtl,unusedSharePercent,unusedShareTone@@ -63,7 +63,8 @@ export const UnusedAccessCard = () => {? formatRemainingTtl(data.remainingTtl): null;const environmentNames = new Map(currentProject.environments.map((env) => [env.slug, env.name]));- const readPeriod = data ? describeReadPeriod(data.periodStart) : "in the last 30 days";+ // Nothing is judged until the project has 30 days of reads.+ const isJudging = !data || new Date(data.unusedAccessFrom) <= new Date();const renderBody = () => {if (isPending) return <Skeleton className="h-[200px] w-full" />;@@ -85,15 +86,19 @@ export const UnusedAccessCard = () => {if (totalCount === 0) {// Recent access and new secrets are not judged yet, so this cannot claim everything was read.- const description = debouncedSearch- ? "No overprivileged user or machine identity matches your search."- : `No identity has left a secret it can access unread ${readPeriod}.`;+ let title = "No overprivileged access found";+ let description = "No identity has left a secret it can access unread in the last 30 days.";+ if (debouncedSearch) {+ title = "No matching identity";+ description = "No overprivileged user or machine identity matches your search.";+ } else if (!isJudging) {+ title = "Not enough read history yet";+ description = `Results will show on ${format(new Date(data.unusedAccessFrom), "PP")}, once secret reads have been tracked for 30 days.`;+ }return (<Empty className="border"><EmptyHeader>- <EmptyTitle>- {debouncedSearch ? "No matching identity" : "No overprivileged access found"}- </EmptyTitle>+ <EmptyTitle>{title}</EmptyTitle><EmptyDescription>{description}</EmptyDescription></EmptyHeader></Empty>@@ -115,7 +120,8 @@ export const UnusedAccessCard = () => {<InfoIcon className="size-3.5 text-muted" /></TooltipTrigger><TooltipContent className="max-w-64">- Of the secrets each identity can read, how many it has not read {readPeriod}.+ Of the secrets each identity can read, how many it has not read in the last 30+ days.</TooltipContent></Tooltip></span>@@ -217,8 +223,8 @@ export const UnusedAccessCard = () => {)}</CardTitle><CardDescription>- Users and machine identities with access to secrets they have not read {readPeriod}.- Select one to see those secrets.+ Users and machine identities with access to secrets they have not read in the last 30+ days. Select one to see those secrets.</CardDescription><CardAction><InputGroup className="w-64">diff --git a/frontend/src/pages/secret-manager/InsightsPage/components/unusedAccessHelpers.ts b/frontend/src/pages/secret-manager/InsightsPage/components/unusedAccessHelpers.tsindex 42391de0bd..59024da3f2 100644--- a/frontend/src/pages/secret-manager/InsightsPage/components/unusedAccessHelpers.ts+++ b/frontend/src/pages/secret-manager/InsightsPage/components/unusedAccessHelpers.ts@@ -1,4 +1,3 @@-import { format } from "date-fns";import { HardDriveIcon, UserIcon } from "lucide-react";import { TUnusedAccessPaths, UnusedAccessActorType } from "@app/hooks/api/secretInsights";@@ -36,14 +35,6 @@ export const accessPathBadges = (}))];-const WINDOW_MS = 30 * 24 * 60 * 60 * 1000;--// The period reads are judged on: the last 30 days once tracking has run that long, else since it began.-export const describeReadPeriod = (periodStart: string) =>- new Date(periodStart).getTime() > Date.now() - WINDOW_MS- ? `since ${format(new Date(periodStart), "PP")}`- : "in the last 30 days";-// The share of the secrets an actor can read that it has not read, as a whole percentage that only reads 0// or 100 when it is exactly that.export const unusedSharePercent = (unusedSecretCount: number, accessibleSecretCount: number) => {diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsxindex e2061c2bef..9c4b457dbe 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx@@ -518,7 +518,6 @@ export function SecretAccessInsights({ secretKey, environment, secretPath }: Proif (actor?.readStatus === SecretReadStatus.Unused) {return { kind: "unread", since: readActivity.readsTrackedSince };}- const judgedFrom = format(new Date(readActivity.unusedAccessJudgedFrom), "PP");if (actor?.notJudgedReason === SecretReadNotJudgedReason.ProjectAdmin) {return {kind: "pending",@@ -526,16 +525,22 @@ export function SecretAccessInsights({ secretKey, environment, secretPath }: Pro"Project admins can read everything by design, so they are not counted as unused access."};}+ if (actor?.notJudgedReason === SecretReadNotJudgedReason.TrackingTooNew) {+ return {+ kind: "pending",+ reason: `Reads have only been tracked since ${format(new Date(readActivity.readsTrackedSince), "PP")}. Unused access will show on ${format(new Date(readActivity.unusedAccessFrom), "PP")}, once reads have been tracked for 30 days.`+ };+ }if (actor?.notJudgedReason === SecretReadNotJudgedReason.AccessTooNew) {return {kind: "pending",- reason: `They got access to this secret on ${format(new Date(actor.accessSince), "PP")}, after reads started being counted on ${judgedFrom}, so they have not had the whole period to read it.`+ reason: `They got access to this secret on ${format(new Date(actor.accessSince), "PP")}, so they have not had 30 days to read it.`};}if (actor?.notJudgedReason === SecretReadNotJudgedReason.SecretTooNew) {return {kind: "pending",- reason: `The secret is newer than ${judgedFrom}, when reads started being counted, so nobody has had the whole period to read it.`+ reason: "The secret is newer than 30 days, so nobody has had 30 days to read it."};}return { kind: "pending", reason: "Not counted as unused access." };