fix(delete): block self-approval of protected-page deletes#448
Open
dalledajay-coder wants to merge 1 commit into
Open
fix(delete): block self-approval of protected-page deletes#448dalledajay-coder wants to merge 1 commit into
dalledajay-coder wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: