Entries were stored in UTC without a zone marker and the Audit and Diagnostic Log pages read them as local time, so every entry showed shifted by the viewer's UTC offset (two hours early in Sweden). A shared parseDbTimestamp() now reads them as UTC, and replaces the inline workaround the Consistency page had. The Audit Log never displayed an entry's details at all, so adding an admin link showed only "server #1". Link entries now carry the server name and the label/URL, and a new Details column shows them, along with things like a port scan's address and range. Entries made within the same second are now ordered by id instead of arbitrarily. A domain's "Check now" was the one user-triggered action that wasn't audited; it is now. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
18 lines
754 B
TypeScript
18 lines
754 B
TypeScript
import { Router } from "express";
|
|
import { desc } from "drizzle-orm";
|
|
import { db } from "../db/client.js";
|
|
import { auditLog } from "../db/schema.js";
|
|
import { requireAuth, requireRole } from "../auth/middleware.js";
|
|
import { asyncHandler } from "../utils/asyncHandler.js";
|
|
|
|
export const auditLogRouter = Router();
|
|
|
|
auditLogRouter.use(requireAuth, requireRole("operator"));
|
|
|
|
auditLogRouter.get("/", asyncHandler(async (req, res) => {
|
|
const limit = Math.min(Number(req.query.limit ?? 200), 500);
|
|
// createdAt only has one-second resolution, so entries made within the same second are ordered by id.
|
|
const rows = await db.select().from(auditLog).orderBy(desc(auditLog.createdAt), desc(auditLog.id)).limit(limit);
|
|
res.json({ entries: rows });
|
|
}));
|