Route allow-always through command authorization planner#80922
Route allow-always through command authorization planner#80922jesse-merhi wants to merge 55 commits into
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: not applicable. this is a feature/refactor PR rather than a current-main bug report. The PR body provides terminal proof and the branch adds focused regression coverage for the preserved approval-ID behavior. Real behavior proof Next step before merge Security Review detailsBest possible solution: Land the planner-backed authorization path only after maintainer/security review confirms the command trust boundary and the focused plus broad validation gates are green. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a feature/refactor PR rather than a current-main bug report. The PR body provides terminal proof and the branch adds focused regression coverage for the preserved approval-ID behavior. Is this the best way to solve the issue? Yes, with maintainer review: centralizing POSIX allowlist and allow-always behavior through one planner is a maintainable direction, and this review did not find a discrete blocker in the latest head. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against be166b9ae48d. |
There was a problem hiding this comment.
Pull request overview
Introduces a new internal “command authorization planner” contract and a first-pass implementation that classifies commands into analyzable, prompt-only, or unanalyzable, producing a tree of command units suitable for downstream allowlist/trust evaluation.
Changes:
- Added planner contract types (
CommandAuthorizationPlan, units, tree relationships, and reason enums). - Implemented
planCommandForAuthorization()with dialect handling and conservative prompt-only detection (inline eval, command substitution, Windows wrappers). - Added a corpus-style Vitest suite covering representative argv/POSIX/Windows wrapper/malformed cases.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/infra/command-authorization/types.ts | Defines the planner contract types, tree structure, and reason enums. |
| src/infra/command-authorization/plan.ts | Implements the planner and unit/tree construction logic using existing exec-approvals analyzers. |
| src/infra/command-authorization/index.ts | Exposes the planner entrypoint and exported types. |
| src/infra/command-authorization/corpus.test.ts | Adds corpus tests to lock in planner behavior across common command shapes and risk cases. |
| const source = command ?? argvInput.join(" "); | ||
| const argv = argvInput.map((entry) => entry.trim()).filter((entry) => entry.length > 0); |
| const source = command.trim(); | ||
| if (!source) { | ||
| return unanalyzablePlan(command, "posix-shell", ["empty-command"]); | ||
| } |
| relationship: "wrapper-inline", | ||
| promptOnlyReasons: [reason], | ||
| }); | ||
| return promptOnlyPlan(command, dialect, { kind: "unit", unitId: unit.id }, [unit]); |
| if (executable === "cmd" || executable === "cmd.exe") { | ||
| return { dialect: "windows-cmd", reason: "unsupported-cmd-wrapper" }; | ||
| } | ||
| if (executable === "powershell" || executable === "powershell.exe" || executable === "pwsh") { |
| command: part.part, | ||
| cwd: context.cwd, | ||
| env: context.env, | ||
| platform: context.platform, |
| function unanalyzableFromAnalysis( | ||
| source: string, | ||
| dialect: CommandDialect, | ||
| analysis: ExecCommandAnalysis, | ||
| ): CommandAuthorizationPlan { | ||
| const reason: CommandUnanalyzableReason = | ||
| analysis.reason === "empty command" ? "empty-command" : "malformed-shell"; | ||
| return unanalyzablePlan(source, dialect, [reason]); |
eb63177 to
f95d24b
Compare
76666de to
68a9521
Compare
ecd2f84 to
fe36a33
Compare
Summary
Real Behavior Proof
fnm exec --using 22.21.0 pnpm exec tsx -e '<planner allowlist proof>''/usr/bin/printf' 'hi' | '/usr/bin/wc' '-c'executed through/bin/sh -lcand returned2.sh -c 'echo ok'persisted/bin/echo; a latersh -c 'id > /tmp/openclaw-parser-proof-marker'still hadallowlistSatisfied: false.Verification
fnm exec --using 22.21.0 pnpm test src/infra/command-authorization/corpus.test.ts src/infra/exec-approvals-analysis.test.ts src/infra/exec-approvals-allow-always.test.ts src/infra/exec-approvals-store.test.ts src/infra/exec-approvals-safe-bins.test.ts src/infra/command-analysis/explain.test.ts src/infra/command-analysis/explain.lazy.test.ts src/infra/exec-approvals-parity.test.ts src/agents/bash-tools.exec-host-gateway.test.ts src/node-host/invoke-system-run.test.tsfnm exec --using 22.21.0 pnpm tsgo:corefnm exec --using 22.21.0 pnpm tsgo:core:testfnm exec --using 22.21.0 pnpm check:changed