Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Constrain review-queue listing, agent, component, and bundle lookups to the reviewer's organization (owner_org_id) so a reviewer in one org cannot read or act on another org's submissions. - Add _owner_org_conditions/_apply_owner_org_filter helpers and thread org_id through _find_listing, _check_agent_components_ready, _query_pending_agents, _query_pending_components, and the approve/ reject/bundle/related-skills handlers. - Treat components the caller's org cannot see as blocking rather than silently approvable. - Add tenant-scope regression tests: helper-level coverage plus route- level tests that drive each handler (list, detail, approve/reject, agent approve/reject, bundle approve/reject, related-skills, approve- with-skills) and assert cross-org access is denied (404/empty) while the org predicate is present in the query (and absent for super-admins). Part of AUDIT2 tenant-scoping, split out of Observal#1184.
13749b2 to
3bc4c60
Compare
WalkthroughReview routes now enforce organization-level isolation for listing, agent, component, bundle, related-skill, approval, and rejection operations. Tenant-scoping tests cover cross-organization denial, organization propagation, super-admin access, and commit prevention. ChangesTenant-scoped review
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
observal-server/api/routes/review.py (1)
521-524: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReuse
_apply_owner_org_filterinstead of duplicating theAgentorg check.get_review,approve_agent, andreject_agenteach repeat the same inlineif current_user.org_id is not None: ...where(Agent.owner_org_id == current_user.org_id)pattern, even though this PR adds_apply_owner_org_filterfor exactly this purpose and already unit-tests it. Consolidating removes duplicated logic that could otherwise diverge.
observal-server/api/routes/review.py#L521-L524: replace the inlineif current_user.org_id is not Noneblock withagent_stmt = _apply_owner_org_filter(select(Agent).where(Agent.id == agent_uuid), Agent, current_user.org_id).observal-server/api/routes/review.py#L727-L730: replace the inline block withagent_stmt = _apply_owner_org_filter(select(Agent).where(Agent.id == agent_id), Agent, current_user.org_id).observal-server/api/routes/review.py#L802-L805: replace the inline block withagent_stmt = _apply_owner_org_filter(select(Agent).where(Agent.id == agent_id), Agent, current_user.org_id).♻️ Proposed refactor (apply the same pattern at all three sites)
- agent_stmt = select(Agent).where(Agent.id == agent_uuid) - if current_user.org_id is not None: - agent_stmt = agent_stmt.where(Agent.owner_org_id == current_user.org_id) - agent = (await db.execute(agent_stmt)).scalar_one_or_none() + agent_stmt = _apply_owner_org_filter( + select(Agent).where(Agent.id == agent_uuid), Agent, current_user.org_id + ) + agent = (await db.execute(agent_stmt)).scalar_one_or_none()🤖 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 `@observal-server/api/routes/review.py` around lines 521 - 524, Replace the duplicated inline Agent organization checks with _apply_owner_org_filter in get_review (observal-server/api/routes/review.py:521-524), approve_agent (observal-server/api/routes/review.py:727-730), and reject_agent (observal-server/api/routes/review.py:802-805), passing each existing Agent query, Agent, and current_user.org_id.
🤖 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.
Nitpick comments:
In `@observal-server/api/routes/review.py`:
- Around line 521-524: Replace the duplicated inline Agent organization checks
with _apply_owner_org_filter in get_review
(observal-server/api/routes/review.py:521-524), approve_agent
(observal-server/api/routes/review.py:727-730), and reject_agent
(observal-server/api/routes/review.py:802-805), passing each existing Agent
query, Agent, and current_user.org_id.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 740058ad-7b0e-4bfe-9be9-a5ca1e53ab42
📒 Files selected for processing (2)
observal-server/api/routes/review.pytests/test_tenant_scope_review.py
Purpose / Description
Constrain registry review access to the reviewer's organization so a reviewer in one org cannot list, read, approve, reject, or bulk-act on another org's submissions.
This is part of the AUDIT2 tenant-scoping work and is split out from the closed broader tenant-scope PR #1184 to keep the change smaller and independently reviewable.
Fixes
Approach
This change scopes review-queue listing, agent, component, and bundle lookups to the caller's
owner_org_id._owner_org_conditionsand_apply_owner_org_filterhelpers.org_idthrough_find_listing,_check_agent_components_ready,_query_pending_agents,_query_pending_components, and review mutation handlers.How Has This Been Tested?
Tested the new review tenant-scope coverage and linted/formatted the changed files.
Targeted tests:
Result: 18 review tenant-scope tests passed.
Lint/format:
Also re-ran adjacent review/agent/bundle/draft suites as part of the split verification; no regressions were found.
Checklist
Summary by CodeRabbit