Files
hyperframes/packages/cli/src/capture/lottiePreviewRequests.test.ts
James Russo 26916b7bdd fix(cli): validate captured Lottie archives and previews (#3811)
* fix(cli): validate captured Lottie archives and previews

* fix(cli): bound Lottie discovery before buffering

* fix(cli): bound Lottie discovery lifecycle and archive paths

* fix(cli): retain highest-priority Lottie candidates
2026-09-09 08:50:48 -04:00

24 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { allowedLottieRequest, LOTTIE_RUNTIME_URL } from "./lottiePreviewRequests.js";
describe("Lottie preview request policy", () => {
it("allows the pinned runtime and public image/font assets", () => {
expect(allowedLottieRequest(LOTTIE_RUNTIME_URL, "script")).toBe(true);
expect(allowedLottieRequest("https://cdn.example/image.png", "image")).toBe(true);
expect(allowedLottieRequest("https://cdn.example/font.woff2", "font")).toBe(true);
expect(allowedLottieRequest("data:image/png;base64,AA==", "image")).toBe(true);
});
it.each([
"http://127.0.0.1/a",
"http://169.254.169.254/a",
"http://[::1]/a",
"file:///etc/passwd",
])("blocks private and local targets %s", (url) => {
expect(allowedLottieRequest(url, "image")).toBe(false);
});
it("blocks arbitrary scripts and navigations", () => {
expect(allowedLottieRequest("https://cdn.example/script.js", "script")).toBe(false);
expect(allowedLottieRequest("https://cdn.example/page", "document")).toBe(false);
});
});