Files
openbot/scripts/development-state-paths.ts
T
4bd31ab663 fix(scripts): support Windows binaries and directory modes in dev runner (#1215)
* 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>
2026-10-02 11:06:29 +02:00

23 lines
662 B
TypeScript

import { homedir } from "node:os";
import { posix } from "node:path";
export function resolveDevelopmentAppDataRoot(
platform: NodeJS.Platform = process.platform,
environment: NodeJS.ProcessEnv = process.env,
homeDirectory = homedir(),
): string {
if (platform === "darwin") {
return posix.join(homeDirectory, "Library", "Application Support");
}
if (platform === "win32") {
const appData = environment.APPDATA?.trim();
if (!appData) {
throw new Error("APPDATA is not set. OpenBot dev state was not changed.");
}
return appData;
}
return environment.XDG_CONFIG_HOME?.trim() || posix.join(homeDirectory, ".config");
}