























@@ -545,7 +545,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
545545546546for (const testCase of approvedEnvShellWrapperCases) {
547547it.runIf(process.platform !== "win32")(testCase.name, async () => {
548-const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-approved-wrapper-"));
548+const tmp = createFixtureDir("openclaw-approved-wrapper-");
549549const marker = path.join(tmp, "marker");
550550const attackerScript = path.join(tmp, "sh");
551551fs.writeFileSync(attackerScript, "#!/bin/sh\necho exploited > marker\n");
@@ -742,7 +742,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
742742it.runIf(process.platform !== "win32")(
743743"denies approval-based execution when cwd is a symlink",
744744async () => {
745-const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-approval-cwd-link-"));
745+const tmp = createFixtureDir("openclaw-approval-cwd-link-");
746746const safeDir = path.join(tmp, "safe");
747747const linkDir = path.join(tmp, "cwd-link");
748748const script = path.join(safeDir, "run.sh");
@@ -770,7 +770,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
770770it.runIf(process.platform !== "win32")(
771771"denies approval-based execution when cwd contains a symlink parent component",
772772async () => {
773-const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-approval-cwd-parent-link-"));
773+const tmp = createFixtureDir("openclaw-approval-cwd-parent-link-");
774774const safeRoot = path.join(tmp, "safe-root");
775775const safeSub = path.join(safeRoot, "sub");
776776const linkRoot = path.join(tmp, "approved-link");
@@ -794,7 +794,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
794794);
795795796796it("uses canonical executable path for approval-based relative command execution", async () => {
797-const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-approval-cwd-real-"));
797+const tmp = createFixtureDir("openclaw-approval-cwd-real-");
798798const script = path.join(tmp, "run.sh");
799799fs.writeFileSync(script, "#!/bin/sh\necho SAFE\n");
800800fs.chmodSync(script, 0o755);
@@ -828,8 +828,8 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
828828});
829829830830it("denies approval-based execution when cwd identity drifts before execution", async () => {
831-const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-approval-cwd-drift-"));
832-const fallback = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-approval-cwd-drift-alt-"));
831+const tmp = createFixtureDir("openclaw-approval-cwd-drift-");
832+const fallback = createFixtureDir("openclaw-approval-cwd-drift-alt-");
833833const script = path.join(tmp, "run.sh");
834834fs.writeFileSync(script, "#!/bin/sh\necho SAFE\n");
835835fs.chmodSync(script, 0o755);
@@ -868,7 +868,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
868868});
869869870870it("denies approval-based execution when a script operand changes after approval", async () => {
871-const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-approval-script-drift-"));
871+const tmp = createFixtureDir("openclaw-approval-script-drift-");
872872const fixture = createMutableScriptOperandFixture(tmp);
873873fs.writeFileSync(fixture.scriptPath, fixture.initialBody);
874874if (process.platform !== "win32") {
@@ -907,7 +907,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
907907});
908908909909it("keeps approved shell script execution working when the script is unchanged", async () => {
910-const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-approval-script-stable-"));
910+const tmp = createFixtureDir("openclaw-approval-script-stable-");
911911const fixture = createMutableScriptOperandFixture(tmp);
912912fs.writeFileSync(fixture.scriptPath, fixture.initialBody);
913913if (process.platform !== "win32") {
@@ -946,9 +946,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
946946await withFakeRuntimeOnPath({
947947 runtime,
948948run: async () => {
949-const tmp = fs.mkdtempSync(
950-path.join(os.tmpdir(), `openclaw-approval-${runtime}-script-drift-`),
951-);
949+const tmp = createFixtureDir(`openclaw-approval-${runtime}-script-drift-`);
952950const fixture = createRuntimeScriptOperandFixture({ tmp, runtime });
953951fs.writeFileSync(fixture.scriptPath, fixture.initialBody);
954952try {
@@ -981,9 +979,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
981979} finally {
982980fs.rmSync(tmp, { recursive: true, force: true });
983981}
984-const stableTmp = fs.mkdtempSync(
985-path.join(os.tmpdir(), `openclaw-approval-${runtime}-script-stable-`),
986-);
982+const stableTmp = createFixtureDir(`openclaw-approval-${runtime}-script-stable-`);
987983const stableFixture = createRuntimeScriptOperandFixture({ tmp: stableTmp, runtime });
988984fs.writeFileSync(stableFixture.scriptPath, stableFixture.initialBody);
989985try {
@@ -1021,9 +1017,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
10211017await withFakeRuntimeOnPath({
10221018runtime: "tsx",
10231019run: async () => {
1024-const tmp = fs.mkdtempSync(
1025-path.join(os.tmpdir(), "openclaw-approval-tsx-missing-binding-"),
1026-);
1020+const tmp = createFixtureDir("openclaw-approval-tsx-missing-binding-");
10271021const fixture = createRuntimeScriptOperandFixture({ tmp, runtime: "tsx" });
10281022fs.writeFileSync(fixture.scriptPath, fixture.initialBody);
10291023try {
@@ -1432,7 +1426,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
14321426approvals: createAllowlistOnMissApprovals(),
14331427run: async () => {
14341428for (const testCase of cases) {
1435-const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-inline-eval-bin-"));
1429+const tempDir = createFixtureDir("openclaw-inline-eval-bin-");
14361430try {
14371431const executablePath = createTempExecutable({
14381432dir: tempDir,
@@ -1474,7 +1468,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
14741468await withTempApprovalsHome({
14751469approvals: createAllowlistOnMissApprovals(),
14761470run: async () => {
1477-const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-inline-eval-awk-"));
1471+const tempDir = createFixtureDir("openclaw-inline-eval-awk-");
14781472try {
14791473const executablePath = createTempExecutable({
14801474dir: tempDir,
@@ -1531,7 +1525,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
15311525await withTempApprovalsHome({
15321526approvals: createAllowlistOnMissApprovals(),
15331527run: async () => {
1534-const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-inline-eval-make-"));
1528+const tempDir = createFixtureDir("openclaw-inline-eval-make-");
15351529try {
15361530const executablePath = createTempExecutable({
15371531dir: tempDir,
@@ -1577,7 +1571,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
15771571it.runIf(process.platform !== "win32")(
15781572"auto-runs allowlisted inner scripts through transport shell wrappers",
15791573async () => {
1580-const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-shell-wrapper-inner-"));
1574+const tempDir = createFixtureDir("openclaw-shell-wrapper-inner-");
15811575try {
15821576const scriptsDir = path.join(tempDir, "scripts");
15831577fs.mkdirSync(scriptsDir, { recursive: true });
@@ -1618,7 +1612,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
1618161216191613it("keeps cmd.exe transport wrappers approval-gated on Windows", async () => {
16201614const platformSpy = vi.spyOn(process, "platform", "get").mockReturnValue("win32");
1621-const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-cmd-wrapper-allow-"));
1615+const tempDir = createFixtureDir("openclaw-cmd-wrapper-allow-");
16221616try {
16231617const scriptPath = path.join(tempDir, "check_mail.cmd");
16241618fs.writeFileSync(scriptPath, "@echo off\r\necho ok\r\n");
@@ -1672,7 +1666,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
16721666},
16731667])("$name", async ({ command }) => {
16741668const platformSpy = vi.spyOn(process, "platform", "get").mockReturnValue("win32");
1675-const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-env-cmd-wrapper-allow-"));
1669+const tempDir = createFixtureDir("openclaw-env-cmd-wrapper-allow-");
16761670try {
16771671const scriptPath = path.join(tempDir, "check_mail.cmd");
16781672fs.writeFileSync(scriptPath, "@echo off\r\necho ok\r\n");
@@ -1724,7 +1718,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
17241718return;
17251719}
172617201727-const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-shell-wrapper-allow-"));
1721+const tempDir = createFixtureDir("openclaw-shell-wrapper-allow-");
17281722try {
17291723const prepared = buildSystemRunApprovalPlan({
17301724command: ["/bin/sh", "-lc", "cd ."],
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。