Files
prowler/ui/__tests__/mockServiceWorker.test.ts
T
Pablo Fernandez Guerra (PFE) 1090ed59b7 feat(ui): replace D3+Dagre attack path graph with React Flow (#10686)
Co-authored-by: Pablo F.G <pablo.fernandez@prowler.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Alan Buscaglia <gentlemanprogramming@gmail.com>
2026-05-12 16:33:29 +02:00

19 lines
631 B
TypeScript

import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
describe("mock service worker message hardening", () => {
it("rejects messages from unexpected origins before handling client messages", () => {
const workerSource = readFileSync(
join(process.cwd(), "public/mockServiceWorker.js"),
"utf8",
);
expect(workerSource).toContain("event.origin !== self.location.origin");
expect(
workerSource.indexOf("event.origin !== self.location.origin"),
).toBeLessThan(workerSource.indexOf("const clientId = Reflect.get"));
});
});