Fixes #22470: Restrict TaggedItem API to visible target objects#22505
Fixes #22470: Restrict TaggedItem API to visible target objects#22505pheus wants to merge 1 commit into
Conversation
|
@claude /review Only report on issues of potential concern; we don't need commentary on anything that doesn't require further consideration. |
|
Claude finished @pheus's task in 4m 22s —— View job PR Review: Restrict TaggedItem API to visible target objects
Concerns1. Silent exclusion of plugin-tagged objects — if not hasattr(target_queryset, 'restrict'):
# Fail closed: target model has no object-level permission enforcement.
continuePlugin models that tag objects but whose manager doesn't use 2. Unnecessary subquery for When a model is listed in content_type_id = X AND object_id IN (SELECT pk FROM <exempt_model_table>)This is logically equivalent to 3. content_type_ids = queryset.order_by().values_list(content_type_id_field, flat=True).distinct()This executes as a separate DB query (accounts for the 4. Before this PR, if |
Add permission filtering to TaggedItemViewSet to prevent disclosure of objects outside user's view permissions. Filter queryset by target model permissions using restrict_queryset_by_gfk utility, which honors object-level constraints. Add None check in serializer for missing or deleted targets. Fixes #22470
e93f637 to
bafca24
Compare
|
@claude /review
|
|
Claude finished @pheus's task in 58s —— View job PR Review (follow-up)
All four responses check out. #1 — Docs note ( #2 — Exempt-model optimization ( #3 — TOCTOU race: Under-inclusion only, not over-inclusion — correct call to leave it. #4 — Serializer No new concerns. |
Closes: #22470
This updates the TaggedItem API to respect object-level view permissions for each tagged object.
Tagged items are now filtered against the permissions of their target objects, preventing users from discovering objects they are not allowed to view through the tags endpoint. It also handles missing or deleted tagged targets more safely during serialization.