fix: allow cron self-removal in isolated runs#73028
Conversation
Greptile SummaryThis PR adds a narrow server-side allowlist mechanism ( Confidence Score: 4/5Safe to merge; only a minor style inconsistency with tool name normalization was found. All findings are P2. The security model is sound (allowlist is server-controlled, narrowly scoped to
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/cron/isolated-agent/run-executor.ts
Line: 51
Comment:
**Inconsistent tool name normalization**
`resolveCronOwnerOnlyToolAllowlist` normalizes with `.trim().toLowerCase()`, while the rest of the codebase (including `applyOwnerOnlyToolPolicy`) uses `normalizeToolName`, which also applies `TOOL_NAME_ALIASES`. The two paths are currently equivalent for `"cron"` (no alias exists), but using a different normalization function is inconsistent and could silently diverge if an alias were ever added.
Consider using the shared utility for the comparison as well:
```ts
function resolveCronOwnerOnlyToolAllowlist(toolsAllow: string[] | undefined): string[] | undefined {
if (!toolsAllow?.some((toolName) => normalizeToolName(toolName) === "cron")) {
return undefined;
}
return ["cron"];
}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix: allow cron self-removal in isolated..." | Re-trigger Greptile |
| @@ -47,6 +47,13 @@ async function loadCronSubagentRegistryRuntime() { | |||
| return await cronSubagentRegistryRuntimePromise; | |||
| } | |||
|
|
|||
| function resolveCronOwnerOnlyToolAllowlist(toolsAllow: string[] | undefined): string[] | undefined { | |||
| if (!toolsAllow?.some((toolName) => toolName.trim().toLowerCase() === "cron")) { | |||
There was a problem hiding this comment.
Inconsistent tool name normalization
resolveCronOwnerOnlyToolAllowlist normalizes with .trim().toLowerCase(), while the rest of the codebase (including applyOwnerOnlyToolPolicy) uses normalizeToolName, which also applies TOOL_NAME_ALIASES. The two paths are currently equivalent for "cron" (no alias exists), but using a different normalization function is inconsistent and could silently diverge if an alias were ever added.
Consider using the shared utility for the comparison as well:
function resolveCronOwnerOnlyToolAllowlist(toolsAllow: string[] | undefined): string[] | undefined {
if (!toolsAllow?.some((toolName) => normalizeToolName(toolName) === "cron")) {
return undefined;
}
return ["cron"];
}Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cron/isolated-agent/run-executor.ts
Line: 51
Comment:
**Inconsistent tool name normalization**
`resolveCronOwnerOnlyToolAllowlist` normalizes with `.trim().toLowerCase()`, while the rest of the codebase (including `applyOwnerOnlyToolPolicy`) uses `normalizeToolName`, which also applies `TOOL_NAME_ALIASES`. The two paths are currently equivalent for `"cron"` (no alias exists), but using a different normalization function is inconsistent and could silently diverge if an alias were ever added.
Consider using the shared utility for the comparison as well:
```ts
function resolveCronOwnerOnlyToolAllowlist(toolsAllow: string[] | undefined): string[] | undefined {
if (!toolsAllow?.some((toolName) => normalizeToolName(toolName) === "cron")) {
return undefined;
}
return ["cron"];
}
```
How can I resolve this? If you propose a fix, please make it concise.|
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Keep this PR open. The live PR still has the protected Best possible solution: Keep this PR open for maintainer review. The best path is to finish the security review, confirm the normalized What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against fd2625a16252. |
0dda62f to
964bf4d
Compare
Summary
crontool only when the job explicitly allowlists itTests
pnpm vitest run src/cron/isolated-agent/run.owner-auth.test.ts src/agents/tool-policy.test.ts src/agents/pi-tools.create-openclaw-coding-tools.test.tspnpm exec oxfmt --check src/agents/pi-embedded-runner/effective-tool-policy.ts src/agents/pi-embedded-runner/run/attempt.ts src/agents/pi-embedded-runner/run/params.ts src/agents/pi-tools.create-openclaw-coding-tools.test.ts src/agents/pi-tools.ts src/agents/tool-policy.test.ts src/agents/tool-policy.ts src/cron/isolated-agent/run-executor.ts src/cron/isolated-agent/run.owner-auth.test.ts