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
fix: lint errors and migration
adilson8332b6ca1eac
diff --git a/backend/src/db/migrations/20260409120000_add-webhook-event-toggles.ts b/backend/src/db/migrations/20260409120000_add-webhook-event-toggles.tsindex e87966aa38..30384744f7 100644--- a/backend/src/db/migrations/20260409120000_add-webhook-event-toggles.ts+++ b/backend/src/db/migrations/20260409120000_add-webhook-event-toggles.ts@@ -3,29 +3,14 @@ import { Knex } from "knex";import { TableName } from "../schemas";const BLOCKED_EVENTS_COLUMN = "blockedEvents";-const SECRET_MODIFIED_EVENT_COLUMN = "isSecretModifiedEventEnabled";-const SECRET_ROTATION_FAILED_EVENT_COLUMN = "isSecretRotationFailedEventEnabled";export async function up(knex: Knex): Promise<void> {const hasWebhookTable = await knex.schema.hasTable(TableName.Webhook);if (!hasWebhookTable) return;- const hasSecretModifiedEventColumn = await knex.schema.hasColumn(TableName.Webhook, SECRET_MODIFIED_EVENT_COLUMN);- const hasSecretRotationFailedEventColumn = await knex.schema.hasColumn(- TableName.Webhook,- SECRET_ROTATION_FAILED_EVENT_COLUMN- );const hasBlockedEventsColumn = await knex.schema.hasColumn(TableName.Webhook, BLOCKED_EVENTS_COLUMN);await knex.schema.alterTable(TableName.Webhook, (table) => {- if (hasSecretModifiedEventColumn) {- table.dropColumn(SECRET_MODIFIED_EVENT_COLUMN);- }-- if (hasSecretRotationFailedEventColumn) {- table.dropColumn(SECRET_ROTATION_FAILED_EVENT_COLUMN);- }-if (!hasBlockedEventsColumn) {table.specificType(BLOCKED_EVENTS_COLUMN, "text[]").notNullable().defaultTo(knex.raw("'{}'"));}@@ -37,23 +22,10 @@ export async function down(knex: Knex): Promise<void> {if (!hasWebhookTable) return;const hasBlockedEventsColumn = await knex.schema.hasColumn(TableName.Webhook, BLOCKED_EVENTS_COLUMN);- const hasSecretModifiedEventColumn = await knex.schema.hasColumn(TableName.Webhook, SECRET_MODIFIED_EVENT_COLUMN);- const hasSecretRotationFailedEventColumn = await knex.schema.hasColumn(- TableName.Webhook,- SECRET_ROTATION_FAILED_EVENT_COLUMN- );await knex.schema.alterTable(TableName.Webhook, (table) => {if (hasBlockedEventsColumn) {table.dropColumn(BLOCKED_EVENTS_COLUMN);}-- if (!hasSecretModifiedEventColumn) {- table.boolean(SECRET_MODIFIED_EVENT_COLUMN).notNullable().defaultTo(true);- }-- if (!hasSecretRotationFailedEventColumn) {- table.boolean(SECRET_ROTATION_FAILED_EVENT_COLUMN).notNullable().defaultTo(true);- }});}diff --git a/backend/src/db/schemas/webhooks.ts b/backend/src/db/schemas/webhooks.tsindex fa04412323..a35603ed0d 100644--- a/backend/src/db/schemas/webhooks.ts+++ b/backend/src/db/schemas/webhooks.ts@@ -6,6 +6,7 @@import { z } from "zod";import { zodBuffer } from "@app/lib/zod";+import { WebhookEvents } from "@app/services/webhook/webhook-types";import { TImmutableDBKeys } from "./models";@@ -30,7 +31,10 @@ export const WebhooksSchema = z.object({type: z.string().default("general").nullable().optional(),encryptedPassKey: zodBuffer.nullable().optional(),encryptedUrl: zodBuffer,- blockedEvents: z.string().array().default([])+ blockedEvents: z+ .nativeEnum(WebhookEvents)+ .array()+ .default([WebhookEvents.SecretModified, WebhookEvents.SecretRotationFailed])});export type TWebhooks = z.infer<typeof WebhooksSchema>;diff --git a/backend/src/services/webhook/webhook-fns.ts b/backend/src/services/webhook/webhook-fns.tsindex 2540a63c03..ae262947e3 100644--- a/backend/src/services/webhook/webhook-fns.ts+++ b/backend/src/services/webhook/webhook-fns.ts@@ -248,7 +248,21 @@ export const getWebhookPayload = (event: TWebhookPayloads) => {}}- logger.warn({ event }, "Unhandled webhook event");+ if (event.type === WebhookEvents.TestEvent) {+ const { projectName, projectId, environment, secretPath } = event.payload;+ return {+ event: event.type,+ project: {+ workspaceId: projectId,+ projectId,+ projectName,+ environment,+ secretPath+ }+ };+ }++ throw new Error(`Unhandled webhook event type: ${(event as { type: string }).type}`);};export type TFnTriggerWebhookDTO = {diff --git a/backend/src/services/webhook/webhook-service.ts b/backend/src/services/webhook/webhook-service.tsindex cee8674913..bcdfb32d39 100644--- a/backend/src/services/webhook/webhook-service.ts+++ b/backend/src/services/webhook/webhook-service.ts@@ -41,14 +41,14 @@ export const webhookServiceFactory = ({const toBlockedEvents = (isSecretModifiedEventEnabled?: boolean,isSecretRotationFailedEventEnabled?: boolean- ): string[] => {- const blocked: string[] = [];+ ): WebhookEvents[] => {+ const blocked: WebhookEvents[] = [];if (isSecretModifiedEventEnabled === false) blocked.push(WebhookEvents.SecretModified);if (isSecretRotationFailedEventEnabled === false) blocked.push(WebhookEvents.SecretRotationFailed);return blocked;};- const withEventFlags = <T extends { blockedEvents?: string[] | null }>(webhook: T) => ({+ const withEventFlags = <T extends { blockedEvents?: WebhookEvents[] | null }>(webhook: T) => ({...webhook,isSecretModifiedEventEnabled: !webhook.blockedEvents?.includes(WebhookEvents.SecretModified),isSecretRotationFailedEventEnabled: !webhook.blockedEvents?.includes(WebhookEvents.SecretRotationFailed)@@ -136,13 +136,13 @@ export const webhookServiceFactory = ({const updateData: {isDisabled?: boolean;- blockedEvents?: string[];+ blockedEvents?: WebhookEvents[];} = {...(isDisabled !== undefined ? { isDisabled } : {})};if (hasEventToggleUpdate) {- const currentBlocked = new Set(webhook.blockedEvents ?? []);+ const currentBlocked = new Set<WebhookEvents>(webhook.blockedEvents ?? []);if (isSecretModifiedEventEnabled !== undefined) {if (isSecretModifiedEventEnabled) {@@ -211,7 +211,7 @@ export const webhookServiceFactory = ({webhook,(value) => secretManagerDecryptor({ cipherTextBlob: value }).toString(),getWebhookPayload({- type: "test" as WebhookEvents.SecretModified,+ type: WebhookEvents.TestEvent,payload: {projectName: project.name,projectId: webhook.projectId,diff --git a/backend/src/services/webhook/webhook-types.ts b/backend/src/services/webhook/webhook-types.tsindex 587058d4e1..5e9ede3723 100644--- a/backend/src/services/webhook/webhook-types.ts+++ b/backend/src/services/webhook/webhook-types.ts@@ -72,4 +72,18 @@ type TWebhookSecretRotationFailedEventPayload = {};};-export type TWebhookPayloads = TWebhookSecretModifiedEventPayload | TWebhookSecretRotationFailedEventPayload;+type TWebhookTestEventPayload = {+ type: WebhookEvents.TestEvent;+ payload: {+ projectName?: string;+ projectId: string;+ environment: string;+ secretPath?: string;+ type?: string | null;+ };+};++export type TWebhookPayloads =+ | TWebhookSecretModifiedEventPayload+ | TWebhookSecretRotationFailedEventPayload+ | TWebhookTestEventPayload;