The function below returns every memo in the system, regardless of who is asking.
The bug: this is the same class of bug as OWASP's NodeGoat's memo-listing endpoint (a deliberately-vulnerable app used for security training) — it fetches all memos and renders them, without ever filtering by the logged-in user. Any authenticated user can read every other user's private memos just by visiting the page.
Your task: fix solve(all_memos, current_user_id) so it returns only the memos that belong to current_user_id.
memos = [
{'id': 1, 'user_id': 'alice', 'text': 'Buy milk'},
{'id': 2, 'user_id': 'bob', 'text': 'Call the bank'},
]
solve(memos, 'alice') # → [{'id': 1, 'user_id': 'alice', 'text': 'Buy milk'}]Sample tests