Files
paseo/packages/website/e2e/registry-server.mjs
Mohamed Boudra fc3b2c4eb7 Sanitize plugin overview rendering: no raw HTML, https links only, no relative links (#6244)
* fix(plugins): restrict overview content to safe Markdown and HTTPS destinations

Registry overviews are author-controlled content read away from their repositories. Apply a shared presentation policy instead of the documentation renderer so relative links, non-HTTPS URLs, raw HTML, and author styles never become active overview content.

* fix(plugins): choose the first allowed screenshot for previews
2026-10-06 18:31:53 +01:00

26 lines
1000 B
JavaScript

import { createServer } from "node:http";
import registry from "./registry.fixture.json" with { type: "json" };
import securityPlugin from "./overview.fixture.json" with { type: "json" };
import overviewCorpus from "../../protocol/tests/fixtures/plugin-overview.json" with { type: "json" };
securityPlugin.readme +=
"\n\n" +
overviewCorpus
.map(({ markdown }) => markdown + "\n\n```html\n" + markdown + "\n```")
.join("\n\n");
// Serve the published registry contract so SSR and browser navigation use the same data.
createServer((request, response) => {
response.setHeader("Content-Type", "application/json");
if (request.url === "/index.json") {
response.end(JSON.stringify(registry));
return;
}
const plugin = [securityPlugin, ...registry.plugins].find(
(entry) => request.url === `/plugins/${entry.id}.json`,
);
response.statusCode = plugin ? 200 : 404;
response.end(JSON.stringify(plugin ?? { error: "Plugin not found" }));
}).listen(8188, "127.0.0.1");