Query parameters are parsed by hand or left untyped
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 57/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
调研方向
Start by reading the validation strategy in #6387 and inspect the referenced filters and views in contentcuration/viewsets/channel.py, search/viewsets/contentnode.py, contentcuration/viewsets/user.py, kolibri_public/views.py, and kolibri_public/views_v1.py. Add regression tests for each listed input, checking that invalid values return 400 and valid resource_types, exclude_content_ids, and literal regex keywords produce the specified results.
由索引模型根据 Issue 内容生成。
描述
Overview
Several list endpoints parse query parameters by hand, or let django-filter generate an untyped filter, so a value of the wrong type reaches Python or the database and the request returns 500. Most of these endpoints are public or reachable by any logged-in user.
Complexity: Medium
Target branch: hotfixes
Context
All inputs below were reproduced:
BaseChannelFilter.filter_licensescallsint()on each value.?licenses=abcraisesValueErroron/api/catalog(anonymous),/api/channeland/api/admin-channels.- The search viewset calls
int()infilter_licensesand uses an uncheckedre.searchinfilter_created_after. On/api/search/search,?licenses=abcraisesValueError,?created_after=abcraisesAttributeError, and?created_after=0000-01-01raisesValueError: year 0 is out of range. - The admin user list builds a Postgres regex from
keywords. On/api/admin-usersand itsdownload_csvaction,?keywords=(,a[or*raisesDataError: invalid regular expression. Related: #2920. - The public v2 contentnode filter lists
content_id,channel_id,prerequisite_for,relatedandhas_prerequisitewithout declaring a filter for them, so django-filter generates aCharFilter. On/api/public/v2/contentnode/,?content_id=abcraisesValueError: badly formed hexadecimal UUID string, and so do the other four. Related: #4788. - On the same endpoint,
resource_typesraisesKeyError: 'resource_types'for every value, becausecontentnode_metadata_lookuphas noresource_typesentry. Related: learningequality/kolibri#15797. - On the same endpoint,
exclude_content_idsraisesAttributeErrorfor every value, because the queryset has noexclude_by_content_idsmethod. - The public v1 views pass
keywordandtokens, the lookupidentifierand thechannel_idof/api/public/channel/<id>to the ORM unvalidated. A NUL byte (%00) in any of them raisesValueError: A string literal cannot contain NUL (0x00) characters. ChannelUserViewSet.remove_selfpasses itschannel_idquery param toChannel.objects.get. A malformed id returns 404, but one containing a NUL byte raises the sameValueError. #5968 fixed this onunstableby parsing the id withuuid.UUID().
The Change
- Each parameter in Context should be a typed django-filter filter, or validated by a DRF field in the v1 views, following the strategy in #6387, so an invalid value returns 400.
resource_typesandexclude_content_idsshould filter the results, as they do in Kolibri.- Admin
keywordsshould match regex metacharacters as literal text.
Acceptance Criteria
General
- Every input in Context other than valid
resource_typesandexclude_content_idsvalues returns 400 instead of 500. - A valid
resource_typesvalue returns only nodes with all of those resource types, andexclude_content_idsleaves out nodes with those content ids. -
?keywords=a[on/api/admin-usersreturns users whose name, email or channel matches the literal texta[.
Testing
- Each input in Context has a regression test.
AI usage
I scoped the audit and chose the validation strategy in #6387. Claude Code found and reproduced these failures and drafted this issue.
- 主要语言
- Python
- 星标
- 212
- 派生
- 321
- 平均合并
- 1 天 7 小时
- 30 天内合并 PR
- 14
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
learningequality/studio 的其他 Issue
-
Community library status changes don't update `date_updated`可能已有人在做 @ArpitaSamanta10 今天认领。 未关闭community-contribution-in-progress DEV: backend good first issue help wanted
难度 2/5 1-3 小时 新手友好度 84/100
learningequality/studio#6414 · 8 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
DEV: backend
难度 2/5 1-3 小时 新手友好度 82/100
learningequality/studio#6410 ·
维护者通常 1 天内回复
-
DEV: backend
难度 2/5 1-3 小时 新手友好度 76/100
learningequality/studio#6409 ·
维护者通常 1 天内回复
-
DEV: backend
难度 2/5 1-3 小时 新手友好度 78/100
learningequality/studio#6407 ·
维护者通常 1 天内回复
-
Stripe webhook accepts events when no webhook secret is configured可能已有人在做 @adibmbrk 今天认领。 未关闭community-contribution-in-progress DEV: backend good first issue help wanted
难度 2/5 1-3 小时 新手友好度 78/100
learningequality/studio#6404 · 3 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 learningequality/studio 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
audit-reference-check
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
site-bug triage
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 77/100
canonical/paas-charm#407 · 1 条评论 ·
维护者通常 5 天内回复