Skip to content

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

fix: address review feedback on secret insights resource counts

Scott Wilson2a7c6b13f662
diff --git a/backend/src/ee/routes/v1/insights-router.ts b/backend/src/ee/routes/v1/insights-router.ts
index 36df7d0dd0..f307956d48 100644
--- a/backend/src/ee/routes/v1/insights-router.ts
+++ b/backend/src/ee/routes/v1/insights-router.ts
@@ -312,7 +312,13 @@ export const registerInsightsRouter = async (server: FastifyZodProvider) => {
onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
const { projectId } = req.query;
- return server.services.insights.getCounts({ projectId }, req.permission);
+ const result = await server.services.insights.getCounts({ projectId }, req.permission);
+ await server.services.auditLog.createAuditLog({
+ projectId,
+ event: { type: EventType.VIEW_INSIGHTS_SECRETS_MANAGEMENT_COUNTS, metadata: { projectId } },
+ ...req.auditLogInfo
+ });
+ return result;
}
});
};
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 0677b4addb..c2f5c690e7 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -698,6 +698,7 @@ export enum EventType {
VIEW_INSIGHTS_SECRETS_MANAGEMENT_ACCESS_LOCATIONS = "view-insights-secrets-management-access-locations",
VIEW_INSIGHTS_SECRETS_MANAGEMENT_SUMMARY = "view-insights-secrets-management-summary",
VIEW_INSIGHTS_SECRETS_DUPLICATION = "view-insights-secrets-duplication",
+ VIEW_INSIGHTS_SECRETS_MANAGEMENT_COUNTS = "view-insights-secrets-management-counts",
VIEW_INSIGHTS_PAM_SUMMARY = "view-insights-pam-summary",
VIEW_INSIGHTS_PAM_SESSION_ACTIVITY = "view-insights-pam-session-activity",
VIEW_INSIGHTS_PAM_TOP_ACTORS = "view-insights-pam-top-actors",
@@ -5694,6 +5695,13 @@ interface ViewInsightsSecretsDuplicationEvent {
};
}
+interface ViewSecretManagementInsightsCountsEvent {
+ type: EventType.VIEW_INSIGHTS_SECRETS_MANAGEMENT_COUNTS;
+ metadata: {
+ projectId: string;
+ };
+}
+
interface ViewAuditLogsEvent {
type: EventType.VIEW_AUDIT_LOGS;
metadata?: Record<string, unknown>;
@@ -7907,6 +7915,7 @@ export type Event =
| ViewInsightsAuthMethodsEvent
| ViewSecretManagementInsightsSummaryEvent
| ViewInsightsSecretsDuplicationEvent
+ | ViewSecretManagementInsightsCountsEvent
| ViewAuditLogsEvent
| ViewPamInsightsSummaryEvent
| ViewPamInsightsSessionActivityEvent
diff --git a/backend/src/ee/services/honey-token/honey-token-dal.ts b/backend/src/ee/services/honey-token/honey-token-dal.ts
index 385242c052..a2163063b8 100644
--- a/backend/src/ee/services/honey-token/honey-token-dal.ts
+++ b/backend/src/ee/services/honey-token/honey-token-dal.ts
@@ -141,8 +141,12 @@ export const honeyTokenDALFactory = (db: TDbClient) => {
const countByProjectId = async (projectId: string, tx?: Knex) => {
const [result] = await (tx || db.replicaNode())(TableName.HoneyToken)
+ .join(TableName.SecretFolder, `${TableName.SecretFolder}.id`, `${TableName.HoneyToken}.folderId`)
+ .join(TableName.Environment, `${TableName.Environment}.id`, `${TableName.SecretFolder}.envId`)
.where(`${TableName.HoneyToken}.projectId`, projectId)
.whereNot(`${TableName.HoneyToken}.status`, "revoked")
+ // exclude honey tokens in soft-deleted environments, mirroring findByFolderIds and the other counts
+ .whereNull(`${TableName.Environment}.deleteAfter`)
.count<{ count: string | number }>({
count: `${TableName.HoneyToken}.id`
});
diff --git a/frontend/src/hooks/api/auditLogs/constants.tsx b/frontend/src/hooks/api/auditLogs/constants.tsx
index 0b2ce386bf..c7823b87da 100644
--- a/frontend/src/hooks/api/auditLogs/constants.tsx
+++ b/frontend/src/hooks/api/auditLogs/constants.tsx
@@ -286,6 +286,8 @@ export const eventToNameMap: { [K in EventType]: string } = {
[EventType.VIEW_INSIGHTS_AUTH_METHODS]: "View Machine Identity Auth Methods Insights",
[EventType.VIEW_INSIGHTS_SECRETS_MANAGEMENT_SUMMARY]: "View Secrets Management Summary Insights",
[EventType.VIEW_INSIGHTS_SECRETS_DUPLICATION]: "View Secrets Duplication Insights",
+ [EventType.VIEW_INSIGHTS_SECRETS_MANAGEMENT_COUNTS]:
+ "View Secrets Management Resource Counts Insights",
[EventType.CREATE_PROJECT_ROLE]: "Create Project Role",
[EventType.UPDATE_PROJECT_ROLE]: "Update Project Role",
diff --git a/frontend/src/hooks/api/auditLogs/enums.tsx b/frontend/src/hooks/api/auditLogs/enums.tsx
index bce97ad16c..87a3f6e537 100644
--- a/frontend/src/hooks/api/auditLogs/enums.tsx
+++ b/frontend/src/hooks/api/auditLogs/enums.tsx
@@ -278,6 +278,7 @@ export enum EventType {
VIEW_INSIGHTS_SECRETS_MANAGEMENT_SUMMARY = "view-insights-secrets-management-summary",
VIEW_INSIGHTS_AUTH_METHODS = "view-insights-auth-methods",
VIEW_INSIGHTS_SECRETS_DUPLICATION = "view-insights-secrets-duplication",
+ VIEW_INSIGHTS_SECRETS_MANAGEMENT_COUNTS = "view-insights-secrets-management-counts",
CREATE_PROJECT_ROLE = "create-project-role",
UPDATE_PROJECT_ROLE = "update-project-role",