refactor(exec): split host flows and harden safe-bin trust

This commit is contained in:
Peter Steinberger
2026-02-19 14:21:07 +01:00
parent b45bb6801c
commit fec48a5006
10 changed files with 834 additions and 616 deletions

View File

@@ -54,4 +54,18 @@ describe("exec safe bin trust", () => {
}),
).toBe(false);
});
it("uses startup PATH snapshot when pathEnv is omitted", () => {
const originalPath = process.env.PATH;
const injected = `/tmp/openclaw-path-injected-${Date.now()}`;
const initial = getTrustedSafeBinDirs({ refresh: true });
try {
process.env.PATH = `${injected}${path.delimiter}${originalPath ?? ""}`;
const refreshed = getTrustedSafeBinDirs({ refresh: true });
expect(refreshed.has(path.resolve(injected))).toBe(false);
expect([...refreshed].toSorted()).toEqual([...initial].toSorted());
} finally {
process.env.PATH = originalPath;
}
});
});