Skip to content

ObjectPermission object type selector includes internal/third-party models #21051

@pheus

Description

@pheus

NetBox Edition

NetBox Community

NetBox Version

v4.4.8

Python Version

3.12

Steps to Reproduce

  1. Navigate to Admin → Permissions (or go to /users/permissions/add/)
  2. Click Add (create a new Object Permission)
  3. In the Object types selector, scroll/search for terms like ObjectType, cached, queue, etc.
  4. Observe that internal/third-party models appear in the selectable list

Expected Behavior

The Object types selector should only include object types that make sense for NetBox ObjectPermissions, for example:

  • user-facing NetBox models, and
  • plugin models intended to participate in NetBox’s object permission system

Internal metadata models and third-party dependency/tooling models (like the examples above) should not be offered as selectable object types.

Observed Behavior

The selector includes internal/third-party models such as:

  • core.ObjectType
  • debug_toolbar.historyentry *
  • django_rq.queue
  • extras.cached_value
  • migrations.migration *
  • thunmbnail.kv_store

*) only listed in a local dev environment


Additional Notes / Suggestion

First off: thank you for the recent improvements around the ObjectPermission UI (especially the object type grouping introduced around #20759). It makes the selector much easier to navigate.

From a quick look, this seems to be related to the queryset/filter used to build the choices. The current filter appears to be:

OBJECTPERMISSION_OBJECT_TYPES = Q(
    ~Q(app_label__in=['account', 'admin', 'auth', 'contenttypes', 'sessions', 'taggit', 'users']) |
    Q(app_label='users', model__in=['objectpermission', 'token', 'group', 'user'])
)

As written, this behaves like a small denylist (plus a special-case allowlist for users.*), which means any other installed Django app (including dev tooling / background worker apps) can show up as selectable object types.

I’d like to suggest a review of all object types that are currently eligible for ObjectPermissions. A short-term fix could be to exclude known internal and common third-party tooling apps/models.

Longer-term, it might be more robust to base the selector on a “user-facing/public models” concept (while still supporting plugins), rather than relying on a denylist of a few Django apps.

Happy to help test any changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    netboxseverity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: needs ownerThis issue is tentatively accepted pending a volunteer committed to its implementationtype: bugA confirmed report of unexpected behavior in the application

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions