Feedback events take `user` from the request and allow updates to other users' events

Ouverte
#6,401 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
56/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
django, python

Piste de recherche

Start with contentcuration/contentcuration/viewsets/feedback.py, especially the serializers and three viewsets identified in the issue, then read the strategy in issue #6398. Add regression tests for spoofed users and updates to another user's recommendation, interaction, and flag events. Done means the ownership and response-code acceptance criteria pass while users can still create and update their own events.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

DEV: backend

Overview

The feedback event endpoints take user from the request body, and their update routes accept any event. Any logged-in user can record recommendation events as another user and change another user's recommendation events by id. The flagged-content endpoint has the same shape for users with the test_dev_feature flag.

Complexity: Low
Target branch: hotfixes

Context
  • BaseFeedbackEventSerializer marks user read-only, but FlagFeedbackEventSerializer and RecommendationsEventSerializer declare their own Meta, which drops it. Nothing sets user from the request.
  • The three viewsets use .objects.all() with no ownership filter.
  • Reproduced:
    • POST /api/events/recommendations with another user's id in user returns 201, and the event is recorded as theirs.
    • PATCH /api/events/recommendations/<another user's event id> returns 200 and changes the event.
The Change
  • user should be read-only on every feedback event serializer and set from request.user, following the strategy in #6398.
  • Update routes should only find the requester's own events. Interaction events belong to the requester through their recommendation_event_id.
Acceptance Criteria
General
  • Creating a recommendation or flag event with another user's id in user records the event as the requester's.
  • PUT and PATCH on another user's recommendation or interaction event return 404. On another user's flag event they return 404 for users with the test_dev_feature flag, and 403 as now for users without it.
  • Users can still create and update their own events.
Testing
  • Regression tests cover spoofed user on create and updates to another user's event, for each event type.

AI usage

I chose which audit findings belong in #6398 and set the access pattern. Claude Code found and reproduced this gap and drafted this issue.

Langage dominant
Python
Étoiles
212
Forks
321
Merge moyen
1 j 7 h
PR mergées (30 j)
14

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de learningequality/studio

Toutes les issues de learningequality/studio

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.