Query parameters are parsed by hand or left untyped
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 57/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Bereich
- backend-api-design, databases, testing
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Python
- Sterne
- 212
- Forks
- 321
- Ø Merge
- 1 T. 7 Std.
- Gemergte PRs (30 T.)
- 14
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus learningequality/studio
-
Community library status changes don't update `date_updated`Evtl. vergeben @ArpitaSamanta10 hat das heute übernommen. Offencommunity-contribution-in-progress DEV: backend good first issue help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
learningequality/studio#6414 · 8 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
DEV: backend
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
learningequality/studio#6410 ·
Maintainer antworten meist innerhalb von 1 Tag
-
DEV: backend
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
learningequality/studio#6409 ·
Maintainer antworten meist innerhalb von 1 Tag
-
DEV: backend
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
learningequality/studio#6407 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Stripe webhook accepts events when no webhook secret is configuredEvtl. vergeben @adibmbrk hat das heute übernommen. Offencommunity-contribution-in-progress DEV: backend good first issue help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
learningequality/studio#6404 · 3 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in learningequality/studio
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 2 Tagen
-
audit-reference-check
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
site-bug triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
canonical/paas-charm#407 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 5 Tagen