fix: harden PTY events and configured roots

This commit is contained in:
N0zoM1z0
2026-07-14 15:21:39 +08:00
parent 2575b30dfc
commit 31b40f39e4
14 changed files with 180 additions and 40 deletions
+12 -1
View File
@@ -1,4 +1,4 @@
import { chmod, mkdtemp, stat } from "node:fs/promises";
import { chmod, mkdtemp, stat, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -62,6 +62,17 @@ describe("project permission store", () => {
});
});
it("classifies malformed JSON as an invalid store", async () => {
const project = await mkdtemp(join(tmpdir(), "rea-policy-invalid-"));
const path = join(project, "permissions.json");
await writeFile(path, "{", { mode: 0o600 });
expect(await readProjectPermissionStore(path, project)).toMatchObject({
ok: false,
error: { reason: "invalid" },
});
});
it("serializes concurrent grant revocations without losing an update", async () => {
const project = await mkdtemp(join(tmpdir(), "rea-policy-revoke-"));
const path = join(project, ".rea", "permissions.json");