feat: Implement centralized audit logging admin interface (refs #10)
Some checks failed
Deploy to Staging / Build Images (pull_request) Successful in 4m42s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 37s
Deploy to Staging / Verify Staging (pull_request) Failing after 6s
Deploy to Staging / Notify Staging Ready (pull_request) Has been skipped
Deploy to Staging / Notify Staging Failure (pull_request) Successful in 6s
Some checks failed
Deploy to Staging / Build Images (pull_request) Successful in 4m42s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 37s
Deploy to Staging / Verify Staging (pull_request) Failing after 6s
Deploy to Staging / Notify Staging Ready (pull_request) Has been skipped
Deploy to Staging / Notify Staging Failure (pull_request) Successful in 6s
- Add audit_logs table with categories, severities, and indexes - Create AuditLogService and AuditLogRepository - Add REST API endpoints for viewing and exporting logs - Wire audit logging into auth, vehicles, admin, and backup features - Add desktop AdminLogsPage with filters and CSV export - Add mobile AdminLogsMobileScreen with card layout - Implement 90-day retention cleanup job - Remove old AuditLogPanel from AdminCatalogPage Security fixes: - Escape LIKE special characters to prevent pattern injection - Limit CSV export to 5000 records to prevent memory exhaustion - Add truncation warning headers for large exports 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,10 @@ import {
|
||||
processBackupRetention,
|
||||
setBackupCleanupJobPool,
|
||||
} from '../../features/backup/jobs/backup-cleanup.job';
|
||||
import {
|
||||
processAuditLogCleanup,
|
||||
setAuditLogCleanupJobPool,
|
||||
} from '../../features/audit-log/jobs/cleanup.job';
|
||||
import { pool } from '../config/database';
|
||||
|
||||
let schedulerInitialized = false;
|
||||
@@ -31,6 +35,9 @@ export function initializeScheduler(): void {
|
||||
setBackupJobPool(pool);
|
||||
setBackupCleanupJobPool(pool);
|
||||
|
||||
// Initialize audit log cleanup job pool
|
||||
setAuditLogCleanupJobPool(pool);
|
||||
|
||||
// Daily notification processing at 8 AM
|
||||
cron.schedule('0 8 * * *', async () => {
|
||||
logger.info('Running scheduled notification job');
|
||||
@@ -90,8 +97,30 @@ export function initializeScheduler(): void {
|
||||
}
|
||||
});
|
||||
|
||||
// Audit log retention cleanup at 3 AM daily (90-day retention)
|
||||
cron.schedule('0 3 * * *', async () => {
|
||||
logger.info('Running audit log cleanup job');
|
||||
try {
|
||||
const result = await processAuditLogCleanup();
|
||||
if (result.success) {
|
||||
logger.info('Audit log cleanup job completed', {
|
||||
deletedCount: result.deletedCount,
|
||||
retentionDays: result.retentionDays,
|
||||
});
|
||||
} else {
|
||||
logger.error('Audit log cleanup job failed', {
|
||||
error: result.error,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('Audit log cleanup job failed', {
|
||||
error: error instanceof Error ? error.message : String(error)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
schedulerInitialized = true;
|
||||
logger.info('Cron scheduler initialized - notification (8 AM), account purge (2 AM), backup check (every min), retention cleanup (4 AM)');
|
||||
logger.info('Cron scheduler initialized - notification (8 AM), account purge (2 AM), audit log cleanup (3 AM), backup check (every min), retention cleanup (4 AM)');
|
||||
}
|
||||
|
||||
export function isSchedulerInitialized(): boolean {
|
||||
|
||||
Reference in New Issue
Block a user