Skip to content

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

feat: add route to calculate the secret counts org wide

adilson6c3a2f934117
diff --git a/backend/e2e-test/insights-counts.spec.ts b/backend/e2e-test/insights-counts.spec.ts
new file mode 100644
index 0000000000..825ece1ad9
--- /dev/null
+++ b/backend/e2e-test/insights-counts.spec.ts
@@ -0,0 +1,250 @@
+import { randomUUID } from "node:crypto";
+
+import { ForbiddenError } from "@casl/ability";
+import { Knex } from "knex";
+import { afterAll, beforeAll, describe, expect, test } from "vitest";
+
+import {
+ ProjectType,
+ ProjectVersion,
+ TableName,
+ TAppConnectionsInsert,
+ TOrganizationsInsert,
+ TProjectEnvironmentsInsert,
+ TProjectsInsert,
+ TSecretFoldersInsert,
+ TSecretRotationsV2Insert,
+ TSecretsV2Insert,
+ TUsersInsert
+} from "@app/db/schemas";
+import { insightsDALFactory } from "@app/ee/services/insights/insights-dal";
+import { insightsServiceFactory } from "@app/ee/services/insights/insights-service";
+import { TOrgInsightsDTO } from "@app/ee/services/insights/insights-types";
+import { SecretRotationStatus } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";
+import { ActorType, AuthMethod } from "@app/services/auth/auth-type";
+
+import { buildOrgInsightsGateStubs, passThroughKeyStore, projectScopedInsightsDepStubs } from "./testUtils/insights";
+
+declare const testDb: Knex;
+
+const ORG_ID = randomUUID();
+const OTHER_ORG_ID = randomUUID();
+const suffix = randomUUID().slice(0, 8);
+
+const USER_ID = randomUUID();
+const CONNECTION_ID = randomUUID();
+
+// One project per scoping rule of countOrgSecretsResources. Only `smA` and `smB` may contribute.
+const projects = {
+ // Two environments, one of them soft-deleted; secrets and a rotation behind each
+ smA: {
+ projectId: randomUUID(),
+ envId: randomUUID(),
+ folderId: randomUUID(),
+ deletedEnvId: randomUUID(),
+ deletedEnvFolderId: randomUUID(),
+ name: `sm-a-${suffix}`
+ },
+ // A second live project so the counts prove aggregation rather than a single-project read
+ smB: { projectId: randomUUID(), envId: randomUUID(), folderId: randomUUID(), name: `sm-b-${suffix}` },
+ // Filtered out entirely
+ otherProductType: { projectId: randomUUID(), envId: randomUUID(), folderId: randomUUID(), name: `pam-${suffix}` },
+ deletedProject: { projectId: randomUUID(), envId: randomUUID(), folderId: randomUUID(), name: `del-${suffix}` },
+ oldVersion: { projectId: randomUUID(), envId: randomUUID(), folderId: randomUUID(), name: `v1-${suffix}` },
+ otherOrg: { projectId: randomUUID(), envId: randomUUID(), folderId: randomUUID(), name: `other-${suffix}` }
+};
+
+const projectList = Object.values(projects);
+
+const { permissionService, licenseService, setCanReadInsights, setPlanHasInsights } = buildOrgInsightsGateStubs();
+
+const insightsService = insightsServiceFactory({
+ ...projectScopedInsightsDepStubs,
+ permissionService,
+ licenseService,
+ orgDAL: { countAllOrgMembers: async () => 0 },
+ identityOrgMembershipDAL: { countAllOrgIdentities: async () => 0 },
+ dynamicSecretLeaseDAL: { countLeasesForOrg: async () => 0 },
+ insightsDAL: insightsDALFactory(testDb),
+ keyStore: passThroughKeyStore
+});
+
+const actor = (orgId: string): TOrgInsightsDTO => ({
+ actor: ActorType.USER,
+ actorId: USER_ID,
+ actorAuthMethod: AuthMethod.EMAIL,
+ actorOrgId: orgId,
+ orgId
+});
+
+const secret = (folderId: string, overrides: Partial<TSecretsV2Insert> = {}): TSecretsV2Insert & { id: string } => ({
+ id: randomUUID(),
+ key: `SECRET_${randomUUID().slice(0, 8)}`,
+ folderId,
+ ...overrides
+});
+
+describe("insights org secrets counts", () => {
+ beforeAll(async () => {
+ const orgRows: (TOrganizationsInsert & { id: string })[] = [
+ { id: ORG_ID, name: `counts-${suffix}`, slug: `counts-${suffix}` },
+ { id: OTHER_ORG_ID, name: `counts-other-${suffix}`, slug: `counts-other-${suffix}` }
+ ];
+ await testDb(TableName.Organization).insert(orgRows);
+
+ // Owner of the personal-override secret that must be excluded from the secrets count
+ const userRows: (TUsersInsert & { id: string })[] = [
+ { id: USER_ID, username: `counts-user-${suffix}`, isAccepted: true, isGhost: false }
+ ];
+ await testDb(TableName.Users).insert(userRows);
+
+ const projectRows: (TProjectsInsert & { id: string })[] = projectList.map((p) => ({
+ id: p.projectId,
+ name: p.name,
+ slug: p.name,
+ orgId: p === projects.otherOrg ? OTHER_ORG_ID : ORG_ID,
+ type: p === projects.otherProductType ? ProjectType.PAM : ProjectType.SecretManager,
+ // The counts only cover v3 projects (the column defaults to v1)
+ version: p === projects.oldVersion ? ProjectVersion.V1 : ProjectVersion.V3,
+ ...(p === projects.deletedProject ? { deleteAfter: new Date() } : {})
+ }));
+ await testDb(TableName.Project).insert(projectRows);
+
+ const environmentRows: (TProjectEnvironmentsInsert & { id: string })[] = [
+ ...projectList.map((p, index) => ({
+ id: p.envId,
+ name: "Development",
+ slug: "dev",
+ position: index + 1,
+ projectId: p.projectId
+ })),
+ {
+ id: projects.smA.deletedEnvId,
+ name: "Staging",
+ slug: "staging",
+ position: projectList.length + 1,
+ projectId: projects.smA.projectId,
+ deleteAfter: new Date()
+ }
+ ];
+ await testDb(TableName.Environment).insert(environmentRows);
+
+ const folderRows: (TSecretFoldersInsert & { id: string })[] = [
+ ...projectList.map((p) => ({
+ id: p.folderId,
+ name: "root",
+ envId: p.envId,
+ parentId: null
+ })),
+ { id: projects.smA.deletedEnvFolderId, name: "root", envId: projects.smA.deletedEnvId, parentId: null }
+ ];
+ await testDb(TableName.SecretFolder).insert(folderRows);
+
+ const secretRows: (TSecretsV2Insert & { id: string })[] = [
+ // smA: two shared secrets count, the personal override does not
+ secret(projects.smA.folderId),
+ secret(projects.smA.folderId),
+ secret(projects.smA.folderId, { userId: USER_ID, type: "personal" }),
+ // smA: behind the soft-deleted environment, must not count
+ secret(projects.smA.deletedEnvFolderId),
+ // smB: one shared secret
+ secret(projects.smB.folderId),
+ // each excluded project carries a secret that must not count
+ secret(projects.otherProductType.folderId),
+ secret(projects.deletedProject.folderId),
+ secret(projects.oldVersion.folderId),
+ secret(projects.otherOrg.folderId)
+ ];
+ await testDb(TableName.SecretV2).insert(secretRows);
+
+ const connectionRows: (TAppConnectionsInsert & { id: string })[] = [
+ {
+ id: CONNECTION_ID,
+ name: `conn-${suffix}`,
+ app: "postgres",
+ method: "username-and-password",
+ encryptedCredentials: Buffer.from("{}"),
+ orgId: ORG_ID
+ }
+ ];
+ await testDb(TableName.AppConnection).insert(connectionRows);
+
+ const rotation = (folderId: string, rotationStatus: string): TSecretRotationsV2Insert & { id: string } => ({
+ id: randomUUID(),
+ name: `rot-${randomUUID().slice(0, 8)}`,
+ type: "postgres-credentials",
+ parameters: {},
+ secretsMapping: {},
+ encryptedGeneratedCredentials: Buffer.from("{}"),
+ folderId,
+ connectionId: CONNECTION_ID,
+ rotationInterval: 30,
+ rotateAtUtc: { hours: 0, minutes: 0 },
+ rotationStatus,
+ lastRotationAttemptedAt: new Date(),
+ lastRotatedAt: new Date()
+ });
+ await testDb(TableName.SecretRotationV2).insert([
+ // the count is status-independent, so one of each status in the live scope
+ rotation(projects.smA.folderId, SecretRotationStatus.Success),
+ rotation(projects.smB.folderId, SecretRotationStatus.Failed),
+ // behind a soft-deleted environment / in an excluded project: must not count
+ rotation(projects.smA.deletedEnvFolderId, SecretRotationStatus.Success),
+ rotation(projects.otherProductType.folderId, SecretRotationStatus.Success)
+ ]);
+ });
+
+ afterAll(async () => {
+ const orgIds = [ORG_ID, OTHER_ORG_ID];
+ const folderIds = [...projectList.map((p) => p.folderId), projects.smA.deletedEnvFolderId];
+ await testDb(TableName.SecretRotationV2).where("connectionId", CONNECTION_ID).delete();
+ await testDb(TableName.AppConnection).where("id", CONNECTION_ID).delete();
+ await testDb(TableName.SecretV2).whereIn("folderId", folderIds).delete();
+ await testDb(TableName.SecretFolder).whereIn("id", folderIds).delete();
+ await testDb(TableName.Environment)
+ .whereIn("id", [...projectList.map((p) => p.envId), projects.smA.deletedEnvId])
+ .delete();
+ await testDb(TableName.Project).whereIn("orgId", orgIds).delete();
+ await testDb(TableName.Users).where("id", USER_ID).delete();
+ await testDb(TableName.Organization).whereIn("id", orgIds).delete();
+ });
+
+ test("returns whole-org counts scoped to live v3 secret-manager projects", async () => {
+ const counts = await insightsService.getOrgSecretsCounts(actor(ORG_ID));
+
+ expect(counts).toEqual({
+ // smA + smB: the PAM, soft-deleted, v1 and other-org projects are all excluded
+ projects: 2,
+ // smA's two live shared secrets + smB's one. The personal override, the secret behind the
+ // soft-deleted environment and the secrets in excluded projects contribute nothing.
+ secrets: 3,
+ // smA's live environment + smB's: the soft-deleted environment and excluded projects' don't count
+ environments: 2,
+ // one per live project; status does not matter
+ rotations: 2
+ });
+ });
+
+ test("an organization with no projects reports zeroes", async () => {
+ const counts = await insightsService.getOrgSecretsCounts(actor(randomUUID()));
+ expect(counts).toEqual({ projects: 0, secrets: 0, environments: 0, rotations: 0 });
+ });
+
+ test("throws when the actor cannot read secrets management insights", async () => {
+ setCanReadInsights(false);
+ try {
+ await expect(insightsService.getOrgSecretsCounts(actor(ORG_ID))).rejects.toBeInstanceOf(ForbiddenError);
+ } finally {
+ setCanReadInsights(true);
+ }
+ });
+
+ test("throws when the plan does not include secret access insights", async () => {
+ setPlanHasInsights(false);
+ try {
+ await expect(insightsService.getOrgSecretsCounts(actor(ORG_ID))).rejects.toThrow(/Upgrade your plan/);
+ } finally {
+ setPlanHasInsights(true);
+ }
+ });
+});
diff --git a/backend/e2e-test/insights-project-warnings.spec.ts b/backend/e2e-test/insights-project-warnings.spec.ts
index 25a33c1ff3..2e72687adc 100644
--- a/backend/e2e-test/insights-project-warnings.spec.ts
+++ b/backend/e2e-test/insights-project-warnings.spec.ts
@@ -280,7 +280,7 @@ describe("insights secrets project warnings", () => {
});
test("returns all secret-manager projects ordered by severity with correct counts", async () => {
- const result = await insightsService.getSecretsProjectWarnings(actor(ORG_ID));
+ const result = await insightsService.getSecretsProjects(actor(ORG_ID));
// warn, clean, noBlindIndex, deletedEnv. The PAM project, the soft-deleted
// project, the v1 project and the other org's project are excluded from the listing.
@@ -339,7 +339,7 @@ describe("insights secrets project warnings", () => {
});
test("pagination slices rows while window totals stay constant", async () => {
- const page = await insightsService.getSecretsProjectWarnings(actor(ORG_ID, { offset: 1, limit: 2 }));
+ const page = await insightsService.getSecretsProjects(actor(ORG_ID, { offset: 1, limit: 2 }));
expect(page.totalProjects).toBe(4);
expect(page.projectsWithIssues).toBe(1);
@@ -349,7 +349,7 @@ describe("insights secrets project warnings", () => {
});
test("an organization with no projects reports empty results", async () => {
- const result = await insightsService.getSecretsProjectWarnings(actor(randomUUID()));
+ const result = await insightsService.getSecretsProjects(actor(randomUUID()));
expect(result.projects).toEqual([]);
expect(result.totalProjects).toBe(0);
expect(result.projectsWithIssues).toBe(0);
@@ -358,7 +358,7 @@ describe("insights secrets project warnings", () => {
test("throws when the actor cannot read secrets management insights", async () => {
setCanReadInsights(false);
try {
- await expect(insightsService.getSecretsProjectWarnings(actor(ORG_ID))).rejects.toBeInstanceOf(ForbiddenError);
+ await expect(insightsService.getSecretsProjects(actor(ORG_ID))).rejects.toBeInstanceOf(ForbiddenError);
} finally {
setCanReadInsights(true);
}
@@ -367,7 +367,7 @@ describe("insights secrets project warnings", () => {
test("throws when the plan does not include secret access insights", async () => {
setPlanHasInsights(false);
try {
- await expect(insightsService.getSecretsProjectWarnings(actor(ORG_ID))).rejects.toThrow(/Upgrade your plan/);
+ await expect(insightsService.getSecretsProjects(actor(ORG_ID))).rejects.toThrow(/Upgrade your plan/);
} finally {
setPlanHasInsights(true);
}
diff --git a/backend/e2e-test/routes/v1/insights.spec.ts b/backend/e2e-test/routes/v1/insights.spec.ts
index 14bfd8cc80..abdcedc870 100644
--- a/backend/e2e-test/routes/v1/insights.spec.ts
+++ b/backend/e2e-test/routes/v1/insights.spec.ts
@@ -11,7 +11,8 @@ const ORG_SCOPED_URLS = {
projects: PROJECTS_URL,
accessVolume: "/api/v1/insights/secrets/access-volume",
authMethods: "/api/v1/insights/secrets/usage/auth-methods",
- staticSecrets: "/api/v1/insights/secrets/usage/static-secrets"
+ staticSecrets: "/api/v1/insights/secrets/usage/static-secrets",
+ counts: "/api/v1/insights/secrets/counts"
};
describe("Insights V1 Router (org-scoped)", async () => {
diff --git a/backend/src/ee/routes/v1/insights-router.ts b/backend/src/ee/routes/v1/insights-router.ts
index b9b243a925..bdf8fab6f1 100644
--- a/backend/src/ee/routes/v1/insights-router.ts
+++ b/backend/src/ee/routes/v1/insights-router.ts
@@ -15,6 +15,7 @@ import {
import {
OrgAuthMethodDistributionSchema,
OrgSecretsAccessVolumeSchema,
+ OrgSecretsCountsSchema,
SecretsProjectsSchema,
SecretsSummarySchema,
StaticSecretsUsageSchema
@@ -274,6 +275,46 @@ export const registerInsightsRouter = async (server: FastifyZodProvider) => {
}
});
+ server.route({
+ method: "GET",
+ url: "/secrets/counts",
+ config: {
+ rateLimit: readLimit
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ schema: {
+ operationId: "getSecretsCounts",
+ description:
+ "Get whole-organization counts of secret management resources: projects, secrets, environments, and secret rotations.",
+ security: [{ bearerAuth: [] }],
+ response: {
+ 200: z.object({
+ counts: OrgSecretsCountsSchema
+ })
+ }
+ },
+ handler: async (req) => {
+ const counts = await server.services.insights.getOrgSecretsCounts({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ orgId: req.permission.orgId
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ orgId: req.permission.orgId,
+ event: {
+ type: EventType.VIEW_INSIGHTS_SECRETS_MANAGEMENT_ORG_COUNTS,
+ metadata: counts
+ }
+ });
+
+ return { counts };
+ }
+ });
+
server.route({
method: "GET",
url: "/:projectId/secrets/calendar",
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 04bdca27b9..56679e8a7c 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -686,6 +686,7 @@ export enum EventType {
VIEW_INSIGHTS_SECRETS_MANAGEMENT_COUNTS = "view-insights-secrets-management-counts",
VIEW_INSIGHTS_SECRETS_MANAGEMENT_USAGE = "view-insights-secrets-management-usage",
VIEW_INSIGHTS_SECRETS_MANAGEMENT_PROJECT_WARNINGS = "view-insights-secrets-management-project-warnings",
+ VIEW_INSIGHTS_SECRETS_MANAGEMENT_ORG_COUNTS = "view-insights-secrets-management-org-counts",
CREATE_AUDIT_REPORT = "create-audit-report",
GET_AUDIT_REPORTS = "get-audit-reports",
@@ -5569,6 +5570,16 @@ interface ViewSecretManagementInsightsProjectWarningsEvent {
};
}
+interface ViewSecretManagementInsightsOrgCountsEvent {
+ type: EventType.VIEW_INSIGHTS_SECRETS_MANAGEMENT_ORG_COUNTS;
+ metadata: {
+ projects: number;
+ secrets: number;
+ environments: number;
+ rotations: number;
+ };
+}
+
interface CreateAuditReportEvent {
type: EventType.CREATE_AUDIT_REPORT;
metadata: {
@@ -7524,6 +7535,7 @@ export type Event =
| ViewSecretManagementInsightsCountsEvent
| ViewSecretManagementInsightsUsageEvent
| ViewSecretManagementInsightsProjectWarningsEvent
+ | ViewSecretManagementInsightsOrgCountsEvent
| CreateAuditReportEvent
| GetAuditReportsEvent
| GetAuditReportEvent
diff --git a/backend/src/ee/services/insights/insights-dal.ts b/backend/src/ee/services/insights/insights-dal.ts
index 317710598d..1f39d25a78 100644
--- a/backend/src/ee/services/insights/insights-dal.ts
+++ b/backend/src/ee/services/insights/insights-dal.ts
@@ -297,5 +297,58 @@ export const insightsDALFactory = (db: TDbClient) => {
}
};
- return { findProjectWarningsForOrg, findSecretCreationsByWeekForOrg, countSecretCreationsForOrg };
+ const countOrgSecretsResources = async (
+ orgId: string,
+ tx?: Knex
+ ): Promise<{ projects: number; secrets: number; environments: number; rotations: number }> => {
+ try {
+ const conn = tx || db.replicaNode();
+
+ const scopeToOrgProjects = <T extends Knex.QueryBuilder>(qb: T): T =>
+ qb
+ .where(`${TableName.Project}.orgId`, orgId)
+ .where(`${TableName.Project}.type`, ProjectType.SecretManager)
+ .where(`${TableName.Project}.version`, ProjectVersion.V3)
+ .whereNull(`${TableName.Project}.deleteAfter`) as T;
+
+ const [projectsRow, environmentsRow, secretsRow, rotationsRow] = await Promise.all([
+ scopeToOrgProjects(conn(TableName.Project)).count("* as count").first(),
+ scopeToOrgProjects(
+ conn(TableName.Environment)
+ .join(TableName.Project, `${TableName.Environment}.projectId`, `${TableName.Project}.id`)
+ .whereNull(`${TableName.Environment}.deleteAfter`)
+ )
+ .count("* as count")
+ .first(),
+ orgStaticSecretsQuery(conn, orgId).count("* as count").first(),
+ scopeToOrgProjects(
+ conn(TableName.SecretRotationV2)
+ .join(TableName.SecretFolder, `${TableName.SecretRotationV2}.folderId`, `${TableName.SecretFolder}.id`)
+ .join(TableName.Environment, `${TableName.SecretFolder}.envId`, `${TableName.Environment}.id`)
+ .join(TableName.Project, `${TableName.Environment}.projectId`, `${TableName.Project}.id`)
+ .whereNull(`${TableName.Environment}.deleteAfter`)
+ )
+ .count("* as count")
+ .first()
+ ]);
+
+ const toCount = (row: unknown) => Number((row as { count?: string | number } | undefined)?.count ?? 0);
+
+ return {
+ projects: toCount(projectsRow),
+ secrets: toCount(secretsRow),
+ environments: toCount(environmentsRow),
+ rotations: toCount(rotationsRow)
+ };
+ } catch (error) {
+ throw new DatabaseError({ error, name: "CountOrgSecretsResources" });
+ }
+ };
+
+ return {
+ findProjectWarningsForOrg,
+ findSecretCreationsByWeekForOrg,
+ countSecretCreationsForOrg,
+ countOrgSecretsResources
+ };
};
diff --git a/backend/src/ee/services/insights/insights-schemas.ts b/backend/src/ee/services/insights/insights-schemas.ts
index b3b7f981c1..cd96de46dc 100644
--- a/backend/src/ee/services/insights/insights-schemas.ts
+++ b/backend/src/ee/services/insights/insights-schemas.ts
@@ -50,6 +50,13 @@ export const OrgAuthMethodDistributionSchema = z.object({
.describe(INSIGHTS.GET_SECRETS_AUTH_METHOD_DISTRIBUTION.methods)
});
+export const OrgSecretsCountsSchema = z.object({
+ projects: z.number().int().describe(INSIGHTS.GET_SECRETS_COUNTS.projects),
+ secrets: z.number().int().describe(INSIGHTS.GET_SECRETS_COUNTS.secrets),
+ environments: z.number().int().describe(INSIGHTS.GET_SECRETS_COUNTS.environments),
+ rotations: z.number().int().describe(INSIGHTS.GET_SECRETS_COUNTS.rotations)
+});
+
export const StaticSecretsUsageSchema = z.object({
weeks: z
.object({
diff --git a/backend/src/ee/services/insights/insights-service.ts b/backend/src/ee/services/insights/insights-service.ts
index 77d71a8ec6..1c3c8a2b51 100644
--- a/backend/src/ee/services/insights/insights-service.ts
+++ b/backend/src/ee/services/insights/insights-service.ts
@@ -59,6 +59,7 @@ import {
TOrgAccessVolume,
TOrgAuthMethodDistribution,
TOrgInsightsDTO,
+ TOrgSecretsCounts,
TSecretsProjectWarnings,
TSecretsUsageInsights,
TStaticSecretsUsage
@@ -93,7 +94,10 @@ export type TInsightsServiceFactoryDep = {
dynamicSecretLeaseDAL: Pick<TDynamicSecretLeaseDALFactory, "countLeasesForOrg">;
insightsDAL: Pick<
TInsightsDALFactory,
- "findProjectWarningsForOrg" | "findSecretCreationsByWeekForOrg" | "countSecretCreationsForOrg"
+ | "findProjectWarningsForOrg"
+ | "findSecretCreationsByWeekForOrg"
+ | "countSecretCreationsForOrg"
+ | "countOrgSecretsResources"
>;
};
@@ -710,6 +714,18 @@ export const insightsServiceFactory = ({
});
};
+ const getOrgSecretsCounts = async (dto: TOrgInsightsDTO): Promise<TOrgSecretsCounts> => {
+ await assertOrgInsightsRead(dto);
+
+ const cacheKey = KeyStorePrefixes.InsightsCache(dto.orgId, "org-counts");
+ return withCache({
+ keyStore,
+ key: cacheKey,
+ ttlSeconds: KeyStoreTtls.InsightsCacheInSeconds,
+ fetcher: () => insightsDAL.countOrgSecretsResources(dto.orgId)
+ });
+ };
+
// How many static secrets the org created in each of the last 12 UTC calendar weeks.
//
// Deleting a secret is a hard delete with no tombstone, so a week can only be counted from the
@@ -767,6 +783,7 @@ export const insightsServiceFactory = ({
getCounts,
getSecretsUsageInsights,
getSecretsProjects,
- getStaticSecretsUsage
+ getStaticSecretsUsage,
+ getOrgSecretsCounts
};
};
diff --git a/backend/src/ee/services/insights/insights-types.ts b/backend/src/ee/services/insights/insights-types.ts
index 7af2b9d9a1..24c8e7120b 100644
--- a/backend/src/ee/services/insights/insights-types.ts
+++ b/backend/src/ee/services/insights/insights-types.ts
@@ -5,6 +5,7 @@ import { TOrgPermission } from "@app/lib/types";
import {
OrgAuthMethodDistributionSchema,
OrgSecretsAccessVolumeSchema,
+ OrgSecretsCountsSchema,
SecretsProjectsSchema,
SecretsProjectWarningSchema,
SecretsSummarySchema,
@@ -59,6 +60,7 @@ export type TSecretsProjectWarnings = z.infer<typeof SecretsProjectsSchema>;
export type TOrgAccessVolume = z.infer<typeof OrgSecretsAccessVolumeSchema>;
export type TOrgAuthMethodDistribution = z.infer<typeof OrgAuthMethodDistributionSchema>;
export type TStaticSecretsUsage = z.infer<typeof StaticSecretsUsageSchema>;
+export type TOrgSecretsCounts = z.infer<typeof OrgSecretsCountsSchema>;
export type TAccessVolumeActor = {
name: string;
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index de9e80cab2..fedb6e4ae2 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -940,6 +940,13 @@ export const INSIGHTS = {
unknownCount:
"The number of accesses whose authentication method could not be determined, which happens for accesses recorded before the method was captured in audit logs. These are included in the total but not in the methods list."
},
+ GET_SECRETS_COUNTS: {
+ projects: "The number of secret management projects in the organization.",
+ secrets:
+ "The total number of shared static secrets across every secret management project in the organization. Personal secret overrides are not counted.",
+ environments: "The total number of environments across every secret management project in the organization.",
+ rotations: "The total number of secret rotations across every secret management project in the organization."
+ },
GET_STATIC_SECRETS_USAGE: {
weeks:
"One entry for each of the last twelve weeks, oldest first. Weeks in which no secret was created are included with a count of zero.",