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
feat(ui): add alerts for audit log stream delivery failures
Calvin56aab3a9c727
diff --git a/frontend/src/hooks/api/alerts/types.ts b/frontend/src/hooks/api/alerts/types.tsindex 67fbbcde5c..e7c403748d 100644--- a/frontend/src/hooks/api/alerts/types.ts+++ b/frontend/src/hooks/api/alerts/types.ts@@ -4,12 +4,14 @@ import { CertSource } from "@app/hooks/api/certificates/enums";export enum AlertResourceType {IdentityAuthentication = "identity.authentication",- SecretReminder = "secret.reminder"+ SecretReminder = "secret.reminder",+ AuditLogStream = "audit-log.stream"}export enum AlertEventType {IdentityAuthenticationExpiry = "identity.authentication.expiry",- IdentityAuthMethodChanged = "identity.authentication.auth-method-changed"+ IdentityAuthMethodChanged = "identity.authentication.auth-method-changed",+ AuditLogStreamDeliveryFailed = "audit-log.stream.delivery-failed"}export enum AlertChannelType {@@ -67,19 +69,33 @@ export const MAX_CERTIFICATE_ALERT_FILTER_IDS = 100;export const ALERT_RESOURCE_TYPE_LABELS: Record<AlertResourceType, string> = {[AlertResourceType.IdentityAuthentication]: "Machine Identity Authentication",- [AlertResourceType.SecretReminder]: "Secret Reminder"+ [AlertResourceType.SecretReminder]: "Secret Reminder",+ [AlertResourceType.AuditLogStream]: "Audit Log Stream"+};++// Secret reminders have their own form, so they list no events here.+export const ALERT_RESOURCE_EVENT_TYPES: Record<AlertResourceType, AlertEventType[]> = {+ [AlertResourceType.IdentityAuthentication]: [+ AlertEventType.IdentityAuthenticationExpiry,+ AlertEventType.IdentityAuthMethodChanged+ ],+ [AlertResourceType.SecretReminder]: [],+ [AlertResourceType.AuditLogStream]: [AlertEventType.AuditLogStreamDeliveryFailed]};export const ALERT_EVENT_TYPE_LABELS: Record<AlertEventType, string> = {[AlertEventType.IdentityAuthenticationExpiry]: "Credential Expiration",- [AlertEventType.IdentityAuthMethodChanged]: "Auth Method Change"+ [AlertEventType.IdentityAuthMethodChanged]: "Auth Method Change",+ [AlertEventType.AuditLogStreamDeliveryFailed]: "Delivery Failure"};export const ALERT_EVENT_TYPE_DESCRIPTIONS: Record<AlertEventType, string> = {[AlertEventType.IdentityAuthenticationExpiry]:"Notify a set number of days before a Universal Auth client secret or Token Auth access token expires.",[AlertEventType.IdentityAuthMethodChanged]:- "Notify whenever an auth method is added, updated, or removed, or one of its credentials is created, updated, or revoked."+ "Notify whenever an auth method is added, updated, or removed, or one of its credentials is created, updated, or revoked.",+ [AlertEventType.AuditLogStreamDeliveryFailed]:+ "Notify when an external log stream cannot be reached and audit log events are being dropped."};export const ALERT_CHANNEL_TYPE_LABELS: Record<AlertChannelType, string> = {diff --git a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsxindex 01f5465f7e..bf3cb50dbf 100644--- a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx+++ b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx@@ -9,6 +9,8 @@ import { withPermission } from "@app/hoc";import { useScopeVariant } from "@app/hooks";import { useGetOrgAuditLogSettings, useUpdateOrgAuditLogSettings } from "@app/hooks/api";+import { AuditLogStreamAlertsCard } from "./AuditLogStreamAlertsCard";+export const AuditLogSettingsTab = withPermission(() => {const { currentOrg } = useOrganization();@@ -25,19 +27,22 @@ export const AuditLogSettingsTab = withPermission();return (- <AuditLogEventClassesForm- title="Event Classes"- description="Choose which classes of organization-level events are recorded. Each project has its own setting for its events."- settings={settings}- isPending={isPending}- isError={isError}- isSaving={isSaving}- canEdit={canEdit}- readOnlyMessage="You need the Edit permission on Audit Logs to change these settings."- variant={scopeVariant}- paywallKey="organization.audit-log-settings"- onSave={(eventClasses) => updateSettings({ eventClasses })}- />+ <div className="flex flex-col gap-y-5">+ <AuditLogEventClassesForm+ title="Event Classes"+ description="Choose which classes of organization-level events are recorded. Each project has its own setting for its events."+ settings={settings}+ isPending={isPending}+ isError={isError}+ isSaving={isSaving}+ canEdit={canEdit}+ readOnlyMessage="You need the Edit permission on Audit Logs to change these settings."+ variant={scopeVariant}+ paywallKey="organization.audit-log-settings"+ onSave={(eventClasses) => updateSettings({ eventClasses })}+ />+ <AuditLogStreamAlertsCard />+ </div>);},{diff --git a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogStreamAlertsCard.tsx b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogStreamAlertsCard.tsxnew file mode 100644index 0000000000..1a85f2adff--- /dev/null+++ b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogStreamAlertsCard.tsx@@ -0,0 +1,27 @@+import { OrgPermissionCan } from "@app/components/permissions";+import { Card, CardAction, CardDescription, CardHeader, CardTitle } from "@app/components/v3";+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";+import { AlertResourceType } from "@app/hooks/api/alerts";+import { AlertAction } from "@app/views/Alerts";++export const AuditLogStreamAlertsCard = () => (+ <Card>+ <CardHeader>+ <CardTitle>Log Stream Alerts</CardTitle>+ <CardDescription>+ Get notified when an external log stream cannot be reached and audit log events are being+ dropped.+ </CardDescription>+ <CardAction>+ <AlertAction+ resourceType={AlertResourceType.AuditLogStream}+ renderPermissionGate={(render) => (+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Settings}>+ {render}+ </OrgPermissionCan>+ )}+ />+ </CardAction>+ </CardHeader>+ </Card>+);diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertAction.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertAction.tsxindex 660cffc634..1729ffe389 100644--- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertAction.tsx+++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertAction.tsx@@ -1,5 +1,6 @@import { OrgPermissionCan } from "@app/components/permissions";import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/context";+import { AlertResourceType } from "@app/hooks/api/alerts";import { AlertAction } from "@app/views/Alerts";type Props = {@@ -8,7 +9,8 @@ type Props = {export const IdentityAlertAction = ({ identityId }: Props) => (<AlertAction- identityId={identityId}+ resourceType={AlertResourceType.IdentityAuthentication}+ resourceId={identityId}renderPermissionGate={(render) => (<OrgPermissionCan I={OrgPermissionIdentityActions.Edit} a={OrgPermissionSubjects.Identity}>{render}diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAlertAction.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAlertAction.tsxindex 99414e8de7..ab2996cb68 100644--- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAlertAction.tsx+++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAlertAction.tsx@@ -2,6 +2,7 @@ import { subject } from "@casl/ability";import { ProjectPermissionCan } from "@app/components/permissions";import { ProjectPermissionIdentityActions, ProjectPermissionSub } from "@app/context";+import { AlertResourceType } from "@app/hooks/api/alerts";import { AlertAction } from "@app/views/Alerts";type Props = {@@ -12,7 +13,8 @@ type Props = {export const ProjectIdentityAlertAction = ({ identityId, projectId, readOnly = false }: Props) => (<AlertAction- identityId={identityId}+ resourceType={AlertResourceType.IdentityAuthentication}+ resourceId={identityId}projectId={projectId}readOnly={readOnly}renderPermissionGate={(render) => (diff --git a/frontend/src/views/Alerts/AddAlertModal.tsx b/frontend/src/views/Alerts/AddAlertModal.tsxindex 52ccfa829c..3db1669af4 100644--- a/frontend/src/views/Alerts/AddAlertModal.tsx+++ b/frontend/src/views/Alerts/AddAlertModal.tsx@@ -1,11 +1,12 @@import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@app/components/v3";-import { AlertEventType, TAlert } from "@app/hooks/api/alerts";+import { AlertEventType, AlertResourceType, TAlert } from "@app/hooks/api/alerts";import { AlertForm } from "./AlertForm";type Props = {isOpen: boolean;onOpenChange: (isOpen: boolean) => void;+ resourceType: AlertResourceType;projectId?: string;resourceId?: string;alert?: TAlert;@@ -15,6 +16,7 @@ type Props = {export const AddAlertModal = ({isOpen,onOpenChange,+ resourceType,projectId,resourceId,alert,@@ -34,6 +36,7 @@ export const AddAlertModal = ({{isOpen && (<AlertFormkey={alert?.id ?? "new"}+ resourceType={resourceType}projectId={projectId}resourceId={resourceId}alert={alert}diff --git a/frontend/src/views/Alerts/AlertAction.tsx b/frontend/src/views/Alerts/AlertAction.tsxindex 6da605aebb..09bc62f86a 100644--- a/frontend/src/views/Alerts/AlertAction.tsx+++ b/frontend/src/views/Alerts/AlertAction.tsx@@ -31,6 +31,7 @@ import { usePopUp, useScopeVariant } from "@app/hooks";import {ALERT_CHANNEL_TYPE_LABELS,ALERT_EVENT_TYPE_LABELS,+ ALERT_RESOURCE_EVENT_TYPES,AlertChannelType,AlertEventType,AlertResourceType,@@ -44,7 +45,9 @@ import { AddAlertModal } from "./AddAlertModal";import { getChannelIcon } from "./channelIcons";type Props = {- identityId: string;+ resourceType: AlertResourceType;+ // Alerts that watch every resource of the type in scope when omitted.+ resourceId?: string;// Org-scoped when omitted.projectId?: string;// Renders the alerts without any way to create, edit or remove them.@@ -60,14 +63,15 @@ const getEnabledChannelTypes = (alert: TAlert): AlertChannelType[] =>);export const AlertAction = ({- identityId,+ resourceType,+ resourceId,projectId,readOnly = false,renderPermissionGate}: Props) => {const { data: alerts = [] } = useListAlerts({- resourceType: AlertResourceType.IdentityAuthentication,- resourceId: identityId,+ resourceType,+ ...(resourceId ? { resourceId } : {}),...(projectId ? { projectId } : {})});@@ -81,7 +85,7 @@ export const AlertAction = ({const enabledCount = alerts.filter((alert) => alert.enabled).length;const usedEventTypes = alerts.map((alert) => alert.eventType as AlertEventType);- const canAddAlert = Object.values(AlertEventType).some(+ const canAddAlert = ALERT_RESOURCE_EVENT_TYPES[resourceType].some((eventType) => !usedEventTypes.includes(eventType));@@ -257,8 +261,9 @@ export const AlertAction = ({<AddAlertModalisOpen={popUp.alert.isOpen}onOpenChange={(isOpen) => handlePopUpToggle("alert", isOpen)}+ resourceType={resourceType}projectId={projectId}- resourceId={identityId}+ resourceId={resourceId}alert={selectedAlert}unavailableEventTypes={usedEventTypes}/>diff --git a/frontend/src/views/Alerts/AlertForm.tsx b/frontend/src/views/Alerts/AlertForm.tsxindex b27386e787..659464041d 100644--- a/frontend/src/views/Alerts/AlertForm.tsx+++ b/frontend/src/views/Alerts/AlertForm.tsx@@ -1,6 +1,5 @@import { Controller, FormProvider, useForm, useWatch } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";-import { KeyRoundIcon } from "lucide-react";import { createNotification } from "@app/components/notifications";import {@@ -26,7 +25,7 @@ import { useScopeVariant } from "@app/hooks";import {ALERT_EVENT_TYPE_DESCRIPTIONS,ALERT_EVENT_TYPE_LABELS,- ALERT_RESOURCE_TYPE_LABELS,+ ALERT_RESOURCE_EVENT_TYPES,AlertEventType,alertFormSchema,AlertResourceType,@@ -45,6 +44,7 @@ import {import { ChannelsField } from "./ChannelsField";type Props = {+ resourceType: AlertResourceType;projectId?: string;resourceId?: string;alert?: TAlert;@@ -56,16 +56,18 @@ type Props = {const DEFAULT_ALERT_BEFORE_DAYS = 7;const DEFAULT_ALERT_NAMES: Record<AlertEventType, string> = {[AlertEventType.IdentityAuthenticationExpiry]: "Credential expiration alert",- [AlertEventType.IdentityAuthMethodChanged]: "Auth method change alert"+ [AlertEventType.IdentityAuthMethodChanged]: "Auth method change alert",+ [AlertEventType.AuditLogStreamDeliveryFailed]: "Stream delivery failure alert"};const AGENT_VAULT_ALERT_NAME_PLACEHOLDERS: Record<AlertEventType, string> = {[AlertEventType.IdentityAuthenticationExpiry]: "Credential expiration alert",- [AlertEventType.IdentityAuthMethodChanged]: "Auth method change alert"+ [AlertEventType.IdentityAuthMethodChanged]: "Auth method change alert",+ [AlertEventType.AuditLogStreamDeliveryFailed]: "Stream delivery failure alert"};-const DEFAULT_EVENT_TYPE = AlertEventType.IdentityAuthenticationExpiry;const buildFormDefaults = (alert: TAlert | undefined,+ resourceType: AlertResourceType,defaultEventType: AlertEventType,defaultName: string): TAlertForm => {@@ -73,7 +75,7 @@ const buildFormDefaults = (return {name: defaultName,description: "",- resourceType: AlertResourceType.IdentityAuthentication,+ resourceType,eventType: defaultEventType,alertBeforeDays: DEFAULT_ALERT_BEFORE_DAYS,dailyReminder: false,@@ -85,9 +87,8 @@ const buildFormDefaults = (return {name: alert.name,description: alert.description ?? "",- resourceType:- (alert.resourceType as AlertResourceType) ?? AlertResourceType.IdentityAuthentication,- eventType: (alert.eventType as AlertEventType) ?? DEFAULT_EVENT_TYPE,+ resourceType,+ eventType: alert.eventType as AlertEventType,alertBeforeDays:parseAlertBeforeDays(alert.condition?.alertBefore) ?? DEFAULT_ALERT_BEFORE_DAYS,dailyReminder: alert.condition?.dailyReminder ?? false,@@ -97,6 +98,7 @@ const buildFormDefaults = (};export const AlertForm = ({+ resourceType,projectId,resourceId,alert,@@ -109,14 +111,15 @@ export const AlertForm = ({const isAgentVault = scopeVariant === "av";const createAlert = useCreateAlert();const updateAlert = useUpdateAlert();+ const eventTypes = ALERT_RESOURCE_EVENT_TYPES[resourceType];const defaultEventType =- Object.values(AlertEventType).find((eventType) => !unavailableEventTypes.includes(eventType)) ??- DEFAULT_EVENT_TYPE;+ eventTypes.find((eventType) => !unavailableEventTypes.includes(eventType)) ?? eventTypes[0];const formMethods = useForm<TAlertForm>({resolver: zodResolver(alertFormSchema),defaultValues: buildFormDefaults(alert,+ resourceType,defaultEventType,isAgentVault ? "" : DEFAULT_ALERT_NAMES[defaultEventType])@@ -131,13 +134,11 @@ export const AlertForm = ({formState: { errors, isSubmitting }} = formMethods;- const resourceTypeValue = useWatch({ control, name: "resourceType" });const eventTypeValue = useWatch({ control, name: "eventType" });const isExpiryEvent = eventTypeValue === AlertEventType.IdentityAuthenticationExpiry;const alertNamePlaceholders = isAgentVault? AGENT_VAULT_ALERT_NAME_PLACEHOLDERS: DEFAULT_ALERT_NAMES;- const isResourceScope = Boolean(resourceId ?? alert?.resourceId);const handleEventTypeChange = (previous: AlertEventType, next: AlertEventType) => {setValue("eventType", next, { shouldDirty: true });if (getValues("name") === DEFAULT_ALERT_NAMES[previous]) {@@ -196,9 +197,7 @@ export const AlertForm = ({<Inputid="alert-name"autoFocus- placeholder={- alertNamePlaceholders[eventTypeValue] ?? alertNamePlaceholders[DEFAULT_EVENT_TYPE]- }+ placeholder={alertNamePlaceholders[eventTypeValue]}isError={Boolean(errors.name)}{...register("name")}autoComplete="off"@@ -239,7 +238,7 @@ export const AlertForm = ({<SelectValue /></SelectTrigger><SelectContent position="popper">- {Object.values(AlertEventType).map((eventType) => (+ {eventTypes.map((eventType) => (<SelectItemkey={eventType}value={eventType}@@ -275,38 +274,6 @@ export const AlertForm = ({)}/>- {!isResourceScope && (- <Controller- control={control}- name="resourceType"- render={({ field: { value, onChange } }) => (- <Field>- <FieldLabel>Resource type</FieldLabel>- <FieldContent>- <Select value={value} onValueChange={onChange}>- <SelectTrigger className="w-full">- <SelectValue />- </SelectTrigger>- <SelectContent position="popper">- {Object.values(AlertResourceType).map((resourceType) => (- <SelectItem key={resourceType} value={resourceType}>- <span className="flex items-center gap-2">- <KeyRoundIcon className="size-4 text-muted" />- <span className="font-medium">- {ALERT_RESOURCE_TYPE_LABELS[resourceType]}- </span>- <span className="font-mono text-xs text-muted">{resourceType}</span>- </span>- </SelectItem>- ))}- </SelectContent>- </Select>- </FieldContent>- </Field>- )}- />- )}-{isExpiryEvent && (<div className="mb-1 flex flex-col gap-1.5"><Label htmlFor="alert-alert-before">Condition</Label>@@ -344,7 +311,7 @@ export const AlertForm = ({<ChannelsFieldprojectId={projectId}- resourceType={resourceTypeValue}+ resourceType={resourceType}resourceId={resourceId ?? alert?.resourceId ?? null}/></div>