An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Allow the Electron default file flag in isolated HTTP map hosts https://github.com/siyuan-note/siyuan/issues/20129
Danielca66d2fe03b5
diff --git a/app/electron/mapHostManager.test.js b/app/electron/mapHostManager.test.jsindex 2ec12ebf52..1845c041cb 100644--- a/app/electron/mapHostManager.test.js+++ b/app/electron/mapHostManager.test.js@@ -301,6 +301,20 @@ test("capability is credential-free and only supports trusted owners with safe passert.equal(s.views.length, 0);});+test("Electron's default file-access switch permits the HTTP map host while file access stays denied", async () => {+ const s = setup();+ s.switches.set("allow-file-access-from-files", "");+ assert.deepEqual(s.handlers["siyuan-map-capability"](s.event()), {version: 1, supported: true});+ assert.deepEqual(s.create(), envelope);+ const ses = s.sessions[0];+ assert.equal((await ses.protocols.file(new Request("file:///etc/passwd"))).status, 403);+ assert.equal(ses.before({url: "file:///etc/passwd", resourceType: "mainFrame"}).cancel, true);+ assert.equal(ses.before({url: "file:///etc/passwd", resourceType: "xhr"}).cancel, true);+ s.owner.mainFrame.url = "file:///app/index.html";+ assert.equal(s.handlers["siyuan-map-capability"](s.event()).supported, false);+ s.manager.destroyAll();+});+test("geometry updates cannot show a map in an unfocused window and focus restores fresh geometry", () => {const s = setup(); s.create(); s.load(); s.reply({type: "bootstrapReady"}); s.reply({type: "ready"});s.win.focused = false; s.win.emit("blur");diff --git a/app/electron/mapHostPolicy.js b/app/electron/mapHostPolicy.jsindex 2dd2bf0381..01ec7e2f28 100644--- a/app/electron/mapHostPolicy.js+++ b/app/electron/mapHostPolicy.js@@ -19,10 +19,12 @@ const providerHosts = Object.freeze({tencent: ["map.qq.com", "apis.map.qq.com", "*.map.qq.com"],baidu: ["api.map.baidu.com", "*.map.bdimg.com", "*.bdimg.com", "*.map.baidu.com"],});+// Electron 默认启用 allow-file-access-from-files;地图仅加载 HTTP(S) 文档,并由独立会话拒绝文件协议。+// 该开关只影响文件来源文档,不应误判为此地图宿主的安全绕过。const unsafeMapSwitches = Object.freeze(["disable-web-security", "allow-running-insecure-content", "disable-site-isolation-for-policy","disable-site-isolation-trials", "no-sandbox", "disable-setuid-sandbox", "disable-seccomp-filter-sandbox",- "single-process", "allow-file-access-from-files", "allow-universal-access-from-files",+ "single-process", "allow-universal-access-from-files","ignore-certificate-errors", "ignore-certificate-errors-spki-list", "ignore-ssl-errors","ignore-ssl-errors-with-hosts", "allow-insecure-localhost",]);diff --git a/app/electron/mapHostPolicy.test.js b/app/electron/mapHostPolicy.test.jsindex b500ce49e4..c55f3ac248 100644--- a/app/electron/mapHostPolicy.test.js+++ b/app/electron/mapHostPolicy.test.js@@ -71,6 +71,7 @@ test("point count is bounded and provider coordinate systems remain consistent",test("map creation fails closed for effective process security bypasses", () => {const commandLine = switches => ({hasSwitch: name => switches.has(name), getSwitchValue: name => switches.get(name)});assert.equal(hasUnsafeMapSwitches(commandLine(new Map())), false);+ assert.equal(hasUnsafeMapSwitches(commandLine(new Map([["allow-file-access-from-files", ""]]))), false);for (const name of unsafeMapSwitches) assert.equal(hasUnsafeMapSwitches(commandLine(new Map([[name, ""]]))), true, name);for (const value of ["IsolateOrigins", "Other, SitePerProcess", "OutOfBlinkCors:trial", "SitePerProcess<Experiment"]) {assert.equal(hasUnsafeMapSwitches(commandLine(new Map([["disable-features", value]]))), true);