Files
quiz/app
ameer bb070a688d fix(room): guard against non-dict WS payloads and unhashable answers
The first-pass JSON-decode hardening exposed two latent bugs that the
fuzz scenario hits as soon as the WS handler stays alive past a bad
message:

1) `data.get("type")` is called on whatever `receive_json()` decodes,
   but valid JSON can be a list/string/number, not just a dict. Reject
   non-object payloads with a structured bad_message error before
   dispatch.

2) `submit_answer` did `if answer not in {"A","B","C","D"}` which
   raises TypeError when the client sends an unhashable answer
   (e.g. a dict). Add an isinstance(str) guard so any non-string
   answer falls into the bad_answer branch instead of crashing the
   handler.

31/31 pytest still passes. Together with the prior commit, the WS
handlers now survive the full set of fuzz payloads without dropping
the connection.
2026-05-02 17:34:18 +08:00
..
2026-05-02 02:54:34 +08:00
2026-05-02 02:59:34 +08:00
2026-05-02 02:59:34 +08:00
2026-05-02 02:59:34 +08:00
2026-05-02 02:59:34 +08:00
2026-05-02 02:59:34 +08:00
2026-05-02 02:59:34 +08:00
2026-05-02 02:59:34 +08:00