Skip to content

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

update comments

Thiago Araujo da Silva823a01521790
diff --git a/backend/src/db/migrations/20260924100000_audit-log-settings.ts b/backend/src/db/migrations/20260924100000_audit-log-settings.ts
index 54daecf6f8..4abf0a71a4 100644
--- a/backend/src/db/migrations/20260924100000_audit-log-settings.ts
+++ b/backend/src/db/migrations/20260924100000_audit-log-settings.ts
@@ -17,7 +17,6 @@ export async function up(knex: Knex): Promise<void> {
t.index(["orgId"]);
});
- // Two partial indexes: NULLS NOT DISTINCT needs Postgres 15.
await knex.raw(
`CREATE UNIQUE INDEX "audit_log_settings_org_scope_unique" ON ??("orgId", "eventClass") WHERE "projectId" IS NULL`,
[TableName.AuditLogSettings]
diff --git a/backend/src/ee/services/audit-log/audit-log-service.ts b/backend/src/ee/services/audit-log/audit-log-service.ts
index 8b78101655..02787feca1 100644
--- a/backend/src/ee/services/audit-log/audit-log-service.ts
+++ b/backend/src/ee/services/audit-log/audit-log-service.ts
@@ -199,9 +199,8 @@ export const auditLogServiceFactory = ({
return auditLogQueue.pushToLog(el);
};
- // Runs when a collapse window closes. Pushes straight to the log rather than through
- // createAuditLog: we're outside a request here, and the payload already carries the actor's
- // permission metadata from the first event.
+ // Runs outside a request, so it skips createAuditLog. The payload already carries the
+ // actor's permission metadata from the first event.
const flushCollapsedRepeats = async ({
collapseKey,
windowStart,
@@ -228,8 +227,8 @@ export const auditLogServiceFactory = ({
await flushCollapsedRepeats(job.data);
});
- // The first event per key is written right away and opens a window; repeats inside it only
- // bump a counter that the flush job turns into one summary event when the window closes.
+ // First event per key is written and opens a window. Repeats inside it only bump a counter
+ // that the flush job turns into one summary event.
const createCollapsedAuditLog: TAuditLogServiceFactory["createCollapsedAuditLog"] = async ({
collapseKeyParts,
collapseWindowSeconds = DEFAULT_COLLAPSE_WINDOW_SECONDS,
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.ts
index c689e9afd1..5a68f2fbaa 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
@@ -128,8 +128,7 @@ export const auditLogSettingsServiceFactory = ({
return settings;
};
- // Hot path (every event and every denial), so it's cached and never throws. A failed
- // lookup means record everything, as before.
+ // Hot path, so cached and never throws. On failure we fall back to recording everything.
const getEffectiveSettings = async (orgId: string): Promise<TEffectiveAuditLogSettings | null> => {
const cacheKey = KeyStorePrefixes.AuditLogOrgSettings(orgId);
try {
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 4d0f62eca1..389fb0e35e 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -122,8 +122,8 @@ export type TCreateAuditLogDTO = {
export type AuditLogInfo = Pick<TCreateAuditLogDTO, "userAgent" | "userAgentType" | "ipAddress" | "actor">;
-// Added to the event metadata by the summary event a collapse window writes when it closes.
-// An event passed to createCollapsedAuditLog should include this in its metadata type.
+// Merged into the metadata of the summary event written when a collapse window closes, so
+// events passed to createCollapsedAuditLog should include it in their metadata type.
export type TAuditLogCollapseSummary = {
suppressedRepeats?: number;
suppressedFrom?: string;
@@ -131,8 +131,7 @@ export type TAuditLogCollapseSummary = {
};
export type TCreateCollapsedAuditLogDTO = TCreateAuditLogDTO & {
- // Together with the event type, identifies a repeat: events with the same parts inside the
- // window collapse into the first one plus a summary.
+ // Events with the same type and parts inside the window count as repeats.
collapseKeyParts: unknown[];
collapseWindowSeconds?: number;
};
diff --git a/backend/src/server/plugins/audit-log-permission-denied.ts b/backend/src/server/plugins/audit-log-permission-denied.ts
index 523fdb12f1..e6af7067f0 100644
--- a/backend/src/server/plugins/audit-log-permission-denied.ts
+++ b/backend/src/server/plugins/audit-log-permission-denied.ts
@@ -7,9 +7,8 @@ import { RequestContextKey } from "@app/lib/request-context/request-context-keys
const isPrimitive = (value: unknown) => value === null || ["string", "number", "boolean"].includes(typeof value);
-// Only the primitive fields of the CASL subject. The subject() marker is non-enumerable so
-// it drops out, and nested objects are skipped on purpose since the subject can wrap a
-// request body.
+// The subject() marker is non-enumerable so it drops out. Nested objects are skipped on
+// purpose since the subject can wrap a request body.
const pickSubjectDetails = (subject: unknown) => {
if (!subject || typeof subject !== "object" || Array.isArray(subject)) return undefined;
const details: Record<string, unknown> = {};
@@ -27,10 +26,10 @@ const readProjectId = (source: unknown) => {
return typeof projectId === "string" ? projectId : undefined;
};
-// Every RBAC denial is a thrown CASL ForbiddenError or PermissionBoundaryError, and onError
-// hooks run before the error handler, so this one hook sees all of them. ForbiddenRequestError
-// is left out on purpose: verifyAuth throws it for auth-mode mismatches and it's also used for
-// plan gating and admin-only checks, none of which are permission decisions.
+// Every RBAC denial is a CASL ForbiddenError or PermissionBoundaryError, and onError hooks run
+// before the error handler, so this one hook sees all of them. ForbiddenRequestError is skipped
+// on purpose: it's used for auth-mode mismatches, plan gating and admin-only checks, none of
+// which are permission decisions.
export const injectPermissionDeniedAuditLog = fp(async (server: FastifyZodProvider) => {
server.addHook("onError", async (req, _reply, error) => {
const isCaslDenial = error instanceof ForbiddenError;
diff --git a/backend/src/services/org/org-service.ts b/backend/src/services/org/org-service.ts
index b4fe162cf6..9a079c54d6 100644
--- a/backend/src/services/org/org-service.ts
+++ b/backend/src/services/org/org-service.ts
@@ -445,7 +445,7 @@ export const orgServiceFactory = ({
});
// Denials are only recorded on the new privilege system, so bust the cache or the first
- // denial after the upgrade gets skipped.
+ // denial after the upgrade is skipped.
await keyStore.deleteItem(KeyStorePrefixes.AuditLogOrgSettings(actorOrgId));
return upgradedOrg;
diff --git a/frontend/src/hooks/api/auditLogSettings/constants.tsx b/frontend/src/hooks/api/auditLogSettings/constants.tsx
index ba14a14d8b..d041de5304 100644
--- a/frontend/src/hooks/api/auditLogSettings/constants.tsx
+++ b/frontend/src/hooks/api/auditLogSettings/constants.tsx
@@ -34,7 +34,7 @@ export const AUDIT_LOG_EVENT_CLASSES = [
AuditLogEventClass.Authorization
] as const;
-// Every class an update must name; the request replaces the scope's settings.
+// An update replaces the scope's settings, so every one of these must be sent.
export const CONFIGURABLE_AUDIT_LOG_EVENT_CLASSES = [
AuditLogEventClass.DataAccess,
AuditLogEventClass.Authentication,