Skip to content

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

Address greptile comments

Carlos Monastyrski9087b853d926
diff --git a/backend/src/queue/queue-service.ts b/backend/src/queue/queue-service.ts
index f4e629e41f..bef9129f7f 100644
--- a/backend/src/queue/queue-service.ts
+++ b/backend/src/queue/queue-service.ts
@@ -1,6 +1,7 @@
import { Job, JobSchedulerJson, Queue, QueueOptions, RepeatOptions, Worker, WorkerListener } from "bullmq";
import { SecretEncryptionAlgo, SecretKeyEncoding, TQueueJobs } from "@app/db/schemas";
+import { PkiAlertEventType } from "@app/services/pki-alert-v2/pki-alert-v2-types";
import { TCreateAuditLogDTO } from "@app/ee/services/audit-log/audit-log-types";
import { PamDiscoverySourceRunTrigger } from "@app/ee/services/pam-discovery/pam-discovery-enums";
import {
@@ -260,7 +261,7 @@ export type TQueueJobTypes = {
payload: {
certificateId: string;
projectId: string;
- eventType: string;
+ eventType: PkiAlertEventType;
};
};
[QueueName.PkiSyncCleanup]: {
diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-queue.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-queue.ts
index e7948a95d0..3d7d64e0f6 100644
--- a/backend/src/services/pki-alert-v2/pki-alert-v2-queue.ts
+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-queue.ts
@@ -194,7 +194,11 @@ export const pkiAlertV2QueueServiceFactory = ({
);
};
- const processEventAlert = async (payload: { certificateId: string; projectId: string; eventType: string }) => {
+ const processEventAlert = async (payload: {
+ certificateId: string;
+ projectId: string;
+ eventType: PkiAlertEventType;
+ }) => {
const { certificateId, projectId, eventType } = payload;
const alerts = await pkiAlertV2DAL.findByProjectId(projectId, {
@@ -206,12 +210,16 @@ export const pkiAlertV2QueueServiceFactory = ({
for (const alert of alerts) {
try {
- await pkiAlertV2Service.sendEventNotifications(alert.id, [certificateId], eventType as PkiAlertEventType);
+ await pkiAlertV2Service.sendEventNotifications(alert.id, [certificateId], eventType);
logger.info(
- `Sent ${eventType} notification for alert ${alert.id} (${alert.name}) for certificate ${certificateId}`
+ { alertId: alert.id, alertName: alert.name, certificateId, eventType },
+ "Sent PKI event notification"
);
} catch (error) {
- logger.error(error, `Failed to process ${eventType} alert ${alert.id} for certificate ${certificateId}`);
+ logger.error(
+ { alertId: alert.id, certificateId, eventType, error },
+ "Failed to process PKI event alert"
+ );
}
}
};
diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-service.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-service.ts
index afa84e9377..7b80e2464f 100644
--- a/backend/src/services/pki-alert-v2/pki-alert-v2-service.ts
+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-service.ts
@@ -799,15 +799,19 @@ export const pkiAlertV2ServiceFactory = ({
const filters = (alert.filters ?? []) as TPkiFilterRule[];
- const matchingCertificates: TCertificatePreview[] = [];
+ const allCertificates: TCertificatePreview[] = [];
for (const certId of certificateIds) {
// eslint-disable-next-line no-await-in-loop
const { certificates } = await pkiAlertV2DAL.findMatchingCertificates(projectId, filters, {
certificateId: certId
});
- matchingCertificates.push(...certificates);
+ allCertificates.push(...certificates);
}
+ const matchingCertificates = allCertificates.filter(
+ (cert) => cert.enrollmentType !== CertificateOrigin.CA
+ );
+
if (matchingCertificates.length === 0) return;
await dispatchToChannels({