Skip to content

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

fix audit log event for log retention

Thiago Araujo da Silva3dfcbedc0e3b
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 d67ab79180..227d688a78 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -6025,7 +6025,8 @@ interface UpdateAuditLogSettingsEvent {
type: EventType.UPDATE_AUDIT_LOG_SETTINGS;
metadata: {
scope: "organization" | "project";
- eventClasses: { eventClass: string; isEnabled: boolean }[];
+ eventClasses?: { eventClass: string; isEnabled: boolean }[];
+ auditLogsRetentionDays?: number;
};
}
diff --git a/backend/src/server/routes/v1/project-router.ts b/backend/src/server/routes/v1/project-router.ts
index e5fc3e11ca..abfe56fbcf 100644
--- a/backend/src/server/routes/v1/project-router.ts
+++ b/backend/src/server/routes/v1/project-router.ts
@@ -713,8 +713,11 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
orgId: req.permission.orgId,
projectId: project.id,
event: {
- type: EventType.UPDATE_PROJECT,
- metadata: req.body
+ type: EventType.UPDATE_AUDIT_LOG_SETTINGS,
+ metadata: {
+ scope: "project",
+ auditLogsRetentionDays: req.body.auditLogsRetentionDays
+ }
}
});
diff --git a/docs/documentation/platform/audit-logs.mdx b/docs/documentation/platform/audit-logs.mdx
index ae8c995877..fe003fb1ea 100644
--- a/docs/documentation/platform/audit-logs.mdx
+++ b/docs/documentation/platform/audit-logs.mdx
@@ -253,7 +253,7 @@ By default, Infisical records every class except `authorization`. The `managemen
</Step>
</Steps>
- Changing these toggles requires the **Edit Settings** permission on **Audit Logs**, which the built-in admin role has. Anyone with the **Read** permission on **Audit Logs** can view them.
+ Changing these toggles requires the **Edit** permission on **Audit Logs**, which the built-in admin role has. Anyone with the **Read** permission on **Audit Logs** can view them.
</Tab>
<Tab title="For a project">
<Steps>
@@ -265,7 +265,7 @@ By default, Infisical records every class except `authorization`. The `managemen
</Step>
</Steps>
- Changing these toggles requires the **Edit Settings** permission on **Audit Logs**, which the built-in admin role has. Anyone with the **Read** permission on **Audit Logs** can view them. A project that has never saved a setting uses the defaults.
+ Changing these toggles requires the **Edit** permission on **Audit Logs**, which the built-in admin role has. Anyone with the **Read** permission on **Audit Logs** can view them. A project that has never saved a setting uses the defaults.
</Tab>
<Tab title="API">
Update the organization's classes with [the organization audit log settings endpoint](/api-reference/endpoints/audit-logs/update-organization-audit-log-settings), or one project's classes with [the project audit log settings endpoint](/api-reference/endpoints/audit-logs/update-project-audit-log-settings). The request replaces the current settings, so include every class except `management` and `data-access`.
@@ -287,7 +287,7 @@ By default, Infisical records every class except `authorization`. The `managemen
A change usually applies to new events right away, and always within 10 minutes. Events that were already recorded stay in the log until their retention period ends.
-Every change to these settings is itself recorded as an `update-audit-log-settings` event in the `management` class, with the classes that changed in `event.metadata`.
+Every change to these settings is itself recorded as an `update-audit-log-settings` event in the `management` class, with the new values in `event.metadata`. If you self-host Infisical, changing how long a project keeps its audit logs records the same event.
### Permission denials
@@ -978,7 +978,7 @@ Infisical emits hundreds of event types. Here are some of the most common ones y
| Event | When it fires |
| ----------------------------------------------------------------------- | -------------------------------------------------------------------- |
| `view-audit-logs` | A user opened the audit log viewer. |
- | `update-audit-log-settings` | An admin changed which event classes an organization or project records. |
+ | `update-audit-log-settings` | An admin changed which event classes an organization or project records, or how long a project keeps its audit logs. |
| `create-audit-report`, `get-audit-report`, `get-audit-reports`, `delete-audit-report` | A user managed a project-level audit report. |
| `create-org-audit-report`, `get-org-audit-reports`, `delete-org-audit-report` | A user managed an organization-level audit report. |
</Accordion>
diff --git a/docs/internals/permissions/project-permissions.mdx b/docs/internals/permissions/project-permissions.mdx
index 7ea1b9144c..b359ac9604 100644
--- a/docs/internals/permissions/project-permissions.mdx
+++ b/docs/internals/permissions/project-permissions.mdx
@@ -122,10 +122,10 @@ Supports conditions and permission inversion.
#### Subject: `audit-logs`
-| Action | Description |
-| ------ | --------------------------------------------------------------------------------------------- |
-| `read` | View audit logs of actions performed within the project |
-| `edit` | Choose which audit log event classes the project records and how long its audit logs are kept |
+| Action | Description |
+| ------ | --------------------------------------------------------- |
+| `read` | View audit logs of actions performed within the project |
+| `edit` | Choose which audit log event classes the project records |
#### Subject: `integrations`
diff --git a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx
index 31b76d1804..01f5465f7e 100644
--- a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx
+++ b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx
@@ -33,7 +33,7 @@ export const AuditLogSettingsTab = withPermission(
isError={isError}
isSaving={isSaving}
canEdit={canEdit}
- readOnlyMessage="You need the Edit Settings permission on Audit Logs to change these settings."
+ readOnlyMessage="You need the Edit permission on Audit Logs to change these settings."
variant={scopeVariant}
paywallKey="organization.audit-log-settings"
onSave={(eventClasses) => updateSettings({ eventClasses })}
diff --git a/frontend/src/pages/organization/RoleByIDPage/components/OrgRoleModifySection.utils.ts b/frontend/src/pages/organization/RoleByIDPage/components/OrgRoleModifySection.utils.ts
index 0683886e46..f52569ee09 100644
--- a/frontend/src/pages/organization/RoleByIDPage/components/OrgRoleModifySection.utils.ts
+++ b/frontend/src/pages/organization/RoleByIDPage/components/OrgRoleModifySection.utils.ts
@@ -631,7 +631,7 @@ export const ORG_PERMISSION_OBJECT: Record<string, TOrgPermissionConfig> = {
},
{
value: OrgPermissionAuditLogsActions.Edit,
- label: "Edit Settings",
+ label: "Edit",
description: "Choose which audit log event classes the organization records"
}
]
diff --git a/frontend/src/pages/project/AuditLogsPage/components/AuditLogEventClassesSection/AuditLogEventClassesSection.tsx b/frontend/src/pages/project/AuditLogsPage/components/AuditLogEventClassesSection/AuditLogEventClassesSection.tsx
index 2e3284fc87..09f9c8b227 100644
--- a/frontend/src/pages/project/AuditLogsPage/components/AuditLogEventClassesSection/AuditLogEventClassesSection.tsx
+++ b/frontend/src/pages/project/AuditLogsPage/components/AuditLogEventClassesSection/AuditLogEventClassesSection.tsx
@@ -29,7 +29,7 @@ export const AuditLogEventClassesSection = () => {
isError={isError}
isSaving={isSaving}
canEdit={canEdit}
- readOnlyMessage="You need the Edit Settings permission on Audit Logs to change these settings."
+ readOnlyMessage="You need the Edit permission on Audit Logs to change these settings."
variant={scopeVariant}
paywallKey="project.audit-log-settings"
onSave={(eventClasses) => updateSettings({ projectId: currentProject.id, eventClasses })}
diff --git a/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx b/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx
index 2815a1bb93..68b7f31973 100644
--- a/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx
+++ b/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx
@@ -2687,10 +2687,9 @@ export const PROJECT_PERMISSION_OBJECT: TProjectPermissionObject = {
description: "View audit logs and security events"
},
{
- label: "Edit Settings",
+ label: "Edit",
value: ProjectPermissionAuditLogsActions.Edit,
- description:
- "Choose which audit log event classes the project records and how long logs are kept"
+ description: "Choose which audit log event classes the project records"
}
]
},