mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-04 19:21:51 +00:00
1090ed59b7
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>
19 lines
631 B
TypeScript
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"));
|
|
});
|
|
});
|