Query parameters are parsed by hand or left untyped

Aperta
#6,392 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
django, postgresql, python

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

DEV: backend

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:

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_types and exclude_content_ids should filter the results, as they do in Kolibri.
  • Admin keywords should match regex metacharacters as literal text.
Acceptance Criteria
General
  • Every input in Context other than valid resource_types and exclude_content_ids values returns 400 instead of 500.
  • A valid resource_types value returns only nodes with all of those resource types, and exclude_content_ids leaves out nodes with those content ids.
  • ?keywords=a[ on /api/admin-users returns users whose name, email or channel matches the literal text a[.
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.

Lingua principale
Python
Stelle
212
Fork
321
Merge medio
1g 7h
PR unite (30g)
14

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di learningequality/studio

Tutte le issue di learningequality/studio

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.