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
gate on audit log read other than project read
Thiago Araujo da Silvaea016fc194be
diff --git a/backend/src/ee/services/audit-log/audit-log-settings-service.test.ts b/backend/src/ee/services/audit-log/audit-log-settings-service.test.tsindex 9bd5d8755d..9456409621 100644--- a/backend/src/ee/services/audit-log/audit-log-settings-service.test.ts+++ b/backend/src/ee/services/audit-log/audit-log-settings-service.test.ts@@ -88,6 +88,7 @@ const createHarness = ({rows = [] as TRow[],shouldUseNewPrivilegeSystem = true,canEditAuditLogs = true,+ canReadAuditLogs = true,planHasAuditLogs = true} = {}) => {const tx = { raw: vi.fn(async () => undefined) };@@ -114,6 +115,9 @@ const createHarness = ({getOrgPermission: vi.fn(async () => ({permission: createMongoAbility([{ action: [OrgPermissionActions.Read, OrgPermissionActions.Edit], subject: OrgPermissionSubjects.Settings },+ ...(canReadAuditLogs+ ? [{ action: OrgPermissionAuditLogsActions.Read, subject: OrgPermissionSubjects.AuditLogs }]+ : []),...(canEditAuditLogs? [{ action: OrgPermissionAuditLogsActions.Edit, subject: OrgPermissionSubjects.AuditLogs }]: [])@@ -125,6 +129,9 @@ const createHarness = ({action: [ProjectPermissionActions.Read, ProjectPermissionActions.Edit],subject: ProjectPermissionSub.Settings},+ ...(canReadAuditLogs+ ? [{ action: ProjectPermissionAuditLogsActions.Read, subject: ProjectPermissionSub.AuditLogs }]+ : []),...(canEditAuditLogs? [{ action: ProjectPermissionAuditLogsActions.Edit, subject: ProjectPermissionSub.AuditLogs }]: [])@@ -254,6 +261,12 @@ describe("updateOrgSettings", () => {expect(result.eventClasses).toHaveLength(4);});+ test("refuses to read without read on audit logs, even with read on settings", async () => {+ const { service } = createHarness({ canReadAuditLogs: false });++ await expect(service.getOrgSettings({ actor: orgActor })).rejects.toThrow(ForbiddenError);+ });+test("refuses to save on a plan without audit logs", async () => {const { service, auditLogSettingsDAL } = createHarness({ planHasAuditLogs: false });@@ -434,6 +447,12 @@ describe("updateProjectSettings", () => {expect(auditLogSettingsDAL.delete).toHaveBeenCalledWith({ orgId: "org-1", projectId: "p1" }, expect.anything());});+ test("refuses to read without read on audit logs, even with read on settings", async () => {+ const { service } = createHarness({ canReadAuditLogs: false });++ await expect(service.getProjectSettings(projectActor)).rejects.toThrow(ForbiddenError);+ });+test("refuses to save on a plan without audit logs, checked against the project's org", async () => {const { service, auditLogSettingsDAL, licenseService } = createHarness({ planHasAuditLogs: false });diff --git a/backend/src/ee/services/audit-log/audit-log-settings-service.ts b/backend/src/ee/services/audit-log/audit-log-settings-service.tsindex b2a7ccae22..033af7633c 100644--- a/backend/src/ee/services/audit-log/audit-log-settings-service.ts+++ b/backend/src/ee/services/audit-log/audit-log-settings-service.ts@@ -11,17 +11,9 @@ import { TOrgDALFactory } from "@app/services/org/org-dal";import { TProjectDALFactory } from "@app/services/project/project-dal";import { TLicenseServiceFactory } from "../license/license-service";-import {- OrgPermissionActions,- OrgPermissionAuditLogsActions,- OrgPermissionSubjects-} from "../permission/org-permission";+import { OrgPermissionAuditLogsActions, OrgPermissionSubjects } from "../permission/org-permission";import { TPermissionServiceFactory } from "../permission/permission-service-types";-import {- ProjectPermissionActions,- ProjectPermissionAuditLogsActions,- ProjectPermissionSub-} from "../permission/project-permission";+import { ProjectPermissionAuditLogsActions, ProjectPermissionSub } from "../permission/project-permission";import {AUDIT_LOG_EVENT_CLASS_DEFAULTS,AUDIT_LOG_EVENT_CLASSES,@@ -281,7 +273,7 @@ export const auditLogSettingsServiceFactory = ({const getOrgSettings = async ({ actor }: TGetOrgAuditLogSettingsDTO) => {const { permission } = await getOrgPermission(actor);- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Settings);+ ForbiddenError.from(permission).throwUnlessCan(OrgPermissionAuditLogsActions.Read, OrgPermissionSubjects.AuditLogs);const org = await findOrgOrThrow(actor.orgId);const rows = await auditLogSettingsDAL.find({ orgId: org.id, projectId: null });return toResponse(toOverrides(rows), org);@@ -313,7 +305,10 @@ export const auditLogSettingsServiceFactory = ({actorOrgId,actionProjectType: ActionProjectType.Any});- ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Settings);+ ForbiddenError.from(permission).throwUnlessCan(+ ProjectPermissionAuditLogsActions.Read,+ ProjectPermissionSub.AuditLogs+ );const project = await findProjectOrThrow(projectId);const org = await findOrgOrThrow(project.orgId);diff --git a/docs/documentation/platform/audit-logs.mdx b/docs/documentation/platform/audit-logs.mdxindex c293cc1a4e..ae8c995877 100644--- a/docs/documentation/platform/audit-logs.mdx+++ b/docs/documentation/platform/audit-logs.mdx@@ -253,19 +253,19 @@ 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 **Settings** can view them.+ 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.</Tab><Tab title="For a project"><Steps><Step>- Open the project and go to **Settings**.+ Open the project, go to **Audit Logs**, and select the **Settings** tab.</Step><Step>- Under **Audit Log Event Classes**, turn a class on or off, then select **Save Changes**.+ Under **Event Classes**, turn a class on or off, then select **Save Changes**.</Step></Steps>- Changing these toggles requires the **Edit Settings** permission on **Audit Logs**, which the built-in admin role has. A project that has never saved a setting uses the defaults. The section appears in the settings of Secret Manager, KMS, and Secret Scanning projects. For other project types, use the API.+ 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.</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`.diff --git a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsxindex 474b78bb17..31b76d1804 100644--- a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx+++ b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx@@ -1,6 +1,5 @@import { AuditLogEventClassesForm } from "@app/components/auditLogSettings";import {- OrgPermissionActions,OrgPermissionAuditLogsActions,OrgPermissionSubjects,useOrganization,@@ -42,8 +41,8 @@ export const AuditLogSettingsTab = withPermission();},{- action: OrgPermissionActions.Read,- subject: OrgPermissionSubjects.Settings,+ action: OrgPermissionAuditLogsActions.Read,+ subject: OrgPermissionSubjects.AuditLogs,accessRestrictedMode: "dialog"});diff --git a/frontend/src/pages/project/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx b/frontend/src/pages/project/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsxindex acefdf39e7..b10d082499 100644--- a/frontend/src/pages/project/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx+++ b/frontend/src/pages/project/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx@@ -1,4 +1,4 @@-import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context";+import { ProjectPermissionAuditLogsActions, ProjectPermissionSub } from "@app/context";import { withProjectPermission } from "@app/hoc";import { AuditLogEventClassesSection } from "../AuditLogEventClassesSection";@@ -12,8 +12,8 @@ export const AuditLogSettingsTab = withProjectPermission(</div>),{- action: ProjectPermissionActions.Read,- subject: ProjectPermissionSub.Settings,+ action: ProjectPermissionAuditLogsActions.Read,+ subject: ProjectPermissionSub.AuditLogs,accessRestrictedMode: "dialog"});