Harden authentication, tenant isolation and security boundaries

This commit is contained in:
t.indorf
2026-10-09 22:49:55 +02:00
parent ec3f4f933d
commit 656ada80bd
71 changed files with 3107 additions and 1200 deletions
+23
View File
@@ -0,0 +1,23 @@
import { stat } from "node:fs/promises";
import { PrismaClient } from "@prisma/client";
import { attachmentPath } from "../src/lib/attachments";
const prisma = new PrismaClient();
async function main() {
let count = 0, missing = 0;
while (true) {
const batch = await prisma.attachment.findMany({ where: { sizeBytes: null }, select: { id: true }, take: 100 });
if (!batch.length) break;
for (const item of batch) {
let sizeBytes = 0;
try { sizeBytes = (await stat(attachmentPath(item.id))).size; }
catch (error) {
if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
missing++;
}
await prisma.attachment.update({ where: { id: item.id }, data: { sizeBytes } });
count++;
}
}
console.log(`Attachment sizes recorded: ${count}; missing files: ${missing}.`);
}
main().finally(() => prisma.$disconnect()).catch(() => { console.error("Attachment size backfill failed."); process.exitCode = 1; });