Cron run-log tests: cover existing directory permission hardening

This commit is contained in:
Vincent Koc
2026-03-06 00:46:10 -05:00
parent a19bcd97b3
commit a3525a2c71

View File

@@ -114,6 +114,28 @@ describe("cron run log", () => {
},
);
it.skipIf(process.platform === "win32")(
"hardens an existing run-log directory to owner-only permissions",
async () => {
await withRunLogDir("openclaw-cron-log-dir-perms-", async (dir) => {
const runDir = path.join(dir, "runs");
const logPath = path.join(runDir, "job-1.jsonl");
await fs.mkdir(runDir, { recursive: true, mode: 0o755 });
await fs.chmod(runDir, 0o755);
await appendCronRunLog(logPath, {
ts: 1,
jobId: "job-1",
action: "finished",
status: "ok",
});
const runDirMode = (await fs.stat(runDir)).mode & 0o777;
expect(runDirMode).toBe(0o700);
});
},
);
it("reads newest entries and filters by jobId", async () => {
await withRunLogDir("openclaw-cron-log-read-", async (dir) => {
const logPathA = path.join(dir, "runs", "a.jsonl");