test(security): escape the whole endpoint when building the proof pattern

This commit is contained in:
Marc-André Bombeck committed 2026-09-27 02:20:18 +02:00
1 parent 45bae0013c
commit dd9efb5066
1 file changed
+6 -1
@@ -14,6 +14,11 @@ import { describe, expect, it } from "vitest";
import { ApiError } from "@/lib/api/api-fetch";
import { isReproofRequired } from "../existing-factor-reauth-dialog";
/** Escapes every regular-expression metacharacter, not only the ones the endpoints use today. */
function escapeRegExp(value: string): string {
return value.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
}
const read = (file: string) =>
readFileSync(resolve(__dirname, "..", file), "utf8");
@@ -51,7 +56,7 @@ describe.each([
it("sends the collected proof on the enrollment call itself", () => {
expect(source).toContain(endpoint);
expect(source).toMatch(
new RegExp(`${endpoint.replace(/[/.]/g, "\\$&")},\\s*proof\\)`),
new RegExp(`${escapeRegExp(endpoint)},\\s*proof\\)`),
);
});