fix(delete): block self-approval of protected-page deletes#448
fix(delete): block self-approval of protected-page deletes#448dalledajay-coder wants to merge 1 commit into
Conversation
|
Warning Review limit reached
Next review available in: 57 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
the protected-kind gate in _approval_block_reason only covered PAGE proposals, so under review.approver_role: trusted-agent a proposer could file and self-approve a DELETE targeting a protected page — removing a policy-bearing page it could not have edited without a second reviewer. extend the gate to DELETE proposals that target a page: resolve the page kind from the live artifact (what approve would actually remove), falling back to the propose-time snapshot so the guard also holds on the idempotent already-gone path. check_approvable shares the helper, so the batch precheck reports the same reason. unprotected deletes keep the trusted-agent opt-out unchanged.
2eb47d8 to
cedd6c9
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
What changed
_approval_block_reasonnow applies the protected-page-kind gate to DELETE proposals that target a page, not just to PAGE proposals. the page kind is resolved from the live artifact (what approve would actually remove), falling back to the propose-time snapshot so the guard also holds on the idempotent already-gone path.check_approvableshares the helper, so the batch precheck reports the same reason. unprotected deletes keep the trusted-agent opt-out unchanged.Why
with
review.approver_role: trusted-agentand a protected page kind (sayvoice), editing that page correctly refuses self-approval — "it always requires a reviewer other than the proposer". but the new delete path didn't run that check, so the same proposer could filekb.propose_deletefor the page and approve it themselves:removing a policy-bearing page is at least as sensitive as editing it, and the comment on the existing gate says the opt-out "can never widen it" — the delete path widened it. deletes are also irreversible (
reversible=Falsein the audit event), so this was the one write a trusted agent could make to protected knowledge without a second reviewer.no
.vouch/directory migration concerns: the change only tightens an approve-time check; nothing on disk changes shape.Testing
tests/test_delete.py::test_delete_protected_page_blocks_self_approval_despite_trusted_agent— fails on currenttest(the approve succeeds and the page is unlinked), passes with the fix; also asserts a distinct reviewer can still approve.tests/test_delete.py::test_delete_protected_page_guard_holds_when_target_already_gone— covers the snapshot fallback on the crash-retry path; fails before, passes after.tests/test_delete.py::test_delete_unprotected_page_keeps_trusted_agent_opt_out— guards against over-blocking; passes before and after.ran locally: