Skip to content

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

some improvements based on PR comments

Matheus Nogueira6ece066d1873
diff --git a/backend/src/ee/services/honey-token/honey-token-service.ts b/backend/src/ee/services/honey-token/honey-token-service.ts
index 2f56b77b61..ee847775c1 100644
--- a/backend/src/ee/services/honey-token/honey-token-service.ts
+++ b/backend/src/ee/services/honey-token/honey-token-service.ts
@@ -18,8 +18,17 @@ import { SmtpTemplates } from "@app/services/smtp/smtp-service";
import { HoneyTokenEventType, HoneyTokenStatus, HoneyTokenType } from "./honey-token-enums";
import { THoneyTokenProviderHooks } from "./honey-token-provider-hook-types";
-import { THoneyTokenByIdInput, THoneyTokenCreateInput } from "./honey-token-provider-types";
-import { AwsHoneyTokenConfigSchema, AwsHoneyTokenEventMetadataSchema } from "./honey-token-types";
+import {
+ THoneyTokenByIdInput,
+ THoneyTokenCreateInput,
+ THoneyTokenListInput,
+ THoneyTokenUpdateInput
+} from "./honey-token-provider-types";
+import {
+ AwsHoneyTokenConfigSchema,
+ AwsHoneyTokenEventMetadataSchema,
+ THoneyTokenEventsInput
+} from "./honey-token-types";
import {
getHoneyTokenProviderDefinition,
getHoneyTokenServiceHooksByType,
@@ -347,17 +356,7 @@ export const honeyTokenServiceFactory = ({
};
const updateHoneyToken = async (
- {
- honeyTokenId,
- name,
- description,
- secretsMapping
- }: {
- honeyTokenId: string;
- name?: string;
- description?: string | null;
- secretsMapping?: Record<string, string>;
- },
+ { honeyTokenId, name, description, secretsMapping }: THoneyTokenUpdateInput,
actor: OrgServiceActor
) => {
await ensurePlanSupportsHoneyTokens(actor.orgId, "update honey token");
@@ -498,10 +497,7 @@ export const honeyTokenServiceFactory = ({
};
};
- const revokeHoneyToken = async (
- { honeyTokenId }: { honeyTokenId: string },
- actor: OrgServiceActor
- ) => {
+ const revokeHoneyToken = async ({ honeyTokenId }: THoneyTokenByIdInput, actor: OrgServiceActor) => {
await ensurePlanSupportsHoneyTokens(actor.orgId, "revoke honey token");
const honeyToken = await getHoneyTokenWithProjectAccess({
honeyTokenId,
@@ -579,10 +575,7 @@ export const honeyTokenServiceFactory = ({
return { honeyTokenId };
};
- const resetHoneyToken = async (
- { honeyTokenId }: { honeyTokenId: string },
- actor: OrgServiceActor
- ) => {
+ const resetHoneyToken = async ({ honeyTokenId }: THoneyTokenByIdInput, actor: OrgServiceActor) => {
const honeyToken = await getHoneyTokenWithProjectAccess({
honeyTokenId,
actor,
@@ -640,25 +633,7 @@ export const honeyTokenServiceFactory = ({
};
const getDashboardHoneyTokens = async (
- {
- projectId,
- environments,
- secretPath,
- search,
- orderBy,
- orderDirection,
- limit,
- offset
- }: {
- projectId: string;
- environments: string[];
- secretPath: string;
- search?: string;
- orderBy?: string;
- orderDirection?: OrderByDirection;
- limit?: number;
- offset?: number;
- },
+ { projectId, environments, secretPath, search, orderBy, orderDirection, limit, offset }: THoneyTokenListInput,
actor: OrgServiceActor
) => {
await getProjectPermission(projectId, actor);
@@ -842,10 +817,7 @@ export const honeyTokenServiceFactory = ({
return { acknowledged: true };
};
- const getHoneyTokenById = async (
- { honeyTokenId }: { honeyTokenId: string },
- actor: OrgServiceActor
- ) => {
+ const getHoneyTokenById = async ({ honeyTokenId }: THoneyTokenByIdInput, actor: OrgServiceActor) => {
const honeyToken = await getHoneyTokenWithProjectAccess({
honeyTokenId,
actor,
@@ -872,7 +844,7 @@ export const honeyTokenServiceFactory = ({
honeyTokenId,
offset,
limit
- }: { honeyTokenId: string; offset?: number; limit?: number },
+ }: THoneyTokenEventsInput,
actor: OrgServiceActor
) => {
const honeyToken = await getHoneyTokenWithProjectAccess({
diff --git a/backend/src/ee/services/honey-token/honey-token-types.ts b/backend/src/ee/services/honey-token/honey-token-types.ts
index 62ec7f2d6b..a26d2b6d07 100644
--- a/backend/src/ee/services/honey-token/honey-token-types.ts
+++ b/backend/src/ee/services/honey-token/honey-token-types.ts
@@ -47,3 +47,9 @@ export const HoneyTokenConfigSchema = z.discriminatedUnion("type", [
]);
export type THoneyTokenConfig = z.infer<typeof HoneyTokenConfigSchema>;
+
+export type THoneyTokenEventsInput = {
+ honeyTokenId: string;
+ offset?: number;
+ limit?: number;
+};
diff --git a/backend/src/server/routes/v1/dashboard-router.ts b/backend/src/server/routes/v1/dashboard-router.ts
index 73754dfc2f..2e7fcc4a25 100644
--- a/backend/src/server/routes/v1/dashboard-router.ts
+++ b/backend/src/server/routes/v1/dashboard-router.ts
@@ -1,7 +1,7 @@
import { ForbiddenError } from "@casl/ability";
import { z } from "zod";
-import { SecretFoldersSchema, SecretImportsSchema, SecretType } from "@app/db/schemas";
+import { HoneyTokensSchema, SecretFoldersSchema, SecretImportsSchema, SecretType } from "@app/db/schemas";
import { RemindersSchema } from "@app/db/schemas/reminders";
import { EventType, UserAgentType } from "@app/ee/services/audit-log/audit-log-types";
import { ProjectPermissionSecretActions } from "@app/ee/services/permission/project-permission";
@@ -32,6 +32,29 @@ import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
const MAX_DEEP_SEARCH_LIMIT = 500; // arbitrary limit to prevent excessive results
+const SanitizedHoneyTokenSchema = HoneyTokensSchema.pick({
+ id: true,
+ name: true,
+ description: true,
+ type: true,
+ status: true,
+ projectId: true,
+ folderId: true,
+ connectionId: true,
+ secretsMapping: true,
+ createdAt: true,
+ updatedAt: true
+}).extend({
+ environment: z.object({
+ id: z.string(),
+ name: z.string(),
+ slug: z.string()
+ }),
+ folder: z.object({
+ path: z.string()
+ })
+});
+
const parseSecretPathSearch = (search?: string) => {
if (!search)
return {
@@ -108,36 +131,13 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {
includeImports: booleanSchema.describe(DASHBOARD.SECRET_OVERVIEW_LIST.includeImports),
includeSecretRotations: booleanSchema.describe(DASHBOARD.SECRET_OVERVIEW_LIST.includeSecretRotations),
includeDynamicSecrets: booleanSchema.describe(DASHBOARD.SECRET_OVERVIEW_LIST.includeDynamicSecrets),
- includeHoneyTokens: booleanSchema.optional()
+ includeHoneyTokens: booleanSchema.describe(DASHBOARD.SECRET_OVERVIEW_LIST.includeHoneyTokens)
}),
response: {
200: z.object({
folders: SecretFoldersSchema.extend({ environment: z.string() }).array().optional(),
dynamicSecrets: SanitizedDynamicSecretSchema.extend({ environment: z.string() }).array().optional(),
- honeyTokens: z
- .object({
- id: z.string().uuid(),
- name: z.string(),
- description: z.string().nullable().optional(),
- type: z.string(),
- status: z.string(),
- projectId: z.string(),
- folderId: z.string().uuid(),
- connectionId: z.string().uuid(),
- secretsMapping: z.unknown(),
- createdAt: z.date(),
- updatedAt: z.date(),
- environment: z.object({
- id: z.string(),
- name: z.string(),
- slug: z.string()
- }),
- folder: z.object({
- path: z.string()
- })
- })
- .array()
- .optional(),
+ honeyTokens: SanitizedHoneyTokenSchema.array().optional(),
secretRotations: z
.intersection(
SecretRotationV2Schema,
@@ -726,7 +726,7 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {
includeDynamicSecrets: booleanSchema.describe(DASHBOARD.SECRET_DETAILS_LIST.includeDynamicSecrets),
includeImports: booleanSchema.describe(DASHBOARD.SECRET_DETAILS_LIST.includeImports),
includeSecretRotations: booleanSchema.describe(DASHBOARD.SECRET_DETAILS_LIST.includeSecretRotations),
- includeHoneyTokens: booleanSchema.optional()
+ includeHoneyTokens: booleanSchema.describe(DASHBOARD.SECRET_DETAILS_LIST.includeHoneyTokens)
}),
response: {
200: z.object({
@@ -738,30 +738,7 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {
.optional(),
folders: SecretFoldersSchema.array().optional(),
dynamicSecrets: SanitizedDynamicSecretSchema.array().optional(),
- honeyTokens: z
- .object({
- id: z.string().uuid(),
- name: z.string(),
- description: z.string().nullable().optional(),
- type: z.string(),
- status: z.string(),
- projectId: z.string(),
- folderId: z.string().uuid(),
- connectionId: z.string().uuid(),
- secretsMapping: z.unknown(),
- createdAt: z.date(),
- updatedAt: z.date(),
- environment: z.object({
- id: z.string(),
- name: z.string(),
- slug: z.string()
- }),
- folder: z.object({
- path: z.string()
- })
- })
- .array()
- .optional(),
+ honeyTokens: SanitizedHoneyTokenSchema.array().optional(),
secretRotations: z
.intersection(
SecretRotationV2Schema,