Skip to content

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

Address greptile comments

Carlos Monastyrski39d55be04c65
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index fcc49605eb..f349963e02 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -7840,7 +7840,9 @@ interface TestPkiApplicationAlertEvent {
type: EventType.TEST_PKI_APPLICATION_ALERT_CHANNEL;
metadata: TPkiApplicationAlertEventMetadata & {
alertId?: string;
+ alertName?: string | null;
channelId?: string;
+ channelName?: string | null;
channelType: string;
success: boolean;
deliveredTo?: number;
diff --git a/backend/src/server/routes/v1/alert-router.ts b/backend/src/server/routes/v1/alert-router.ts
index 7fb9b286e7..b71e006191 100644
--- a/backend/src/server/routes/v1/alert-router.ts
+++ b/backend/src/server/routes/v1/alert-router.ts
@@ -150,13 +150,14 @@ export const registerAlertRouter = async (server: FastifyZodProvider) => {
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),
handler: async (req) => {
- const { projectId, resourceName, ...result } = await server.services.alertChannelTest.testChannel({
- ...req.body,
- actor: req.permission.type,
- actorId: req.permission.id,
- actorAuthMethod: req.permission.authMethod,
- actorOrgId: req.permission.orgId
- });
+ const { projectId, resourceName, alertName, channelName, ...result } =
+ await server.services.alertChannelTest.testChannel({
+ ...req.body,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
+ });
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
@@ -168,7 +169,9 @@ export const registerAlertRouter = async (server: FastifyZodProvider) => {
resourceId: req.body.resourceId,
resourceName,
alertId: req.body.alertId,
+ alertName,
channelId: req.body.channelId,
+ channelName,
channelType: req.body.channelType,
success: result.success,
deliveredTo: result.deliveredTo,
diff --git a/backend/src/services/alert/alert-channel-test-service.test.ts b/backend/src/services/alert/alert-channel-test-service.test.ts
index 7c2995eea1..6ee09d0c66 100644
--- a/backend/src/services/alert/alert-channel-test-service.test.ts
+++ b/backend/src/services/alert/alert-channel-test-service.test.ts
@@ -202,7 +202,14 @@ describe("alertChannelTestService", () => {
config: { webhookUrl: "https://hooks.slack.com/services/T/B/x" }
});
- expect(result).toEqual({ success: true, deliveredTo: 1, projectId: null, resourceName: null });
+ expect(result).toEqual({
+ success: true,
+ deliveredTo: 1,
+ projectId: null,
+ resourceName: null,
+ alertName: null,
+ channelName: null
+ });
expect(sent).toHaveLength(1);
expect(sent[0].config).toEqual({ webhookUrl: "https://hooks.slack.com/services/T/B/x" });
// A test must never page an on-call rotation at the severity a real firing would carry.
@@ -462,7 +469,9 @@ describe("alertChannelTestService", () => {
success: true,
deliveredTo: 1,
projectId: null,
- resourceName: null
+ resourceName: null,
+ alertName: null,
+ channelName: null
});
await expect(service.testChannel(dto)).rejects.toThrow(/Try again in 60s/);
} finally {
@@ -493,7 +502,14 @@ describe("alertChannelTestService", () => {
config: {},
recipients: [{ principalType: "user" as never, principalId: "user-1" }]
})
- ).resolves.toEqual({ success: true, deliveredTo: 1, projectId: null, resourceName: null });
+ ).resolves.toEqual({
+ success: true,
+ deliveredTo: 1,
+ projectId: null,
+ resourceName: null,
+ alertName: null,
+ channelName: null
+ });
} finally {
restoreSlack();
restoreEmail();
@@ -516,7 +532,14 @@ describe("alertChannelTestService", () => {
config: { webhookUrl: "https://hooks.slack.com/services/T/B/x" }
});
- expect(result).toEqual({ success: false, error: "connect ECONNREFUSED", projectId: null, resourceName: null });
+ expect(result).toEqual({
+ success: false,
+ error: "connect ECONNREFUSED",
+ projectId: null,
+ resourceName: null,
+ alertName: null,
+ channelName: null
+ });
} finally {
restore();
}
diff --git a/backend/src/services/alert/alert-channel-test-service.ts b/backend/src/services/alert/alert-channel-test-service.ts
index 130508b043..bd558fd5c5 100644
--- a/backend/src/services/alert/alert-channel-test-service.ts
+++ b/backend/src/services/alert/alert-channel-test-service.ts
@@ -216,6 +216,7 @@ export const alertChannelTestServiceFactory = ({
resourceId: dto.resourceId
});
+ let alertName: string | null = null;
if (dto.alertId) {
const alert = await alertDAL.findActiveById(dto.alertId);
if (
@@ -227,6 +228,7 @@ export const alertChannelTestServiceFactory = ({
) {
throw new NotFoundError({ message: `Alert with ID '${dto.alertId}' was not found in this scope` });
}
+ alertName = alert.name;
}
await provider.assertPermission({
@@ -246,7 +248,9 @@ export const alertChannelTestServiceFactory = ({
return {
...result,
projectId,
- resourceName: await getAlertResourceName(provider, dto.actorOrgId, dto.resourceId)
+ resourceName: await getAlertResourceName(provider, dto.actorOrgId, dto.resourceId),
+ alertName,
+ channelName: dto.channelId ? ((await alertChannelDAL.findById(dto.channelId))?.name ?? null) : null
};
};
diff --git a/backend/src/services/alert/alert-service-types.ts b/backend/src/services/alert/alert-service-types.ts
index 356bad1900..ece666da33 100644
--- a/backend/src/services/alert/alert-service-types.ts
+++ b/backend/src/services/alert/alert-service-types.ts
@@ -57,7 +57,9 @@ export type TTestAlertChannelResponse = {
export type TTestAlertChannelResult = TTestAlertChannelResponse & {
projectId: string | null;
- resourceName?: string | null;
+ resourceName: string | null;
+ alertName: string | null;
+ channelName: string | null;
};
export type TAlertResponse = {
diff --git a/backend/src/services/alert/alert-types.ts b/backend/src/services/alert/alert-types.ts
index a3ea31facb..0703d545f7 100644
--- a/backend/src/services/alert/alert-types.ts
+++ b/backend/src/services/alert/alert-types.ts
@@ -160,7 +160,9 @@ type TAlertChannelTestAudit = {
resourceId?: string | null;
resourceName?: string | null;
alertId?: string;
+ alertName?: string | null;
channelId?: string;
+ channelName?: string | null;
channelType: string;
success: boolean;
deliveredTo?: number;
diff --git a/backend/src/services/alert/providers/cert-manager-application-alert-provider.test.ts b/backend/src/services/alert/providers/cert-manager-application-alert-provider.test.ts
index fbe71bf42b..c0ace4082e 100644
--- a/backend/src/services/alert/providers/cert-manager-application-alert-provider.test.ts
+++ b/backend/src/services/alert/providers/cert-manager-application-alert-provider.test.ts
@@ -284,6 +284,9 @@ describe("cert manager application alert provider", () => {
resourceId: "app-1",
resourceName: "payments-api",
alertId: "alert-1",
+ alertName: "tls-expiry",
+ channelId: "channel-1",
+ channelName: "Email",
channelType: "email",
success: true,
deliveredTo: 1
@@ -295,7 +298,9 @@ describe("cert manager application alert provider", () => {
applicationId: "app-1",
applicationName: "payments-api",
alertId: "alert-1",
- channelId: undefined,
+ alertName: "tls-expiry",
+ channelId: "channel-1",
+ channelName: "Email",
channelType: "email",
success: true,
deliveredTo: 1,
diff --git a/backend/src/services/alert/providers/cert-manager-application-alert-provider.ts b/backend/src/services/alert/providers/cert-manager-application-alert-provider.ts
index 651813f9e5..bf5241425d 100644
--- a/backend/src/services/alert/providers/cert-manager-application-alert-provider.ts
+++ b/backend/src/services/alert/providers/cert-manager-application-alert-provider.ts
@@ -204,7 +204,9 @@ export const certManagerApplicationAlertProviderFactory = ({
applicationId: test.resourceId ?? null,
applicationName: test.resourceName ?? null,
alertId: test.alertId,
+ alertName: test.alertName ?? null,
channelId: test.channelId,
+ channelName: test.channelName ?? null,
channelType: test.channelType,
success: test.success,
deliveredTo: test.deliveredTo,