mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 11:26:02 +00:00
fix: static, producer and engine file servers check Host and mark runtime pages (#7852)
* fix(cli): the static project server answers only loopback and marks pages another site loads check, snapshot, validate, layout, compare, grade-compare and motion-shot serve the project from a loopback server. It now refuses any Host other than loopback or its in-process name before reading a file. A page or file that another site loads comes back sandboxed, and its documents carry the another-site mark, so the runtime offers that site no editing port. The capture browser's own loads are unchanged. * fix(producer): the render file server answers only loopback and offers no editing port The render file server now refuses any Host other than loopback before it opens a file; the capture browser asks for localhost. Every HTML page it serves carries the another-site mark, so its runtime answers no editing connect. A render never sends one, so capture is unchanged. * fix(engine): the exported file server answers only its own host and offers no editing port createFileServer from @hyperframes/engine now refuses any Host other than loopback or the hostname it was bound to (on a wildcard bind, this machine's own addresses too) before it reads a file. Every HTML page it serves carries the another-site mark, so its runtime answers no editing connect.
This commit is contained in:
@@ -729,6 +729,46 @@ describe("serveStaticProjectHtml private project files", () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe("serveStaticProjectHtml page another site loads", () => {
|
||||
const MARK = '<meta name="hyperframes-preview-for-another-site">';
|
||||
const SANDBOX = "sandbox allow-scripts";
|
||||
|
||||
async function serveProject(): Promise<string> {
|
||||
dir = mkdtempSync(join(tmpdir(), "hf-static-site-"));
|
||||
writeFileSync(join(dir, "scene.html"), "<html><head></head><body>scene</body></html>");
|
||||
server = await serveStaticProjectHtml(
|
||||
dir,
|
||||
"<html><head></head><body>composition</body></html>",
|
||||
);
|
||||
return server.url;
|
||||
}
|
||||
|
||||
it.each(["", "scene.html"])(
|
||||
"marks and sandboxes /%s when another site frames it",
|
||||
async (path) => {
|
||||
const url = await serveProject();
|
||||
const res = await fetch(`${url}${path}`, {
|
||||
headers: { "Sec-Fetch-Site": "cross-site", "Sec-Fetch-Dest": "iframe" },
|
||||
});
|
||||
expect(res.status).toBe(200);
|
||||
expect(await res.text()).toContain(MARK);
|
||||
expect(res.headers.get("content-security-policy")).toContain(SANDBOX);
|
||||
},
|
||||
);
|
||||
|
||||
it.each(["none", "same-origin"])(
|
||||
"leaves the capture page unmarked for Sec-Fetch-Site %s",
|
||||
async (site) => {
|
||||
const url = await serveProject();
|
||||
for (const path of ["", "scene.html"]) {
|
||||
const res = await fetch(`${url}${path}`, { headers: { "Sec-Fetch-Site": site } });
|
||||
expect(await res.text(), path).not.toContain(MARK);
|
||||
expect(res.headers.get("content-security-policy"), path).not.toContain(SANDBOX);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
function writeToolRecords(projectDir: string): void {
|
||||
mkdirSync(join(projectDir, ".hyperframes", "prepared-assets"), { recursive: true });
|
||||
for (const name of ["app-history.jsonl", "agent-handoff.json", "comments.jsonl"]) {
|
||||
|
||||
Reference in New Issue
Block a user