mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
The app's CSP now includes `frame-ancestors 'none'`, so no page (for example a project's HTML in the built-in preview) can embed the IDE's own pages in a frame. Notebook HTML output, plugin views (srcdoc frames) and the built-in HTML preview still render in a debug bundle that serves the CSP. Co-authored-by: rohitdanda <10144914+rohitdanda@users.noreply.github.com>
22 lines
782 B
TypeScript
22 lines
782 B
TypeScript
// @vitest-environment node
|
|
import { readFileSync } from "node:fs";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
/** The app's CSP, which Tauri sends as a response header with every HTML page it serves. */
|
|
function directives(): Map<string, string[]> {
|
|
const conf = JSON.parse(readFileSync("src-tauri/tauri.conf.json", "utf8"));
|
|
const csp: string = conf.app.security.csp;
|
|
const map = new Map<string, string[]>();
|
|
for (const part of csp.split(";")) {
|
|
const [name, ...sources] = part.trim().split(/\s+/);
|
|
if (name) map.set(name.toLowerCase(), sources);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
describe("app content security policy", () => {
|
|
it("does not let any page embed the app's own pages", () => {
|
|
expect(directives().get("frame-ancestors")).toEqual(["'none'"]);
|
|
});
|
|
});
|