Repository navigation
fix(cron): scope all-run job names - #79940
HemantSudarshan wants to merge 2 commits into
Conversation
|
Codex review: found issues before merge. Summary Reproducibility: yes. Source inspection reproduces the current-main leak via unfiltered Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Derive the job-name lookup scope from trusted caller/session context, with an explicit admin override if needed, and add a regression proving one read-scoped caller cannot enrich or search another agent's cron job name. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection reproduces the current-main leak via unfiltered Is this the best way to solve the issue? No. Full review comments:
Overall correctness: patch is incorrect Security concerns:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 3f3e94a604c1. Re-review progress:
|
Summary
Fixes #49175.
cron.runswithscope: "all"still returns global run-log rows, but job-name enrichment now uses the same agent-scoped job visibility path ascron.listinstead of reading every job through the unfilteredcron.list()shortcut.Problem summary
cron.runs(scope=all)builtjobNameByIdfromcontext.cron.list({ includeDisabled: true }). That list is not caller/agent filtered, so run-history responses could attach another agent's cron job name to otherwise global run entries.Root cause
The all-scope run-log reader intentionally scans all run logs, but the server method reused an unscoped job list to enrich those entries and to make job names searchable. The leak was in the enrichment map, not in scheduler execution or run-log storage.
Architectural reasoning
context.cron.listPage()for the job-name lookup because it already appliesagentIdfiltering and effective default-agent handling.limit: 200so the enrichment map remains complete for large visible job lists.agentIdonCronRunsParams; when omitted, enrichment defaults to the cron service default agent, then the canonicalmaindefault.cron.runs, scheduling, delivery, cleanup, retry, and background-task behavior unchanged.Testing performed
pnpm test src/gateway/server-methods/cron.runs.test.ts src/gateway/protocol/cron-validators.test.tspnpm exec oxfmt --check --threads=1 CHANGELOG.md src/gateway/protocol/schema/cron.ts src/gateway/protocol/cron-validators.test.ts src/gateway/server-methods/cron.ts src/gateway/server-methods/cron.runs.test.tspnpm tsgo:corepnpm tsgo:core:testpnpm lint:coreOPENCLAW_LOCAL_CHECK=1 OPENCLAW_LOCAL_CHECK_MODE=throttled pnpm check:changedpnpm check:changelog-attributionsgit diff --check upstream/main...HEADReal behavior proof
cron.runs(scope=all)no longer builds its job-name enrichment map from every cron job across all agents.v22.15.0, pnpm10.33.2. The repo warns that Node>=22.16.0is preferred on this machine; the targeted proof below completed.cron.runsserver handler from the source checkout withscope: "all"andagentId: "main"; the command throws if the old unscopedcron.list()path is used and records the actual listing call made by the handler.{ "unscopedListCalls": 0, "listPageCalls": [ { "includeDisabled": true, "agentId": "main", "limit": 200, "offset": 0 } ], "response": { "ok": true, "result": { "entries": [], "total": 0, "offset": 0, "limit": 1, "hasMore": false, "nextOffset": null } } }unscopedListCalls: 0) and used the agent-scoped paginated list path withagentId: "main"; the call returned successfully.src/gateway/server.cron.test.ts -t "writes cron run history"integration test was attempted locally and still fails here because the pre-existing all-scope run-log directory listing path returns no entries under the local fs-safe/root implementation. That failure is independent of this privacy fix; the added regression directly tests the changed handler contract.Risk analysis
Risk is low-to-medium. The changed runtime path is limited to all-scope
cron.runsjob-name enrichment. It does not alter run execution, scheduler concurrency, cleanup, delivery, retries, or job-specific run-history reads. The main compatibility change is intentionally privacy-preserving: callers still receive all-scope run entries, but job names are only attached for the requested/default agent scope.Backward compatibility
Additive protocol change:
CronRunsParamsnow accepts optionalagentId. Existingcron.runscallers remain valid.