Skip to content

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

requested changes

Matheus Nogueira1093b2a361a6
diff --git a/backend/src/ee/routes/v1/insights-router.ts b/backend/src/ee/routes/v1/insights-router.ts
index 86767c3304..3093e48ed5 100644
--- a/backend/src/ee/routes/v1/insights-router.ts
+++ b/backend/src/ee/routes/v1/insights-router.ts
@@ -182,8 +182,10 @@ export const registerInsightsRouter = async (server: FastifyZodProvider) => {
secrets: z.array(
z.object({
key: z.string(),
- environment: z.string(),
- environmentSlug: z.string(),
+ environment: z.object({
+ name: z.string(),
+ slug: z.string()
+ }),
secretPath: z.string()
})
)
@@ -205,7 +207,7 @@ export const registerInsightsRouter = async (server: FastifyZodProvider) => {
...req.auditLogInfo
});
- if (remainingTTL >= 0) {
+ if (remainingTTL && remainingTTL >= 0) {
void reply.header("X-Cache-TTL", remainingTTL);
}
diff --git a/backend/src/ee/services/insights/insights-service.ts b/backend/src/ee/services/insights/insights-service.ts
index 88b9dd951a..f8046e11f7 100644
--- a/backend/src/ee/services/insights/insights-service.ts
+++ b/backend/src/ee/services/insights/insights-service.ts
@@ -510,12 +510,9 @@ export const insightsServiceFactory = ({
if (!project.secretBlindIndexEnabled) {
return {
result: {
- secretBlindIndexEnabled: false as const,
- groups: [] as {
- secrets: { key: string; environment: string; environmentSlug: string; secretPath: string }[];
- }[]
+ secretBlindIndexEnabled: false,
+ groups: []
},
- remainingTTL: -1
};
}
@@ -551,8 +548,10 @@ export const insightsServiceFactory = ({
const groups = filteredGroups.map((g) => ({
secrets: g.secrets.map((s) => ({
key: s.key,
- environment: s.environmentName,
- environmentSlug: s.environment,
+ environment: {
+ name: s.environmentName,
+ slug: s.environment
+ },
secretPath: folderRecord[s.folderId] ?? "/"
}))
}));
diff --git a/backend/src/lib/cache/with-cache.ts b/backend/src/lib/cache/with-cache.ts
index 62845d8f1e..ca2ad71e4e 100644
--- a/backend/src/lib/cache/with-cache.ts
+++ b/backend/src/lib/cache/with-cache.ts
@@ -2,7 +2,8 @@ import { TKeyStoreFactory } from "@app/keystore/keystore";
import { logger } from "@app/lib/logger";
import { permissionCacheFingerprintDurationHistogram, permissionCacheLookupCounter } from "@app/lib/telemetry/metrics";
-type TCacheKeyStore = Pick<TKeyStoreFactory, "getItem" | "setItemWithExpiry" | "ttl">;
+type TCacheKeyStore = Pick<TKeyStoreFactory, "getItem" | "setItemWithExpiry">;
+type TCacheKeyStoreTTLGetter = Pick<TKeyStoreFactory, "ttl">
/** Read a raw string from Redis, returning null on miss or error. */
const cacheGet = async (keyStore: TCacheKeyStore, key: string, errMsg: string): Promise<string | null> => {
@@ -80,7 +81,7 @@ export const withCache = async <T>({ keyStore, key, ttlSeconds, fetcher, reviver
/**
* Returns the remaining TTL (in seconds) for a cache key, or -1 if the key does not exist / has no expiry.
*/
-export const getCacheTtl = async (keyStore: TCacheKeyStore, key: string): Promise<number> => {
+export const getCacheTtl = async (keyStore: TCacheKeyStoreTTLGetter, key: string): Promise<number> => {
try {
const remaining = await keyStore.ttl(key);
// Redis returns -2 if key doesn't exist, -1 if no expiry is set
diff --git a/backend/src/queue/queue-service.ts b/backend/src/queue/queue-service.ts
index c8363e8979..319d6a93b5 100644
--- a/backend/src/queue/queue-service.ts
+++ b/backend/src/queue/queue-service.ts
@@ -190,6 +190,13 @@ export enum QueueJobs {
SecretBlindIndexMigration = "secret-blind-index-migration"
}
+export enum JobState {
+ NotFound = "not-found",
+ Pending = "pending",
+ Completed = "completed",
+ Failed = "failed"
+}
+
export type TQueueOptions = {
jobId: string;
removeOnComplete?: boolean | { count: number } | { age: number };
diff --git a/backend/src/server/routes/v1/project-router.ts b/backend/src/server/routes/v1/project-router.ts
index 2211342be4..c98b01f914 100644
--- a/backend/src/server/routes/v1/project-router.ts
+++ b/backend/src/server/routes/v1/project-router.ts
@@ -36,6 +36,7 @@ import { CaStatus } from "@app/services/certificate-authority/certificate-author
import { sanitizedCertificateTemplate } from "@app/services/certificate-template/certificate-template-schema";
import { validateMicrosoftTeamsChannelsSchema } from "@app/services/microsoft-teams/microsoft-teams-fns";
import { sanitizedPkiSubscriber } from "@app/services/pki-subscriber/pki-subscriber-schema";
+import { JobState } from "@app/queue/queue-service";
import { ProjectFilterType, SearchProjectSortBy } from "@app/services/project/project-types";
import { validateSlackChannelsField } from "@app/services/slack/slack-auth-validators";
import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
@@ -576,7 +577,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
rateLimit: writeLimit
},
schema: {
- hide: false,
+ hide: true,
operationId: "enableProjectSecretBlindIndex",
tags: [ApiDocsTags.Projects],
description: "Enable secret blind indexing for duplicate detection",
@@ -615,7 +616,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
rateLimit: readLimit
},
schema: {
- hide: false,
+ hide: true,
operationId: "getProjectSecretBlindIndexStatus",
tags: [ApiDocsTags.Projects],
description: "Get secret blind index migration status",
@@ -629,7 +630,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- status: z.enum(["not-found", "pending", "completed", "failed"]),
+ status: z.nativeEnum(JobState),
message: z.string().optional()
})
}
diff --git a/backend/src/services/project/project-queue.ts b/backend/src/services/project/project-queue.ts
index 3edf83b657..c9eeed6358 100644
--- a/backend/src/services/project/project-queue.ts
+++ b/backend/src/services/project/project-queue.ts
@@ -31,6 +31,8 @@ import {
import { crypto } from "@app/lib/crypto/cryptography";
import { logger } from "@app/lib/logger";
import { QueueJobs, QueueName, TQueueJobTypes, TQueueServiceFactory } from "@app/queue";
+import { JobState } from "@app/queue/queue-service";
+
import { TIntegrationAuthDALFactory } from "../integration-auth/integration-auth-dal";
import { TKmsServiceFactory } from "../kms/kms-service";
@@ -741,30 +743,30 @@ export const projectQueueFactory = ({
logger.error(err, `SecretBlindIndexMigration: failed [projectId=${job?.data.projectId}]`);
});
- const getSecretBlindIndexMigrationStatus = async (projectId: string) => {
+ const getJobState = async (projectId: string) => {
const jobId = `enable-blind-index-project-${projectId}`;
const job = await queueService.getJob(QueueName.SecretBlindIndexMigration, jobId);
if (!job) {
- return { status: "not-found" as const };
+ return { status: JobState.NotFound };
}
const state = await job.getState();
- if (state === "failed") {
- return { status: "failed" as const, message: job.failedReason ?? "Unknown error" };
+ if (state === JobState.Failed) {
+ return { status: JobState.Failed, message: job.failedReason ?? "Unknown error" };
}
- if (state === "completed") {
- return { status: "completed" as const };
+ if (state === JobState.Completed) {
+ return { status: JobState.Completed };
}
- return { status: "pending" as const };
+ return { status: JobState.Pending };
};
return {
upgradeProject,
startSecretBlindIndexMigration,
- getSecretBlindIndexMigrationStatus
+ getJobState
};
};
diff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-dal.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-dal.ts
index 01037833db..c6926e0587 100644
--- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-dal.ts
+++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-dal.ts
@@ -1028,7 +1028,7 @@ export const secretV2BridgeDALFactory = ({ db, keyStore }: TSecretV2DalArg) => {
const docs = await (tx || db.replicaNode())(TableName.SecretV2)
.join(TableName.SecretFolder, `${TableName.SecretV2}.folderId`, `${TableName.SecretFolder}.id`)
.join(TableName.Environment, `${TableName.SecretFolder}.envId`, `${TableName.Environment}.id`)
- .where("projectId", projectId)
+ .where(`${TableName.Environment}.projectId`, projectId)
.whereNull(`${TableName.Environment}.deleteAfter`)
.whereNull(`${TableName.SecretV2}.secretValueBlindIndex`)
.whereNotNull(`${TableName.SecretV2}.encryptedValue`)
diff --git a/backend/src/services/super-admin/super-admin-service.ts b/backend/src/services/super-admin/super-admin-service.ts
index e38239cdc3..cb73986549 100644
--- a/backend/src/services/super-admin/super-admin-service.ts
+++ b/backend/src/services/super-admin/super-admin-service.ts
@@ -86,7 +86,7 @@ type TSuperAdminServiceFactoryDep = {
kmsService: Pick<TKmsServiceFactory, "encryptWithRootKey" | "decryptWithRootKey" | "updateEncryptionStrategy">;
kmsRootConfigDAL: TKmsRootConfigDALFactory;
orgService: Pick<TOrgServiceFactory, "createOrganization">;
- keyStore: Pick<TKeyStoreFactory, "getItem" | "setItemWithExpiry" | "deleteItem" | "deleteItems" | "ttl">;
+ keyStore: Pick<TKeyStoreFactory, "getItem" | "setItemWithExpiry" | "deleteItem" | "deleteItems">;
licenseService: Pick<TLicenseServiceFactory, "onPremFeatures" | "updateSubscriptionOrgMemberCount">;
microsoftTeamsService: Pick<TMicrosoftTeamsServiceFactory, "initializeTeamsBot">;
invalidateCacheQueue: TInvalidateCacheQueueFactory;
diff --git a/frontend/src/hooks/api/auditLogs/constants.tsx b/frontend/src/hooks/api/auditLogs/constants.tsx
index b969caba01..786efa421c 100644
--- a/frontend/src/hooks/api/auditLogs/constants.tsx
+++ b/frontend/src/hooks/api/auditLogs/constants.tsx
@@ -283,6 +283,7 @@ export const eventToNameMap: { [K in EventType]: string } = {
"View Secrets Management Access Locations Insights",
[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.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 49dcd625d0..cf5894a93f 100644
--- a/frontend/src/hooks/api/auditLogs/enums.tsx
+++ b/frontend/src/hooks/api/auditLogs/enums.tsx
@@ -275,6 +275,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_AUTH_METHODS = "view-insights-auth-methods",
+ VIEW_INSIGHTS_SECRETS_DUPLICATION = "view-insights-secrets-duplication",
CREATE_PROJECT_ROLE = "create-project-role",
UPDATE_PROJECT_ROLE = "update-project-role",
diff --git a/frontend/src/hooks/api/secretInsights/types.ts b/frontend/src/hooks/api/secretInsights/types.ts
index f78c657760..90a6371f37 100644
--- a/frontend/src/hooks/api/secretInsights/types.ts
+++ b/frontend/src/hooks/api/secretInsights/types.ts
@@ -127,8 +127,10 @@ export type TGetSecretsDuplicationDTO = {
export type TDuplicatedSecretEntry = {
key: string;
- environment: string;
- environmentSlug: string;
+ environment: {
+ name: string;
+ slug: string;
+ };
secretPath: string;
};
diff --git a/frontend/src/pages/secret-manager/InsightsPage/components/DuplicatedSecretsCard.tsx b/frontend/src/pages/secret-manager/InsightsPage/components/DuplicatedSecretsCard.tsx
index cb7fcc6da5..1369822c40 100644
--- a/frontend/src/pages/secret-manager/InsightsPage/components/DuplicatedSecretsCard.tsx
+++ b/frontend/src/pages/secret-manager/InsightsPage/components/DuplicatedSecretsCard.tsx
@@ -214,7 +214,7 @@ export const DuplicatedSecretsCard = () => {
</div>
{(() => {
const locationCount = new Set(
- group.secrets.map((s) => `${s.environmentSlug}:${s.secretPath}`)
+ group.secrets.map((s) => `${s.environment.slug}:${s.secretPath}`)
).size;
return (
<Badge variant="neutral" className="flex items-center gap-1.5 font-normal">
@@ -242,7 +242,7 @@ export const DuplicatedSecretsCard = () => {
<TableBody>
{group.secrets.map((entry, idx) => (
<TableRow
- key={`${entry.key}-${entry.environment}-${entry.secretPath}-${String(idx)}`}
+ key={`${entry.key}-${entry.environment.slug}-${entry.secretPath}-${String(idx)}`}
className="group/row bg-mineshaft-900"
>
<TableCell isTruncatable className="max-w-60">
@@ -253,7 +253,7 @@ export const DuplicatedSecretsCard = () => {
</TableCell>
<TableCell>
<Badge variant="info" isTruncatable className="max-w-full">
- <span>{entry.environment}</span>
+ <span>{entry.environment.name}</span>
</Badge>
</TableCell>
<TableCell>
@@ -280,7 +280,7 @@ export const DuplicatedSecretsCard = () => {
},
search: {
secretPath: entry.secretPath,
- environments: [entry.environmentSlug]
+ environments: [entry.environment.slug]
}
})
}