Q117: commands run in an allowlisted environment, and records and approvals say host isolation is advisory
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d67996fd25
commit
cb1a4be167
10 files changed
+103
-6
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { mkdtempSync, readFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { homedir, tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import { BoundedOutput, formatCommandResult, runCommand } from "../../src/main/services/workspace-command";
|
||||
@@ -75,3 +75,20 @@ describe("command results", () => {
|
||||
expect(formatCommandResult(null, null, "")).toBe("ERROR: the command ended without an exit code; treat it as failed.\n(no output)");
|
||||
});
|
||||
});
|
||||
|
||||
describe("the environment a command runs in", () => {
|
||||
test("a command sees no inherited secrets and a home of its own, while PATH still finds tools", async () => {
|
||||
const root = mkdtempSync(join(tmpdir(), "ac-env-"));
|
||||
process.env.AGENTCOMPANY_TEST_SECRET = "sk-should-not-leak";
|
||||
try {
|
||||
const output = await runCommand(root, "node -e \"console.log(process.env.AGENTCOMPANY_TEST_SECRET ?? 'none'); console.log(require('os').homedir())\"");
|
||||
const [code, secret, home] = output.split(/\r?\n/);
|
||||
expect(code).toBe("exit code 0");
|
||||
expect(secret).toBe("none");
|
||||
expect(home).not.toBe(homedir());
|
||||
expect(home).toContain("agentcompany-home-");
|
||||
} finally {
|
||||
delete process.env.AGENTCOMPANY_TEST_SECRET;
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user