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
remove duplicates
Thiago Araujo da Silvaaca8df605027
diff --git a/backend/src/ee/services/group/group-service.ts b/backend/src/ee/services/group/group-service.tsindex 4913a39f7b..1accdc5a6e 100644--- a/backend/src/ee/services/group/group-service.ts+++ b/backend/src/ee/services/group/group-service.ts@@ -24,7 +24,7 @@ import { requestMemoKeys } from "@app/lib/request-context/memo-keys";import { requestMemoize } from "@app/lib/request-context/request-memoizer";import { TGenericPermission } from "@app/lib/types";import { TAlertChannelRecipientDALFactory } from "@app/services/alert/alert-channel-recipient-dal";-import { AlertPrincipalType } from "@app/services/alert/alert-types";+import { prepareDeletedGroupAlertRecipientCleanup } from "@app/services/alert/alert-recipient-cleanup-fns";import { TIdentityDALFactory } from "@app/services/identity/identity-dal";import { TIdentityAccessTokenServiceFactory } from "@app/services/identity-access-token/identity-access-token-service";import { PamIdentities, SecretIdentities } from "@app/services/license-client";@@ -581,9 +581,11 @@ export const groupServiceFactory = ({}return groupDAL.transaction(async (tx) => {- // Read before the delete cascades the group memberships away — a member may have reached a- // project only through this group, leaving them stale on that project's alert channels.- const memberUserIds = (await userGroupMembershipDAL.find({ groupId }, { tx })).map((m) => m.userId);+ const finalizeAlertRecipients = await prepareDeletedGroupAlertRecipientCleanup(+ { userGroupMembershipDAL, alertChannelRecipientDAL },+ groupId,+ tx+ );const [deletedGroup] = await groupDAL.delete({@@ -593,15 +595,7 @@ export const groupServiceFactory = ({tx);- await alertChannelRecipientDAL.deleteByPrincipals(- {- principalType: AlertPrincipalType.GROUP,- principalIds: [groupId]- },- tx- );-- await alertChannelRecipientDAL.pruneOutOfScopeRecipients({ userIds: memberUserIds }, tx);+ await finalizeAlertRecipients();return deletedGroup;});diff --git a/backend/src/ee/services/scim/scim-service.ts b/backend/src/ee/services/scim/scim-service.tsindex e8d79321ea..ce1de2ae61 100644--- a/backend/src/ee/services/scim/scim-service.ts+++ b/backend/src/ee/services/scim/scim-service.ts@@ -30,7 +30,7 @@ import { recordScimOperationMetric, ScimOperation } from "@app/lib/telemetry/metimport { sanitizeEmail, validateEmail } from "@app/lib/validator/validate-email";import { TAdditionalPrivilegeDALFactory } from "@app/services/additional-privilege/additional-privilege-dal";import { TAlertChannelRecipientDALFactory } from "@app/services/alert/alert-channel-recipient-dal";-import { AlertPrincipalType } from "@app/services/alert/alert-types";+import { prepareDeletedGroupAlertRecipientCleanup } from "@app/services/alert/alert-recipient-cleanup-fns";import { TApprovalPolicyDALFactory } from "@app/services/approval-policy/approval-policy-dal";import { AuthTokenType } from "@app/services/auth/auth-type";import { TExternalGroupOrgRoleMappingDALFactory } from "@app/services/external-group-org-role-mapping/external-group-org-role-mapping-dal";@@ -1541,18 +1541,16 @@ export const scimServiceFactory = ({});const [group] = await groupDAL.transaction(async (tx) => {- // Read the members before the delete cascades their group memberships away — one may have- // reached a project only through this group, leaving them stale on its alert channels.- const memberUserIds = (await userGroupMembershipDAL.find({ groupId }, { tx })).map((m) => m.userId);+ const finalizeAlertRecipients = await prepareDeletedGroupAlertRecipientCleanup(+ { userGroupMembershipDAL, alertChannelRecipientDAL },+ groupId,+ tx+ );const deleted = await groupDAL.delete({ id: groupId, orgId }, tx);if (!deleted.length) return deleted;- await alertChannelRecipientDAL.deleteByPrincipals(- { principalType: AlertPrincipalType.GROUP, principalIds: [groupId] },- tx- );- await alertChannelRecipientDAL.pruneOutOfScopeRecipients({ userIds: memberUserIds }, tx);+ await finalizeAlertRecipients();return deleted;});diff --git a/backend/src/lib/logger/index.ts b/backend/src/lib/logger/index.tsindex 21cb66920f..a315fb3866 100644--- a/backend/src/lib/logger/index.ts+++ b/backend/src/lib/logger/index.ts@@ -1 +1,2 @@export { initLogger, logger } from "./logger";+export { sanitizeUrlForLog } from "./sanitize-url";diff --git a/backend/src/lib/pagerduty/integration-key.ts b/backend/src/lib/pagerduty/integration-key.tsnew file mode 100644index 0000000000..9ceaa0c8d2--- /dev/null+++ b/backend/src/lib/pagerduty/integration-key.ts@@ -0,0 +1,5 @@+import RE2 from "re2";++export const pagerDutyIntegrationKeyRegex = new RE2("^[a-f0-9]{32}$", "i");++export const PAGERDUTY_INTEGRATION_KEY_ERROR = "Integration key must be a 32-character hex string";diff --git a/backend/src/services/alert/alert-channel-service.test.ts b/backend/src/services/alert/alert-channel-service.test.tsindex b712ea11f7..e467f91e12 100644--- a/backend/src/services/alert/alert-channel-service.test.ts+++ b/backend/src/services/alert/alert-channel-service.test.ts@@ -172,21 +172,44 @@ describe("alert channel service", () => {});test("keeps an omitted secret on update", async () => {- const { service } = buildService();- const channel = seedRow({- id: "ch-1",- channelType: AlertChannelType.WEBHOOK,- encryptedConfig: encConfig({ url: "https://example.com/hook", signingSecret: "s3cr3t" })+ const { service, store } = buildService({+ seed: [+ seedRow({+ id: "ch-1",+ channelType: AlertChannelType.WEBHOOK,+ encryptedConfig: encConfig({ url: "https://example.com/hook", signingSecret: "s3cr3t" })+ })+ ]});// Config sent without signingSecret -> keep the existing one.- const finalConfig = await service.updateChannelInTx(+ await service.updateChannelInTx({ channelId: "ch-1", config: { url: "https://example.com/hook" } },- channel as never,+ store.get("ch-1") as never,cipher,tx);- expect(finalConfig).toEqual({ url: "https://example.com/hook", signingSecret: "s3cr3t" });++ const stored = JSON.parse(store.get("ch-1")!.encryptedConfig.toString()) as Record<string, unknown>;+ expect(stored).toEqual({ url: "https://example.com/hook", signingSecret: "s3cr3t" });+ });++ test("rejects changing the channel type of an existing channel", async () => {+ const { service } = buildService();+ const channel = seedRow({+ id: "ch-1",+ channelType: AlertChannelType.WEBHOOK,+ encryptedConfig: encConfig({ url: "https://example.com/hook" })+ });++ await expect(+ service.updateChannelInTx(+ { channelId: "ch-1", channelType: AlertChannelType.SLACK },+ channel as never,+ cipher,+ tx+ )+ ).rejects.toThrow("type cannot be changed");});test("clears an optional secret when explicitly emptied on update", async () => {@@ -197,17 +220,16 @@ describe("alert channel service", () => {encryptedConfig: encConfig({ url: "https://example.com/hook", signingSecret: "s3cr3t" })});- const finalConfig = await service.updateChannelInTx(+ await service.updateChannelInTx({ channelId: "ch-1", config: { url: "https://example.com/hook", signingSecret: "" } },channel as never,cipher,tx);- expect(finalConfig).toEqual({ url: "https://example.com/hook" });- // And it is actually gone from the stored ciphertext, not just hidden.+ // It is actually gone from the stored ciphertext, not just hidden.const stored = JSON.parse(store.get("ch-1")!.encryptedConfig.toString()) as Record<string, unknown>;- expect(stored).not.toHaveProperty("signingSecret");+ expect(stored).toEqual({ url: "https://example.com/hook" });});test("sets a new secret when a value is provided on update", async () => {diff --git a/backend/src/services/alert/alert-channel-service.ts b/backend/src/services/alert/alert-channel-service.tsindex 54064c6582..bd77b6d0de 100644--- a/backend/src/services/alert/alert-channel-service.ts+++ b/backend/src/services/alert/alert-channel-service.ts@@ -52,6 +52,7 @@ export type TCreateChannelInTxInput = {export type TUpdateChannelInTxInput = {channelId: string;+ channelType?: AlertChannelType | string;name?: string;config?: Record<string, unknown>;enabled?: boolean;@@ -168,7 +169,13 @@ export const alertChannelServiceFactory = ({channel: TAlertChannels,cipher: { encryptor: TAlertEncryptor; decryptor: TAlertDecryptor },tx: Knex- ): Promise<Record<string, unknown>> => {+ ): Promise<void> => {+ if (input.channelType !== undefined && input.channelType !== channel.channelType) {+ throw new BadRequestError({+ message: `Channel '${channel.id}' is a ${channel.channelType} channel and its type cannot be changed to ${input.channelType}`+ });+ }+const definition = getChannelDefinition(channel.channelType);const existingConfig = decryptChannelConfig<Record<string, unknown>>(channel.encryptedConfig, cipher.decryptor);@@ -207,8 +214,6 @@ export const alertChannelServiceFactory = ({);}}-- return finalConfig;};const deleteChannelInTx = async (channelId: string, tx: Knex): Promise<void> => {diff --git a/backend/src/services/alert/alert-channel-test-service.ts b/backend/src/services/alert/alert-channel-test-service.tsindex b9b3ae4c95..02aad5aea2 100644--- a/backend/src/services/alert/alert-channel-test-service.ts+++ b/backend/src/services/alert/alert-channel-test-service.ts@@ -18,7 +18,7 @@ import { TAlertDALFactory } from "./alert-dal";import { TAlertProviderRegistry } from "./alert-provider-registry";import { TAlertRecipientResolver } from "./alert-recipient-resolver";import { TTestAlertChannelDTO, TTestAlertChannelResponse } from "./alert-service-types";-import { AlertPermissionAction, IResourceAlertProvider, TAlertContext } from "./alert-types";+import { AlertPermissionAction, IResourceAlertProvider, TAlertContext, toAlertActor } from "./alert-types";export type TAlertChannelTestServiceFactoryDep = {alertChannelDAL: Pick<TAlertChannelDALFactory, "findById">;@@ -81,12 +81,7 @@ export const alertChannelTestServiceFactory = ({orgId: owner.orgId,projectId: owner.projectId,resourceId: owner.resourceId,- actor: {- actor: dto.actor,- actorId: dto.actorId,- actorAuthMethod: dto.actorAuthMethod,- actorOrgId: dto.actorOrgId- }+ actor: toAlertActor(dto)});}};@@ -185,12 +180,7 @@ export const alertChannelTestServiceFactory = ({orgId: dto.actorOrgId,projectId,resourceId: dto.resourceId,- actor: {- actor: dto.actor,- actorId: dto.actorId,- actorAuthMethod: dto.actorAuthMethod,- actorOrgId: dto.actorOrgId- }+ actor: toAlertActor(dto)});await provider.assertResourceInScope({ orgId: dto.actorOrgId, projectId, resourceId: dto.resourceId });diff --git a/backend/src/services/alert/alert-channel-types.ts b/backend/src/services/alert/alert-channel-types.tsindex 094dcedb44..31801a2e88 100644--- a/backend/src/services/alert/alert-channel-types.ts+++ b/backend/src/services/alert/alert-channel-types.ts@@ -1,8 +1,10 @@-import RE2 from "re2";import { z } from "zod";+import { PAGERDUTY_INTEGRATION_KEY_ERROR, pagerDutyIntegrationKeyRegex } from "@app/lib/pagerduty/integration-key";import { TSmtpService } from "@app/services/smtp/smtp-service";+export const ALERT_CHANNEL_HTTP_TIMEOUT = 7 * 1000;+export enum AlertChannelType {EMAIL = "email",SLACK = "slack",@@ -99,10 +101,6 @@ export const SlackChannelConfigSchema = z.object({}, "Slack webhook URL must be from hooks.slack.com")});-export const pagerDutyIntegrationKeyRegex = new RE2("^[a-f0-9]{32}$", "i");-export const PagerDutyChannelConfigSchema = z.object({- integrationKey: z- .string()- .refine((val) => pagerDutyIntegrationKeyRegex.test(val), "Integration key must be a 32-character hex string")+ integrationKey: z.string().refine((val) => pagerDutyIntegrationKeyRegex.test(val), PAGERDUTY_INTEGRATION_KEY_ERROR)});diff --git a/backend/src/services/alert/alert-recipient-cleanup-fns.ts b/backend/src/services/alert/alert-recipient-cleanup-fns.tsnew file mode 100644index 0000000000..59d7928df8--- /dev/null+++ b/backend/src/services/alert/alert-recipient-cleanup-fns.ts@@ -0,0 +1,41 @@+import { Knex } from "knex";++import { TUserGroupMembershipDALFactory } from "@app/ee/services/group/user-group-membership-dal";++import { TAlertChannelRecipientDALFactory } from "./alert-channel-recipient-dal";+import { AlertPrincipalType } from "./alert-types";++type TDeletedGroupCleanupDeps = {+ userGroupMembershipDAL: Pick<TUserGroupMembershipDALFactory, "find">;+ alertChannelRecipientDAL: Pick<TAlertChannelRecipientDALFactory, "deleteByPrincipals" | "pruneOutOfScopeRecipients">;+};++/**+ * Reads a group's members, then hands back the cleanup to run once the group row is gone.+ *+ * The read has to happen *before* the delete, because deleting the group cascades its user+ * memberships away: a member who reached a project only through this group would otherwise still look+ * in-scope and keep its recipient rows. So callers do:+ *+ * const finalizeAlertRecipients = await prepareDeletedGroupAlertRecipientCleanup(deps, groupId, tx);+ * ...delete the group...+ * await finalizeAlertRecipients();+ *+ * The cleanup drops the group's own recipient rows (principalId carries no FK, so nothing cascades+ * them) and then prunes the members that lost their access with it.+ */+export const prepareDeletedGroupAlertRecipientCleanup = async (+ { userGroupMembershipDAL, alertChannelRecipientDAL }: TDeletedGroupCleanupDeps,+ groupId: string,+ tx: Knex+): Promise<() => Promise<void>> => {+ const memberUserIds = (await userGroupMembershipDAL.find({ groupId }, { tx })).map((m) => m.userId);++ return async () => {+ await alertChannelRecipientDAL.deleteByPrincipals(+ { principalType: AlertPrincipalType.GROUP, principalIds: [groupId] },+ tx+ );+ await alertChannelRecipientDAL.pruneOutOfScopeRecipients({ userIds: memberUserIds }, tx);+ };+};diff --git a/backend/src/services/alert/alert-service.ts b/backend/src/services/alert/alert-service.tsindex 6d280ca02b..d4da4e60f9 100644--- a/backend/src/services/alert/alert-service.ts+++ b/backend/src/services/alert/alert-service.ts@@ -21,7 +21,7 @@ import {TListAlertsDTO,TUpdateAlertDTO} from "./alert-service-types";-import { AlertPermissionAction, AlertTriggerType, IResourceAlertProvider } from "./alert-types";+import { AlertPermissionAction, AlertTriggerType, IResourceAlertProvider, toAlertActor } from "./alert-types";export type TAlertServiceFactoryDep = {alertDAL: TAlertDALFactory;@@ -53,13 +53,6 @@ export const alertServiceFactory = ({return provider;};- const $toActor = (dto: TGenericPermission): TGenericPermission => ({- actor: dto.actor,- actorId: dto.actorId,- actorAuthMethod: dto.actorAuthMethod,- actorOrgId: dto.actorOrgId- });-const $assertAlertPermission = (provider: IResourceAlertProvider,action: AlertPermissionAction,@@ -71,7 +64,7 @@ export const alertServiceFactory = ({orgId: scope.orgId,projectId: scope.projectId,resourceId: scope.resourceId,- actor: $toActor(dto)+ actor: toAlertActor(dto)});const $validate = (@@ -292,6 +285,7 @@ export const alertServiceFactory = ({await alertChannelService.updateChannelInTx({channelId: channelInput.id,+ channelType: channelInput.channelType,name: channelInput.name,config: channelInput.config,enabled: channelInput.enabled,diff --git a/backend/src/services/alert/alert-types.ts b/backend/src/services/alert/alert-types.tsindex 1466da9fcb..bfda0340e6 100644--- a/backend/src/services/alert/alert-types.ts+++ b/backend/src/services/alert/alert-types.ts@@ -34,6 +34,13 @@ export type TAlertPermissionInput = {actor: TGenericPermission;};+export const toAlertActor = (dto: TGenericPermission): TGenericPermission => ({+ actor: dto.actor,+ actorId: dto.actorId,+ actorAuthMethod: dto.actorAuthMethod,+ actorOrgId: dto.actorOrgId+});+export const DEFAULT_DEDUP_WINDOW_HOURS = 24;// Providers scan this many days ahead of `alertBefore` so alerts fire at LEAST `alertBefore` beforediff --git a/backend/src/services/alert/channels/alert-channel-email-fns.ts b/backend/src/services/alert/channels/alert-channel-email-fns.tsindex 9eeba34482..750dc65336 100644--- a/backend/src/services/alert/channels/alert-channel-email-fns.ts+++ b/backend/src/services/alert/channels/alert-channel-email-fns.ts@@ -17,6 +17,7 @@ const buildSubstitutions = (payload: TAlertPayload) => ({severity: payload.severity,viewUrl: payload.alert.viewUrl,items: payload.items.map((item) => ({+ id: item.id,title: item.title,identifier: item.identifier,fields: item.fields ?? []diff --git a/backend/src/services/alert/channels/alert-channel-pagerduty-fns.ts b/backend/src/services/alert/channels/alert-channel-pagerduty-fns.tsindex 1743eeb5ae..17e14e79d8 100644--- a/backend/src/services/alert/channels/alert-channel-pagerduty-fns.ts+++ b/backend/src/services/alert/channels/alert-channel-pagerduty-fns.ts@@ -4,8 +4,8 @@ import { logger } from "@app/lib/logger";import { safeRequest } from "@app/lib/validator";import {+ ALERT_CHANNEL_HTTP_TIMEOUT,PagerDutyChannelConfigSchema,- pagerDutyIntegrationKeyRegex,TAlertChannelSendContext,TAlertItem,TAlertPayload,@@ -13,7 +13,6 @@ import {} from "../alert-channel-types";const PAGERDUTY_EVENTS_URL = "https://events.pagerduty.com/v2/enqueue";-const PAGERDUTY_TIMEOUT = 7 * 1000;export const PAGERDUTY_MAX_INCIDENTS_PER_RUN = 10;const PAGERDUTY_SUMMARY_MAX_LENGTH = 1024;@@ -72,18 +71,14 @@ export const buildPagerDutyEvent = (const triggerPagerDutyEvent = async (payload: TPagerDutyPayload): Promise<void> => {await safeRequest.post(PAGERDUTY_EVENTS_URL, payload, {headers: { "Content-Type": "application/json" },- timeout: PAGERDUTY_TIMEOUT,- signal: AbortSignal.timeout(PAGERDUTY_TIMEOUT)+ timeout: ALERT_CHANNEL_HTTP_TIMEOUT,+ signal: AbortSignal.timeout(ALERT_CHANNEL_HTTP_TIMEOUT)});};export const sendPagerDutyNotification = async (ctx: TAlertChannelSendContext): Promise<TChannelResult> => {const config = PagerDutyChannelConfigSchema.parse(ctx.config);- if (!pagerDutyIntegrationKeyRegex.test(config.integrationKey)) {- return { success: false, error: "Invalid PagerDuty integration key" };- }-const targetResults = await Promise.all(ctx.payload.items.map(async (item) => {try {diff --git a/backend/src/services/alert/channels/alert-channel-slack-fns.ts b/backend/src/services/alert/channels/alert-channel-slack-fns.tsindex 493d3d8444..6d306c2d5b 100644--- a/backend/src/services/alert/channels/alert-channel-slack-fns.ts+++ b/backend/src/services/alert/channels/alert-channel-slack-fns.ts@@ -1,7 +1,8 @@-import { SLACK_WEBHOOK_TIMEOUT, TSlackBlock, TSlackPayload } from "@app/lib/slack/slack-webhook";+import { TSlackBlock, TSlackPayload } from "@app/lib/slack/slack-webhook";import { safeRequest } from "@app/lib/validator";import {+ ALERT_CHANNEL_HTTP_TIMEOUT,SlackChannelConfigSchema,TAlertChannelSendContext,TAlertPayload,@@ -78,8 +79,8 @@ export const buildSlackPayload = (payload: TAlertPayload): TSlackPayload => {const triggerSlackWebhook = async (url: string, payload: TSlackPayload): Promise<void> => {await safeRequest.post(url, payload, {headers: { "Content-Type": "application/json" },- timeout: SLACK_WEBHOOK_TIMEOUT,- signal: AbortSignal.timeout(SLACK_WEBHOOK_TIMEOUT)+ timeout: ALERT_CHANNEL_HTTP_TIMEOUT,+ signal: AbortSignal.timeout(ALERT_CHANNEL_HTTP_TIMEOUT)});};diff --git a/backend/src/services/alert/channels/alert-channel-webhook-fns.ts b/backend/src/services/alert/channels/alert-channel-webhook-fns.tsindex 96aea50e48..facb39e48a 100644--- a/backend/src/services/alert/channels/alert-channel-webhook-fns.ts+++ b/backend/src/services/alert/channels/alert-channel-webhook-fns.ts@@ -3,14 +3,13 @@ import crypto from "node:crypto";import { safeRequest } from "@app/lib/validator";import {+ ALERT_CHANNEL_HTTP_TIMEOUT,TAlertChannelSendContext,TAlertPayload,TChannelResult,WebhookChannelConfigSchema} from "../alert-channel-types";-const ALERT_WEBHOOK_TIMEOUT = 7 * 1000;-type TAlertWebhookPayload = {specversion: "1.0";type: string;@@ -71,8 +70,8 @@ const triggerWebhook = async (params: {await safeRequest.post(url, payload, {headers,- timeout: ALERT_WEBHOOK_TIMEOUT,- signal: AbortSignal.timeout(ALERT_WEBHOOK_TIMEOUT)+ timeout: ALERT_CHANNEL_HTTP_TIMEOUT,+ signal: AbortSignal.timeout(ALERT_CHANNEL_HTTP_TIMEOUT)});};diff --git a/backend/src/services/alert/providers/identity-credential-alert-provider.ts b/backend/src/services/alert/providers/identity-credential-alert-provider.tsindex 817930c484..2daa451711 100644--- a/backend/src/services/alert/providers/identity-credential-alert-provider.ts+++ b/backend/src/services/alert/providers/identity-credential-alert-provider.ts@@ -91,6 +91,8 @@ export type TIdentityCredentialAlertProviderDep = {permissionService: Pick<TPermissionServiceFactory, "getOrgPermission" | "getProjectPermission">;};+const targetId = (target: TIdentityCredentialTarget): string => `${target.credentialType}:${target.id}`;+export const identityCredentialAlertProviderFactory = ({identityCredentialAlertDAL,permissionService@@ -168,7 +170,7 @@ export const identityCredentialAlertProviderFactory = ({? `${targets.length} machine identity authentication(s) expiring within ${humanizeAlertBefore(alertBefore)}`: `${targets.length} machine identity authentication(s) expiring`,items: targets.map((target) => ({- id: `${target.credentialType}:${target.id}`,+ id: targetId(target),title: target.identityName,fields: [{ label: "Secret Name", value: target.description || target.clientSecretPrefix },@@ -179,8 +181,6 @@ export const identityCredentialAlertProviderFactory = ({};};- const targetId = (target: TIdentityCredentialTarget): string => `${target.credentialType}:${target.id}`;-const buildTestTargets = (): TIdentityCredentialTarget[] => [{credentialType: "ua-client-secret",diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-pagerduty-fns.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-pagerduty-fns.tsindex ba59106498..2f1373dd59 100644--- a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-pagerduty-fns.ts+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-pagerduty-fns.ts@@ -4,12 +4,12 @@ import { getConfig } from "@app/lib/config/env";import { request } from "@app/lib/config/request";import { delay } from "@app/lib/delay";import { logger } from "@app/lib/logger";+import { pagerDutyIntegrationKeyRegex } from "@app/lib/pagerduty/integration-key";import { RETRYABLE_NETWORK_ERRORS } from "@app/lib/retry/network-errors";import { PKI_ALERT_RETRY_CONFIG } from "./pki-alert-v2-constants";import {getRevocationReasonLabel,- pagerDutyIntegrationKeyRegex,PkiAlertEventType,TAlertInfo,TBuildPagerDutyPayloadParams,diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-types.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-types.tsindex 6530cef619..da50962342 100644--- a/backend/src/services/pki-alert-v2/pki-alert-v2-types.ts+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-types.ts@@ -1,6 +1,7 @@import RE2 from "re2";import { z } from "zod";+import { PAGERDUTY_INTEGRATION_KEY_ERROR, pagerDutyIntegrationKeyRegex } from "@app/lib/pagerduty/integration-key";import { TGenericPermission } from "@app/lib/types";const createSecureNameValidator = () => {@@ -177,12 +178,8 @@ export const SlackChannelConfigSchema = z.object({}, "Slack webhook URL must be from hooks.slack.com")});-export const pagerDutyIntegrationKeyRegex = new RE2("^[a-f0-9]{32}$", "i");-export const PagerDutyChannelConfigSchema = z.object({- integrationKey: z- .string()- .refine((val) => pagerDutyIntegrationKeyRegex.test(val), "Integration key must be a 32-character hex string")+ integrationKey: z.string().refine((val) => pagerDutyIntegrationKeyRegex.test(val), PAGERDUTY_INTEGRATION_KEY_ERROR)});export type TPagerDutyChannelConfig = z.infer<typeof PagerDutyChannelConfigSchema>;diff --git a/backend/src/services/smtp/emails/AlertNotificationTemplate.tsx b/backend/src/services/smtp/emails/AlertNotificationTemplate.tsxindex ab16bc20e7..ee2af6f067 100644--- a/backend/src/services/smtp/emails/AlertNotificationTemplate.tsx+++ b/backend/src/services/smtp/emails/AlertNotificationTemplate.tsx@@ -11,7 +11,7 @@ interface AlertNotificationTemplateProps extends Omit<BaseEmailWrapperProps, "tisummary: string;severity?: string;viewUrl: string;- items: { title: string; identifier?: string; fields?: { label: string; value: string }[] }[];+ items: { id: string; title: string; identifier?: string; fields?: { label: string; value: string }[] }[];}const SEVERITY_STYLES: Record<string, { label: string; color: string; background: string; border: string }> = {@@ -68,7 +68,7 @@ export const AlertNotificationTemplate = ({<Section className="mt-[28px] mb-[8px]">{items.map((item) => (<Section- key={item.identifier ?? item.title}+ key={item.id}className="mb-[12px] px-[20px] pt-[16px] pb-[8px] border border-solid border-gray-200 rounded-lg bg-gray-50"><Text className="text-[15px] font-semibold text-black m-0 mb-[2px]">{item.title}</Text>@@ -121,6 +121,7 @@ AlertNotificationTemplate.PreviewProps = {siteUrl: "https://infisical.com",items: [{+ id: "ua-client-secret:1f0c3a5e-1111-4c2a-9f10-8b7d6e5a4c31",title: "ci-runner",fields: [{ label: "Secret Name", value: "ci-secret" },@@ -129,6 +130,7 @@ AlertNotificationTemplate.PreviewProps = {]},{+ id: "ua-client-secret:2b9d4f7c-2222-4e83-b6a1-5c4e3d2b1a09",title: "deploy-bot",fields: [{ label: "Secret Name", value: "release-token" },diff --git a/frontend/src/views/Alerts/ChannelCard.tsx b/frontend/src/views/Alerts/ChannelCard.tsxindex 4400c6f979..80e144a14e 100644--- a/frontend/src/views/Alerts/ChannelCard.tsx+++ b/frontend/src/views/Alerts/ChannelCard.tsx@@ -102,9 +102,7 @@ export const ChannelCard = ({<div className="flex items-center justify-between"><div className="flex items-center gap-2"><Icon className="size-4 text-muted" />- <span className="text-sm font-medium text-foreground">- {ALERT_CHANNEL_TYPE_LABELS[channelType]}- </span>+ <span className="text-sm font-medium text-foreground">{channelLabel}</span></div><div className="flex items-center gap-3"><Buttondiff --git a/frontend/src/views/Alerts/ChannelRecipientsField.tsx b/frontend/src/views/Alerts/ChannelRecipientsField.tsxindex 5fae5bc9ee..cedae77436 100644--- a/frontend/src/views/Alerts/ChannelRecipientsField.tsx+++ b/frontend/src/views/Alerts/ChannelRecipientsField.tsx@@ -18,15 +18,8 @@ type RecipientOption = {groupLabel: "Users" | "Groups";};-const userLabel = (user: {- firstName?: string;- lastName?: string;- username?: string;- email?: string;-}): string => {- const name = `${user.firstName ?? ""} ${user.lastName ?? ""}`.trim();- return user.email || user.username || name || "Unknown user";-};+const userLabel = (user: { firstName?: string; lastName?: string; username?: string }): string =>+ user.username || `${user.firstName ?? ""} ${user.lastName ?? ""}`.trim() || "Unknown user";const buildOptions = (users: { user: { id: string; firstName?: string; lastName?: string; username?: string } }[],