Cursor pagination doesn't validate the cursor position or page size
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Start with ValuesViewsetCursorPagination in contentcuration/contentcuration/utils/pagination.py, ContentNodePagination in contentcuration/contentcuration/viewsets/contentnode.py, and OptionalContentNodePagination in contentcuration/kolibri_public/views.py; compare how each handles cursor positions, ordering and page size. Reproduce the listed requests and add regression tests for each input, including the import metadata endpoint. Done means malformed cursors return DRF's invalid-cursor 404, ignored ordering cursors do not affect /api/contentnode, and public content-node pages respect a maximum size.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Overview
Cursor pagination passes the cursor's position to the queryset filter without checking it fits the ordering field, and the public contentnode endpoint has no maximum page size. A crafted cursor, or a huge max_results, raises an exception and the request returns 500. Two of the affected endpoints are anonymous.
Complexity: Medium
Target branch: hotfixes
Context
All inputs below were reproduced:
ValuesViewsetCursorPaginationrelies on DRF'sCursorPagination.decode_cursor, which validates the cursor's offset and direction but not its position (p). A base64 cursor ofp=abcorp=notadatereaches the filter on:/api/public/v2/contentnode/?max_results=2&cursor=cD1hYmM=:ValueError: Field 'lft' expected a number but got 'abc'. Anonymous./api/channelversion?version__gte=0&max_results=5&cursor=<p=abc>:ValueErroronversion. Anonymous./api/communitylibrary_submission?max_results=5&cursor=<p=notadate>: DjangoValidationErroron the datetime.ImportMetadataPaginationon/api/public/v2/importmetadata/<id>/orders bylftthe same way. Anonymous. Not reproduced separately.
ContentNodePaginationreads the cursor field from the raworderingparam and only checks the value is an integer when that field islft. On/api/contentnode?parent=<id>&max_results=2:&ordering=foo&foo__gt=abcraisesValueErroronlft, because DRF falls back tolftordering.&ordering=modified&modified__gt=abcraises DjangoValidationError.- Related: #4854.
OptionalContentNodePaginationsets nomax_page_size. On/api/public/v2/contentnode/,?max_results=999999999999999999999999999999raisesDataError: bigint out of range. Related: learningequality/kolibri#15826.
The Change
- A cursor position that doesn't fit the ordering field should get the same response DRF gives for any malformed cursor.
ContentNodePaginationshould take its cursor field from the ordering the viewset applies, not the raworderingparam.OptionalContentNodePaginationshould capmax_results.
Acceptance Criteria
General
- Every cursor input in Context, and the same cursor on
/api/public/v2/importmetadata/<id>/, returns DRF's invalid-cursor 404 instead of 500. -
/api/contentnodeignores a cursor param for anorderingit doesn't apply, and returns a 4xx for a cursor value of the wrong type for the ordering it applies. -
/api/public/v2/contentnode/with amax_resultsabove the cap returns at most the cap.
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.
- Ngôn ngữ chính
- Python
- Star
- 212
- Fork
- 321
- Merge trung bình
- 1 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 14
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của learningequality/studio
-
Community library status changes don't update `date_updated`Có thể đã có người làm @LightCreator1007 đã nhận 1 ngày trước. Đang mởDEV: backend good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
learningequality/studio#6414 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DEV: backend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
learningequality/studio#6410 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DEV: backend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
learningequality/studio#6409 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DEV: backend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
learningequality/studio#6407 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DEV: backend good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
learningequality/studio#6404 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của learningequality/studio
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
canonical/paas-charm#407 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 5 ngày
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
FAIRmat-NFDI/pynxtools-spm#136 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement tooling
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`read_nexus` entry point points to a function that no longer existsCó thể đã có người làm @RubelMozumder đã nhận hôm nay. Đang mởannotator bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
FAIRmat-NFDI/pynxtools#876 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: HTTP 499 (Client Closed Request) is classified as a non-retryable format_error, so a mid-flight abort fails the turn over instead of retryingCó thể đã có người làm @yipinghuang1991 đã nhận hôm nay. Đang mởcomp/agent P2 type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NousResearch/hermes-agent#156837 ·
Maintainer thường phản hồi trong vòng 1 ngày