security: isolate artifact documents and default servers to execution-only

This commit is contained in:
2026-10-20 15:36:14 +01:00
parent db88cebd0b
commit f06281db08
10 changed files with 193 additions and 4 deletions
+20
View File
@@ -0,0 +1,20 @@
// Invoked by the Go scratch-server test, never against the deployed service.
import assert from "node:assert/strict";
import { launchChrome } from "./browser.mjs";
const url = process.argv[2];
assert.ok(url?.startsWith("http://127.0.0.1:"), "scratch loopback fixture required");
const browser = await launchChrome({ width: 390, height: 844 });
try {
const page = await browser.openPage("about:blank");
await page.goto(url);
await page.waitForSelector("#report");
assert.equal(await page.evaluate("document.title"), "Safe report");
assert.equal(await page.evaluate("document.querySelector('#report').textContent"), "Readable report");
assert.equal(await page.evaluate("getComputedStyle(document.querySelector('#report')).color"), "rgb(12, 34, 56)");
// The inline attack would change the title and call /attack if it ran. The
// server-side test also asserts that endpoint received no request.
console.log("Raw HTML report is readable; inline script blocked by response policy.");
} finally {
await browser.close();
}