feat: harden approval and management tool controls - #99
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughMiftah adds explicit approval mechanisms, fail-closed human confirmation, delegated-agent gating, centralized management-tool descriptors and annotations, Claude Code permission guidance, and stricter GitHub multi-profile preset defaults. ChangesSecurity and onboarding controls
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Poem
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
tests/profile-leases-docs-contract.test.ts (1)
2-3: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winPreserve Unreleased-section scoping in both changelog contract tests.
Both replacements scan the entire changelog, allowing historical entries to satisfy assertions intended to validate the current release notes.
tests/profile-leases-docs-contract.test.ts#L2-L3,L35-L35: restore section-scoped extraction or constrain the[#28]match to## [Unreleased].tests/profile-runtime-isolation-docs-contract.test.ts#L2-L2,L35-L35: restore section-scoped extraction or constrain the[#29]match to## [Unreleased].🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/profile-leases-docs-contract.test.ts` around lines 2 - 3, Update both changelog contract tests, tests/profile-leases-docs-contract.test.ts lines 2-3 and 35, and tests/profile-runtime-isolation-docs-contract.test.ts lines 2 and 35, so their assertions inspect only the ## [Unreleased] section. Restore section-scoped extraction or constrain the profile leases [`#28`] and profile runtime isolation [`#29`] matches to that section; do not allow historical changelog entries to satisfy either test.src/approvals/approval-store.ts (1)
106-119: 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy liftMake the approval mechanism explicit and immutable.
request()defaults to"delegated-agent"while the bearer-safety callback defaults to accepting any bearer. A caller that omitsmechanismtherefore silently creates delegated-agent authorization, contrary to the explicit opt-in contract. Pending-record reuse also ignoresmechanism, so the same binding can be requested under a different mechanism while the stored summary retains the original one. Require the mechanism and reject mismatched reuse (or bind it through the consume path) to prevent authorization and audit inconsistencies.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/approvals/approval-store.ts` around lines 106 - 119, The request method must require an explicit, immutable approval mechanism instead of defaulting to "delegated-agent". Remove the mechanism default in request, and ensure pending-record reuse only returns a token when the stored mechanism matches the requested mechanism; otherwise reject or proceed through a mechanism-bound creation/consume path so the stored summary and authorization remain consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/mcp/server/management-tools.ts`:
- Around line 190-201: Update the miftah_list_approvals tool definition to
classify its non-mutating approval metadata listing as observational: change
interaction to observational, set readOnlyHint to true, destructiveHint to
false, and idempotentHint to true; leave its availability and other fields
unchanged.
In `@src/mcp/server/miftah-server.ts`:
- Around line 1696-1701: Update auditStatus() to classify MiftahError code
APPROVAL_DELEGATION_DISABLED as an audit denial rather than a failure,
preserving the existing handling for other error codes and the
assertDelegatedAgentApprovalEnabled() behavior.
---
Outside diff comments:
In `@src/approvals/approval-store.ts`:
- Around line 106-119: The request method must require an explicit, immutable
approval mechanism instead of defaulting to "delegated-agent". Remove the
mechanism default in request, and ensure pending-record reuse only returns a
token when the stored mechanism matches the requested mechanism; otherwise
reject or proceed through a mechanism-bound creation/consume path so the stored
summary and authorization remain consistent.
In `@tests/profile-leases-docs-contract.test.ts`:
- Around line 2-3: Update both changelog contract tests,
tests/profile-leases-docs-contract.test.ts lines 2-3 and 35, and
tests/profile-runtime-isolation-docs-contract.test.ts lines 2 and 35, so their
assertions inspect only the ## [Unreleased] section. Restore section-scoped
extraction or constrain the profile leases [`#28`] and profile runtime isolation
[`#29`] matches to that section; do not allow historical changelog entries to
satisfy either test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 5d44142a-9c2a-417e-80ab-01f925efb8c2
📒 Files selected for processing (37)
CHANGELOG.mdREADME.mddocs/architecture.mddocs/cli.mddocs/config.mddocs/library-api.mddocs/presets-and-clients.mddocs/security.mddocs/threat-model.mdexamples/github.miftah.jsonsrc/approvals/approval-store.tssrc/audit/audit-trail.tssrc/audit/audit-types.tssrc/cli/client-snippets.tssrc/cli/exit-codes.tssrc/cli/init.tssrc/config/presets.tssrc/config/schema.tssrc/config/types.tssrc/mcp/server/management-tools.tssrc/mcp/server/miftah-server.tssrc/utils/errors.tstests/approval-fallback.test.tstests/audit-outcomes.test.tstests/cli-exit-codes.test.tstests/client-snippets.test.tstests/config-schema-contract.test.tstests/identity-docs-contract.test.tstests/init-command.test.tstests/management-tools-contract.test.tstests/mcp-wrapper.test.tstests/preset-docs-contract.test.tstests/presets.test.tstests/profile-leases-docs-contract.test.tstests/profile-runtime-isolation-docs-contract.test.tstests/profile-state-docs-contract.test.tstests/routing-context-docs-contract.test.ts
|
CodeRabbit follow-up for the outside-diff comments:\n\n- Approval mechanism handling is fixed in 07b45f4: the mechanism is explicit at runtime and in TypeScript, pending records reject cross-mechanism reuse, and consumption is mechanism-bound.\n- The #28 and #29 assertions intentionally inspect retained release history. Those entries are published in 0.2.0, not current Unreleased notes. The prior helper only happened to return released history when Unreleased was empty; requiring old entries in every unrelated Unreleased section would make the contract incorrect.\n\nThe focused regressions and the complete release-quality suite pass on 07b45f4. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai run pre-merge checks |
✅ Actions performedRunning Pre-merge checks. Results will be posted in the summary comment once complete. |
|
@coderabbitai run pre-merge checks |
✅ Actions performedRunning Pre-merge checks. Results will be posted in the summary comment once complete. |
|
CodeRabbit pre-merge exception record for current head
This records a demonstrably stuck, opaque pre-merge metric rather than disregarding actionable feedback. I will proceed only after the exact-head Windows retry and all other required CI checks are green. |
|
Tip For best results, initiate chat on the files or code changes.
🐇⏳ |
Summary
Security impact
Test-first and validation
Closes #96
Closes #97
Closes #98
Summary by CodeRabbit
security.approvalModewith human (default) and delegated-agent options.miftah init --client claude-codenow prints reviewed Claude Code permission guidance without modifying client settings.