mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 22:25:24 +00:00
* fix(desktop): stop the renderer choosing the external editor binary or reading the session cookie open-external-editor now launches only the editor saved from a file dialog and refuses to hand executable file types to the OS opener. The unused get-session-cookie and wait-session-cookie channels, which returned the httpOnly jwt, are removed. * fix: validate setting keys before editor authorization
41 lines
974 B
TypeScript
41 lines
974 B
TypeScript
import { createRequire } from "node:module";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
const require = createRequire(import.meta.url);
|
|
const { isLaunchableFileName } = require("../electron/external-editor.cjs") as {
|
|
isLaunchableFileName: (fileName: unknown) => boolean;
|
|
};
|
|
|
|
describe("Electron external editor", () => {
|
|
it("refuses remote file names the OS would run instead of open", () => {
|
|
for (const name of [
|
|
"payload.exe",
|
|
"run.BAT",
|
|
"script.ps1",
|
|
"a.exe. ",
|
|
"a.cmd...",
|
|
"../../evil.vbs",
|
|
"start.command",
|
|
"launch.desktop",
|
|
"install.sh",
|
|
]) {
|
|
expect(isLaunchableFileName(name)).toBe(true);
|
|
}
|
|
});
|
|
|
|
it("opens ordinary text files", () => {
|
|
for (const name of [
|
|
"nginx.conf",
|
|
"README.md",
|
|
"Dockerfile",
|
|
".bashrc",
|
|
"config.json",
|
|
"index.ts",
|
|
"",
|
|
undefined,
|
|
]) {
|
|
expect(isLaunchableFileName(name)).toBe(false);
|
|
}
|
|
});
|
|
});
|