mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 19:23:24 +00:00
refactor(process): give POSIX PATH search order one owner (#10891)
* refactor(process): give POSIX PATH search order one owner Program lookup, the packet-tool locator and Jadx's Java lookup each split PATH and resolved empty and relative entries themselves. They now take the candidates from posixPathCandidates in src/process/executableSearch and keep only their own probe and failure reporting. A counted architecture guard keeps new PATH splits from returning; the remaining Windows and Ghidra searches are baselined. * refactor(process): move the colon-split PATH searches onto the search owner REA's launcher-alias lookup and Ghidra's macOS Java lookup split PATH on ":" and skipped relative entries themselves; they now use posixPathCandidates with relativeEntries: "skip", and the guard counts colon splits of PATH as well. * fix(process): produce PATH candidates lazily so an unused entry cannot fail an earlier match * refactor(process): give Windows PATH/PATHEXT search order the executable search owner (#10916) * refactor(process): give Windows PATH/PATHEXT search order the executable search owner * fix(process): keep later PATH entries searchable after a stray quote or a removed working directory * fix(reverse): refuse a Windows objdump or Rizin command that PATH does not find (#10953) * fix(reverse): refuse an objdump or Rizin command Windows PATH does not find instead of launching the bare name * fix(reverse): report a Windows lookup refusal after cancellation and to capability discovery * fix(desktop): search a Windows host's PATH as Windows does when doctor looks up a program programOnPath sent every host through the POSIX PATH search, so on Windows a relative PATH entry reached absoluteCallerPath with platform linux and the Windows working directory, which resolved against itself until the stack overflowed. programOnPath now searches PATH and PATHEXT through windowsPathCandidates on a Windows host, and absoluteCallerPath refuses a non-POSIX working directory with a TypeError instead of recursing.
This commit is contained in:
1 parent
659772952d
commit
422cff00ab
23 files changed
+912
-330
No files matched your search
@@ -2,6 +2,8 @@ import { win32 } from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { err, ok } from "../../src/domain/result.js";
|
||||
import { RIZIN_PROVIDER_IDENTITY } from "../../src/rizin/RizinProviderIdentity.js";
|
||||
import { resolveWindowsProviderExecutable } from "../../src/composition/resolveWindowsProviderExecutable.js";
|
||||
import { createReverseEngineeringCommandPort } from "../../src/composition/reverseEngineering.js";
|
||||
|
||||
@@ -29,7 +31,7 @@ describe("resolveWindowsProviderExecutable", () => {
|
||||
},
|
||||
windowsLookup(cwd, [expected]),
|
||||
),
|
||||
).toBe(expected);
|
||||
).toEqual(ok(expected));
|
||||
});
|
||||
|
||||
it("resolves a relative configured path against the caller's Windows CWD", () => {
|
||||
@@ -39,7 +41,7 @@ describe("resolveWindowsProviderExecutable", () => {
|
||||
{},
|
||||
windowsLookup("D:\\analysis", []),
|
||||
),
|
||||
).toBe("D:\\analysis\\tools\\objdump.exe");
|
||||
).toEqual(ok("D:\\analysis\\tools\\objdump.exe"));
|
||||
});
|
||||
|
||||
it("resolves relative PATH hits to absolute drive paths", () => {
|
||||
@@ -50,7 +52,7 @@ describe("resolveWindowsProviderExecutable", () => {
|
||||
{ PATH: ".\\bin", PATHEXT: ".EXE" },
|
||||
windowsLookup("D:\\analysis", [expected]),
|
||||
),
|
||||
).toBe(expected);
|
||||
).toEqual(ok(expected));
|
||||
});
|
||||
|
||||
it("skips script extensions and preserves a caller-selected absolute path", () => {
|
||||
@@ -62,24 +64,31 @@ describe("resolveWindowsProviderExecutable", () => {
|
||||
{ PATH: "C:\\tools", PATHEXT: ".CMD;.BAT;.EXE;.COM" },
|
||||
windowsLookup("C:\\work", ["C:\\tools\\rizin.CMD", expected]),
|
||||
),
|
||||
).toBe(expected);
|
||||
).toEqual(ok(expected));
|
||||
expect(
|
||||
resolveWindowsProviderExecutable(
|
||||
selected,
|
||||
{},
|
||||
windowsLookup("D:\\work", []),
|
||||
),
|
||||
).toBe(selected);
|
||||
).toEqual(ok(selected));
|
||||
});
|
||||
|
||||
it("keeps unresolved bare command names unchanged", () => {
|
||||
it("refuses an unresolved bare name instead of letting Windows search the current directory", () => {
|
||||
expect(
|
||||
resolveWindowsProviderExecutable(
|
||||
"missing-tool",
|
||||
{ PATH: ".\\tools", PATHEXT: ".EXE" },
|
||||
windowsLookup("C:\\work", []),
|
||||
),
|
||||
).toBe("missing-tool");
|
||||
).toEqual(err({ kind: "not_found" }));
|
||||
expect(
|
||||
resolveWindowsProviderExecutable(
|
||||
"missing-tool",
|
||||
{ PATH: "C:\\tools", PATHEXT: ".EXE;C:\\bad" },
|
||||
windowsLookup("C:\\work", []),
|
||||
),
|
||||
).toEqual(err({ kind: "invalid_extension", extension: "C:\\bad" }));
|
||||
});
|
||||
|
||||
it("passes an absolute selected command through provider composition", () => {
|
||||
@@ -88,8 +97,25 @@ describe("resolveWindowsProviderExecutable", () => {
|
||||
"win32",
|
||||
);
|
||||
expect(
|
||||
commands.objdump({ path: "artifact", operation: "file_headers" })
|
||||
.executable,
|
||||
).toBe("C:\\tools\\objdump.exe");
|
||||
commands.objdump({ path: "artifact", operation: "file_headers" }),
|
||||
).toMatchObject({
|
||||
ok: true,
|
||||
value: { executable: "C:\\tools\\objdump.exe" },
|
||||
});
|
||||
});
|
||||
|
||||
it("reports a bare command missing from PATH as unavailable before launch", () => {
|
||||
const commands = createReverseEngineeringCommandPort(
|
||||
{ PATH: "", REA_RIZIN_COMMAND: "rea-missing-rizin" },
|
||||
"win32",
|
||||
);
|
||||
expect(commands.rizin({ path: "artifact", command: "i" })).toMatchObject({
|
||||
ok: false,
|
||||
error: {
|
||||
identity: { id: RIZIN_PROVIDER_IDENTITY.id },
|
||||
command: "rea-missing-rizin",
|
||||
reason: { kind: "not_found" },
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user