mirror of
https://github.com/nightly-labs/openbot.git
synced 2026-11-26 02:29:31 +08:00
* fix(scripts): support Windows binaries and directory modes in dev runner * fix(scripts): resolve effective owner without getuid on win32 * fix(scripts): address review feedback on Windows dev runner * Make the Windows dev registry checks fail closed - Stop when the registry owner cannot be read. Compare SIDs in one PowerShell call, so localized account names do not cause a refusal. - Ignore children of a process that reused a dead leader pid. - Show netstat on Windows in place of lsof. - Import cliSpawnTarget directly and remove the dead APPDATA copy. - Restore the comments that the earlier change cut or moved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Check write access on Windows and quote batch arguments - Reject a Windows registry directory that grants write rights to an account other than this user, Administrators or SYSTEM, as the POSIX mode check does. Read the owner and the ACL in one PowerShell call. - Quote each argument that cliSpawnTarget passes through cmd.exe to a .cmd or .bat wrapper, so a space, a quote, & or % stays in its argument. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Count inherit-only write entries in the Windows registry check A registry record gets its permissions from the inherit-only entries of its directory, so an account with write access to new files only could still replace a record. Count these entries too. Trust CREATOR OWNER, because this user creates every record. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Sniezka1927 <dygons14@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { spawn } from "node:child_process";
|
|
import { dirname } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { createOpenBotLogger } from "@openbot/logging";
|
|
import { cliSpawnTarget } from "../src/backend/cli";
|
|
import { withoutElectronRuntimeFlags } from "./electron-spawn-env";
|
|
import { resolvePackageBin } from "./package-bin";
|
|
|
|
const logger = createOpenBotLogger("preview");
|
|
|
|
const projectRoot = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
const executable = resolvePackageBin(projectRoot, "electron-vite");
|
|
const target = cliSpawnTarget(executable, ["preview", ...process.argv.slice(2)]);
|
|
const child = spawn(target.command, target.args, {
|
|
cwd: projectRoot,
|
|
// The parent shell may run inside an Electron harness with
|
|
// ELECTRON_RUN_AS_NODE=1, which would make the spawned Electron run as
|
|
// plain Node instead of opening the preview app.
|
|
env: { ...withoutElectronRuntimeFlags(process.env), OPENBOT_APP_VARIANT: "preview" },
|
|
stdio: "inherit",
|
|
shell: false,
|
|
windowsVerbatimArguments: target.windowsVerbatimArguments,
|
|
});
|
|
|
|
child.once("error", (error) => {
|
|
logger.error("Could not start electron-vite preview:", error.message);
|
|
process.exitCode = 1;
|
|
});
|
|
child.once("exit", (code, signal) => {
|
|
if (signal) {
|
|
process.exitCode = 1;
|
|
return;
|
|
}
|
|
process.exitCode = code ?? 0;
|
|
});
|