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

未关闭
#6,401 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
56/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
django, python

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Python
星标
212
派生
321
平均合并
1 天 7 小时
30 天内合并 PR
14

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

learningequality/studio 的其他 Issue

查看 learningequality/studio 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。