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
refactor(audit-log): enhance audit log service and configuration handling
Victor Hugo dos Santos3ebe41e64664
diff --git a/backend/src/ee/services/audit-log/audit-log-service.ts b/backend/src/ee/services/audit-log/audit-log-service.tsindex 95a827c3f6..b02b022e91 100644--- a/backend/src/ee/services/audit-log/audit-log-service.ts+++ b/backend/src/ee/services/audit-log/audit-log-service.ts@@ -179,7 +179,13 @@ export const auditLogServiceFactory = ({const checkPostgresAuditLogVolumeMigrationAlert = async () => {const appCfg = getConfig();const isClickHouseConfigured = appCfg.isClickHouseConfigured && appCfg.CLICKHOUSE_AUDIT_LOG_ENABLED;- if (isClickHouseConfigured || appCfg.isCloud) return;+ if (+ isClickHouseConfigured ||+ appCfg.isCloud ||+ appCfg.DISABLE_AUDIT_LOG_GENERATION ||+ appCfg.DISABLE_POSTGRES_AUDIT_LOG_STORAGE+ )+ return;const rowCount: number = await auditLogDAL.getApproximateRowCount();@@ -201,7 +207,14 @@ export const auditLogServiceFactory = ({adminsOnly: true});- if (superAdminsResult.users.length === 0) return;+ if (superAdminsResult.users.length === 0) {+ await keyStore.setItemWithExpiry(+ "audit-log-migration-alert-last-row-count",+ AUDIT_LOG_MIGRATION_ALERT_STATE_TTL_SECONDS,+ String(rowCount)+ );+ return;+ }const adminsWithEmail = superAdminsResult.users.filter((admin): admin is TUsers & { email: string } =>Boolean(admin.email)diff --git a/backend/src/lib/config/env.ts b/backend/src/lib/config/env.tsindex f8ffbe4841..5aead2df29 100644--- a/backend/src/lib/config/env.ts+++ b/backend/src/lib/config/env.ts@@ -133,9 +133,10 @@ const envSchema = zCLICKHOUSE_AUDIT_LOG_ENABLED: zodStrBool.default("true").describe("Enable inserting audit logs into ClickHouse"),AUDIT_LOG_STREAMS_ENABLED: zodStrBool.default("true").describe("Enable sending audit logs to external log streams"),DISABLE_AUDIT_LOG_STORAGE: zodStrBool.optional(), // deprecated: use DISABLE_POSTGRES_AUDIT_LOG_STORAGE instead- DISABLE_POSTGRES_AUDIT_LOG_STORAGE: zodStrBool- .default("false")+ DISABLE_POSTGRES_AUDIT_LOG_STORAGE: z+ .string().optional()+ .transform((val) => (val === undefined ? undefined : val === "true")).describe("Disable PostgreSQL audit log storage"),GENERATE_SANITIZED_SCHEMA: zodStrBool.default("false")@@ -465,9 +466,7 @@ const envSchema = z...data,SALT_ROUNDS: data.SALT_ROUNDS || data.BCRYPT_SALT_ROUND || 12,DISABLE_POSTGRES_AUDIT_LOG_STORAGE:- process.env.DISABLE_POSTGRES_AUDIT_LOG_STORAGE !== undefined- ? data.DISABLE_POSTGRES_AUDIT_LOG_STORAGE- : (data.DISABLE_AUDIT_LOG_STORAGE ?? false),+ data.DISABLE_POSTGRES_AUDIT_LOG_STORAGE ?? data.DISABLE_AUDIT_LOG_STORAGE ?? false,DB_READ_REPLICAS: data.DB_READ_REPLICAS? databaseReadReplicaSchema.parse(JSON.parse(data.DB_READ_REPLICAS)): undefined,diff --git a/backend/src/services/smtp/emails/AuditLogMigrationAlertTemplate.tsx b/backend/src/services/smtp/emails/AuditLogMigrationAlertTemplate.tsxindex ab683a7d67..51a40f1855 100644--- a/backend/src/services/smtp/emails/AuditLogMigrationAlertTemplate.tsx+++ b/backend/src/services/smtp/emails/AuditLogMigrationAlertTemplate.tsx@@ -23,12 +23,12 @@ export const AuditLogMigrationAlertTemplate = ({ siteUrl }: AuditLogMigrationAleto an external destination like Splunk or using the built-in ClickHouse integration.</Text><Section className="text-center mt-[16px]">- <BaseButton href={`${siteUrl}/docs/documentation/platform/audit-log-streams/audit-log-streams`}>+ <BaseButton href="https://infisical.com/docs/documentation/platform/audit-log-streams/audit-log-streams">Set Up Audit Log Streams</BaseButton></Section><Section className="text-center mt-[8px]">- <BaseButton href={`${siteUrl}/docs/documentation/platform/audit-logs-clickhouse-setup`}>+ <BaseButton href="https://infisical.com/docs/documentation/platform/audit-logs-clickhouse-setup">View ClickHouse Setup Guide</BaseButton></Section>