Add a content security policy and expire mailed export links.

Responses had no CSP, the 48-hour download token never changed, and short share slugs could be guessed without a miss limit.
This commit is contained in:
adilallo committed 2026-11-21 11:46:16 -07:00
1 parent 0fe2624002
commit 75649a9a42
18 files changed
+249 -19

No files matched your search

@@ -2,6 +2,7 @@ import { NextRequest } from "next/server";
import { beforeEach, describe, expect, it, vi } from "vitest";
const findFirstRuleMock = vi.fn();
const publishedRuleUpdateMock = vi.fn();
const findFirstStakeholderMock = vi.fn();
const countMock = vi.fn();
const deleteMock = vi.fn();
@@ -20,6 +21,7 @@ vi.mock("../../lib/server/db", () => ({
prisma: {
publishedRule: {
findFirst: (...args: unknown[]) => findFirstRuleMock(...args),
update: (...args: unknown[]) => publishedRuleUpdateMock(...args),
},
ruleStakeholder: {
findFirst: (...args: unknown[]) => findFirstStakeholderMock(...args),
@@ -67,6 +69,7 @@ const memberCtx = {
beforeEach(() => {
findFirstRuleMock.mockReset();
publishedRuleUpdateMock.mockReset();
findFirstStakeholderMock.mockReset();
countMock.mockReset();
deleteMock.mockReset();
@@ -177,6 +180,10 @@ describe("DELETE /api/rules/[id]/stakeholders/[stakeholderId]", () => {
expect(res.status).toBe(200);
expect(await res.json()).toEqual({ ok: true });
expect(deleteMock).toHaveBeenCalledWith({ where: { id: "st-1" } });
expect(publishedRuleUpdateMock).toHaveBeenCalledWith({
where: { id: "rule-1" },
data: { exportTokenVersion: { increment: 1 } },
});
});
});