Spot the bug
Which line lets any signed-in user read any invoice?
from dataclasses import dataclass@dataclassclass Invoice:id: intowner_id: inttotal: intDB = {1001: Invoice(1001, 7, 500), 1002: Invoice(1002, 8, 900)}def get_invoice(user_id: int, invoice_id: int) -> Invoice | None:inv = DB.get(invoice_id)return inv
Hint 1 of 1
Where is user_id used?
Choose an answer, then open Show answer below to check it.
Show answer
- Answer: line 16
return inv
Line 16 returns the invoice without comparing inv.owner_id to user_id. Return it only when they match.