дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 17:21:13 +02:00
fix(security): close the findings of GHSA-442p-gxfg-qxv9
- Restricted Mode git: reads run without a signature verifier, hooks (including config-defined ones), an external diff, filters or a lazy fetch, also inside submodules; every repository and every git starts restricted until the project is trusted. - project.write and plugin quick fixes cannot reach git's own files under any spelling or through links; project.write is a high-risk grant. - Built-in web server: each served root has its own port and token; a file outside the project is served with its folder minus dot names, or alone when that folder is the home folder or above it; no fixed port. - Images, references, Markdown links and language-server links reach no network share other than the one already open. - Marketplace: entries whose id or version no manifest may carry are dropped; an index read over the network names nothing on this machine; network reads are bounded in size and time. - Agent replies load remote images on a click; the Markdown preview and Mermaid configuration no longer fetch from other hosts.
Цей коміт міститься в:
1 джерело
8b179992e8
коміт
a497178b3e
53 files changed
+3206
-243
No files matched your search
@@ -349,6 +349,7 @@
|
||||
"Listening for Xdebug on port {port}": "Listening for Xdebug on port {port}",
|
||||
"Port {port} is already in use: another IDE or debug session may be listening on it. Stop it or choose another port.": "Port {port} is already in use: another IDE or debug session may be listening on it. Stop it or choose another port.",
|
||||
"Unable to load image: {path}": "Unable to load image: {path}",
|
||||
"Load image from {host}": "Load image from {host}",
|
||||
"Updates": "Updates",
|
||||
"Update source": "Update source",
|
||||
"Current version": "Current version",
|
||||
|
||||
@@ -6820,6 +6820,7 @@
|
||||
"Stage and Retry": "暂存并重试",
|
||||
"Show Files": "显示文件",
|
||||
"Unable to load image: {path}": "无法加载图片:{path}",
|
||||
"Load image from {host}": "加载来自 {host} 的图片",
|
||||
"Updates": "更新",
|
||||
"Update source": "更新源",
|
||||
"Current version": "当前版本",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { ipcPath } from "./paths";
|
||||
import { ipcPath, onOtherShare, opensOtherShare } from "./paths";
|
||||
|
||||
const raw = String.raw;
|
||||
const APPDATA = raw`C:\Users\me\AppData\Roaming\ai.l0ng.openidea`;
|
||||
@@ -22,3 +22,57 @@ describe("ipcPath", () => {
|
||||
expect(ipcPath(raw`/home/me/a\b.txt`)).toBe(raw`/home/me/a\b.txt`);
|
||||
});
|
||||
});
|
||||
|
||||
describe("onOtherShare", () => {
|
||||
it("is true for a share the base is not on", () => {
|
||||
for (const base of ["C:/repo/a.md", "", "//nas/work/a.md", "//evil/other/a.md", "//evil"]) {
|
||||
expect(onOtherShare("//evil/share/a.png", base), base).toBe(true);
|
||||
expect(onOtherShare(raw`\\evil\share\a.png`, base), base).toBe(true);
|
||||
}
|
||||
// A server alone, and spellings with no server to compare.
|
||||
for (const path of ["//evil", "//evil/", raw`/\\evil/share/a.png`]) {
|
||||
expect(onOtherShare(path, "//evil/share/a.md"), path).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
// A project on a share gets its paths from the host as `//?/UNC/server/share/…`.
|
||||
it("reads the server and share of a device path", () => {
|
||||
const base = "//?/UNC/nas/work/app/a.md";
|
||||
expect(onOtherShare("//?/UNC/evil/share/a.png", base)).toBe(true);
|
||||
expect(onOtherShare("//?/UNC/nas/private/a.png", base)).toBe(true);
|
||||
expect(onOtherShare("//evil/share/a.png", base)).toBe(true);
|
||||
expect(onOtherShare("//?/UNC", base)).toBe(true);
|
||||
expect(onOtherShare("//?/C:/a.png", "//?/C:/a.md")).toBe(true);
|
||||
expect(onOtherShare("//?/unc/NAS/Work/lib/a.png", base)).toBe(false);
|
||||
expect(onOtherShare("//nas/work/lib/a.png", base)).toBe(false);
|
||||
expect(onOtherShare("//?/UNC/nas/work/lib/a.png", "//nas/work/app/a.md")).toBe(false);
|
||||
});
|
||||
|
||||
it("is false on the base's own share and off any share", () => {
|
||||
expect(onOtherShare("//NAS/Work/lib/a.png", "//nas/work/app/a.md")).toBe(false);
|
||||
expect(onOtherShare(raw`\\nas\work\lib\a.png`, "//nas/work/app/a.md")).toBe(false);
|
||||
expect(onOtherShare("C:/repo/a.png", "//nas/work/app/a.md")).toBe(false);
|
||||
expect(onOtherShare("/abs/a.png", "C:/repo/a.md")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("opensOtherShare", () => {
|
||||
it("is true for a share the text names itself, in any mix of slashes", () => {
|
||||
for (const written of ["//evil/share/a.png", raw`\\evil\share\a.png`, raw`/\evil/share/a.png`, raw`\/evil/a.png`]) {
|
||||
expect(opensOtherShare(written, written, "C:/repo"), written).toBe(true);
|
||||
expect(opensOtherShare(written, written, "//nas/work"), written).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("is true for a share that only appears once the path is resolved", () => {
|
||||
expect(opensOtherShare(raw`/\evil/share/a.png`, raw`\evil/share/a.png`, "")).toBe(true);
|
||||
expect(opensOtherShare(raw`/\evil/share/a.png`, raw`../\evil/share/a.png`, "/guide.md")).toBe(true);
|
||||
expect(opensOtherShare("//evil/share/a.png", "a.png", "//nas/work")).toBe(true);
|
||||
});
|
||||
|
||||
it("is false on a local drive and on the share the text is on", () => {
|
||||
expect(opensOtherShare("C:/repo/docs/a.png", "docs/a.png", "C:/repo")).toBe(false);
|
||||
expect(opensOtherShare("/abs/a.png", "/abs/a.png", "C:/repo")).toBe(false);
|
||||
expect(opensOtherShare("//nas/work/docs/a.png", "docs/a.png", "//nas/work")).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -21,6 +21,39 @@ export function ipcPath(p: string): string {
|
||||
return DRIVE.test(path) || NETWORK.test(path) ? path.replace(/\\/g, "/") : path;
|
||||
}
|
||||
|
||||
const SHARE = /^[\\/]{2}/;
|
||||
const SHARE_NAME = /^[\\/]{2}(?:\?[\\/]UNC[\\/])?([^\\/]+)[\\/]([^\\/]+)/i;
|
||||
|
||||
/**
|
||||
* `server/share` of a path on a network share, in lower case; null for any other path. The
|
||||
* host hands out a share's paths as `//?/UNC/server/share/…`, the dialogs as `//server/share/…`.
|
||||
*/
|
||||
function shareOf(path: string): string | null {
|
||||
const m = SHARE_NAME.exec(path);
|
||||
// Any other device path (`//?/C:/…`, `//./…`) names no server to compare.
|
||||
return m && m[1] !== "?" && m[1] !== "." ? `${m[1]}/${m[2]}`.toLowerCase() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether `path` is on a network share that `base` is not on. Windows reads `//server/share`,
|
||||
* `\\server\share` and mixes of the two as a share, and opening one signs in to its server
|
||||
* with the user's credentials: a path that text someone else wrote leads to is followed to no
|
||||
* share but the one that text is on.
|
||||
*/
|
||||
export function onOtherShare(path: string, base: string): boolean {
|
||||
if (!SHARE.test(path)) return false;
|
||||
const share = shareOf(path);
|
||||
return share === null || share !== shareOf(base);
|
||||
}
|
||||
|
||||
/**
|
||||
* `onOtherShare` for a path resolved against `base`, the folder or file of the text naming
|
||||
* it: also true when that text spells a share itself (`written`, decoded).
|
||||
*/
|
||||
export function opensOtherShare(path: string, written: string, base: string): boolean {
|
||||
return SHARE.test(written) || onOtherShare(path, base);
|
||||
}
|
||||
|
||||
/** True when `path` equals `ancestor` or lies below it. */
|
||||
export function isSameOrInside(path: string, ancestor: string): boolean {
|
||||
path = ipcPath(path);
|
||||
|
||||
Reference in new issue
Заблокувати користувача