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
chore: drop unused accountCount from pam resource breakdown
bernie-gda60f1211c81
diff --git a/backend/src/ee/routes/v1/pam-insights-router.ts b/backend/src/ee/routes/v1/pam-insights-router.tsindex 29dd6e00f3..bf211d4b40 100644--- a/backend/src/ee/routes/v1/pam-insights-router.ts+++ b/backend/src/ee/routes/v1/pam-insights-router.ts@@ -135,8 +135,7 @@ export const registerPamInsightsRouter = async (server: FastifyZodProvider) => {breakdown: z.array(z.object({resourceType: z.string(),- resourceCount: z.number(),- accountCount: z.number()+ resourceCount: z.number()}))})diff --git a/backend/src/ee/services/pam-account/pam-account-dal.ts b/backend/src/ee/services/pam-account/pam-account-dal.tsindex 8cccec515c..6bf7281f9c 100644--- a/backend/src/ee/services/pam-account/pam-account-dal.ts+++ b/backend/src/ee/services/pam-account/pam-account-dal.ts@@ -342,25 +342,6 @@ export const pamAccountDALFactory = (db: TDbClient) => {}[];};- const countByProjectGroupedByResourceType = async (- projectId: string,- tx?: Knex- ): Promise<{ resourceType: string; count: number }[]> => {- // leftJoin + COALESCE so domain accounts (resourceId IS NULL) are bucketed under- // a synthetic "domain" type instead of being silently dropped from the breakdown.- const rows = (await (tx || db.replicaNode())(TableName.PamAccount)- .leftJoin(TableName.PamResource, `${TableName.PamAccount}.resourceId`, `${TableName.PamResource}.id`)- .select(db.raw(`COALESCE("${TableName.PamResource}"."resourceType", 'domain') as "resourceType"`))- .count(`${TableName.PamAccount}.id as count`)- .where(`${TableName.PamAccount}.projectId`, projectId)- .groupByRaw(`COALESCE("${TableName.PamResource}"."resourceType", 'domain')`)) as unknown as {- resourceType: string;- count: string | number;- }[];-- return rows.map((row) => ({ resourceType: row.resourceType, count: Number(row.count) }));- };-const findRotationCandidatesByProject = async (projectId: string,tx?: Knex@@ -409,7 +390,6 @@ export const pamAccountDALFactory = (db: TDbClient) => {findRotationCandidatesByProject,countByProject,countFailedRotationsByProject,- findFailedRotationsByProject,- countByProjectGroupedByResourceType+ findFailedRotationsByProject};};diff --git a/backend/src/ee/services/pam-insights/pam-insights-service.ts b/backend/src/ee/services/pam-insights/pam-insights-service.tsindex 2f78b785da..af58b09aca 100644--- a/backend/src/ee/services/pam-insights/pam-insights-service.ts+++ b/backend/src/ee/services/pam-insights/pam-insights-service.ts@@ -32,7 +32,6 @@ type TPamInsightsServiceFactoryDep = {| "countByProject"| "countFailedRotationsByProject"| "findFailedRotationsByProject"- | "countByProjectGroupedByResourceType"| "findRotationCandidatesByProject">;pamResourceRotationRulesDAL: Pick<TPamResourceRotationRulesDALFactory, "findByResourceIds">;@@ -181,18 +180,11 @@ export const pamInsightsServiceFactory = ({key: KeyStorePrefixes.InsightsCache(projectId, "pam:resource-breakdown"),ttlSeconds: KeyStoreTtls.InsightsCacheInSeconds,fetcher: async () => {- const [resourceCounts, accountCounts] = await Promise.all([- pamResourceDAL.countByProjectGroupedByType(projectId),- pamAccountDAL.countByProjectGroupedByResourceType(projectId)- ]);-- const accountsByType = new Map<string, number>();- accountCounts.forEach((row) => accountsByType.set(row.resourceType, row.count));+ const resourceCounts = await pamResourceDAL.countByProjectGroupedByType(projectId);const breakdown = resourceCounts.map((row) => ({resourceType: row.resourceType,- resourceCount: row.count,- accountCount: accountsByType.get(row.resourceType) ?? 0+ resourceCount: row.count}));breakdown.sort((a, b) => b.resourceCount - a.resourceCount);diff --git a/frontend/src/hooks/api/pamInsights/types.ts b/frontend/src/hooks/api/pamInsights/types.tsindex 2d795f1bfd..f35212f1d1 100644--- a/frontend/src/hooks/api/pamInsights/types.ts+++ b/frontend/src/hooks/api/pamInsights/types.ts@@ -45,7 +45,6 @@ export type TPamTopActorsResponse = {export type TPamResourceBreakdownEntry = {resourceType: string;resourceCount: number;- accountCount: number;};export type TPamResourceBreakdownResponse = {