



























@@ -626,4 +626,35 @@ describe("cron run log", () => {
626626}
627627});
628628});
629+630+it("normalizes the jobId on write so the write/read roundtrip is symmetric", async () => {
631+await withRunLogDir("openclaw-cron-log-roundtrip-", async (dir) => {
632+const storePath = storePathForDir(dir);
633+await appendCronRunLog({
634+ storePath,
635+entry: { ts: 1000, jobId: " spaced-job ", action: "finished", status: "ok" },
636+});
637+// Reads trim before querying, so the written row must be found under both the
638+// trimmed and the original whitespace-padded jobId, and stored normalized.
639+expect(readCronRunLogEntriesSync({ storePath, jobId: "spaced-job" })).toHaveLength(1);
640+expect(readCronRunLogEntriesSync({ storePath, jobId: " spaced-job " })).toHaveLength(1);
641+expect(readCronRunLogEntriesSync({ storePath, jobId: "spaced-job" })[0]?.jobId).toBe(
642+"spaced-job",
643+);
644+});
645+});
646+647+it("rejects unsafe job ids on write the same way reads do", async () => {
648+await withRunLogDir("openclaw-cron-log-write-reject-", async (dir) => {
649+const storePath = storePathForDir(dir);
650+for (const jobId of ["nested/job", "..\\job", " "]) {
651+await expect(
652+appendCronRunLog({
653+ storePath,
654+entry: { ts: 1000, jobId, action: "finished", status: "ok" },
655+}),
656+).rejects.toThrow(/invalid cron run log job id/i);
657+}
658+});
659+});
629660});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。