Skip to content

fix: restore authz checks and default-deny filtering in restricted_*_filter#94

Open
devin-ai-integration[bot] wants to merge 1 commit into
eval-bug-1from
devin/1781290509-fix-authz-regression
Open

fix: restore authz checks and default-deny filtering in restricted_*_filter#94
devin-ai-integration[bot] wants to merge 1 commit into
eval-bug-1from
devin/1781290509-fix-authz-regression

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Restores the authorization and query-filtering fixes from Netflix#6155 that were reverted in source only (tests retained), causing 3 test failures.

auth/views.pyGET /users/{user_id} was missing its OrganizationMemberPermission dependency, leaving the endpoint unprotected. Re-added it.

database/service.py — three regressions:

  1. restricted_incident_filter / restricted_case_filter only filtered for role == member, leaving admin/owner/manager/none roles unhandled. Restored default-deny approach:

    # admin/owner/manager → unrestricted
    if role in [admin, owner, manager]:
        return query.distinct()
    # all other roles → outerjoin + filter on visibility + participant email

    Also switched joinouterjoin (inner join dropped open-visibility items with no participants) and added the missing Visibility.restricted condition.

  2. search_filter_sort_paginate stored the restricted query in query_restricted and applied it via .intersect() only for Incident/Case models, breaking sort ordering for all models. Restored direct query = apply_model_specific_filters(...) application.

  3. Removed a stray print() debug statement in apply_filter_specific_joins.

Link to Devin session: https://app.devin.ai/sessions/275b7e9077c04ac4b2648bb9d8969025

…ring in restricted_*_filter

- Restore OrganizationMemberPermission dependency on GET /users/{user_id}
- Restore admin/owner/manager role bypass in restricted_incident_filter and restricted_case_filter
- Use outerjoin instead of inner join so open-visibility items are not dropped
- Add restricted visibility condition (was missing, allowing unrestricted access)
- Apply model-specific filters directly to query instead of via intersect (fixes sort ordering)
- Remove stray debug print() in apply_filter_specific_joins

Co-Authored-By: bot_apk <apk@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants