Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion utils/build/docker/python/flask/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def rasp_sqli(*args, **kwargs):
DB = sqlite3.connect(":memory:")
print(f"SELECT * FROM users WHERE id='{user_id}'")
cursor = DB.execute(f"SELECT * FROM users WHERE id='{user_id}'")
print("DB request with {len(list(cursor))} results")
print(f"DB request with {len(list(cursor))} results")
return f"DB request with {len(list(cursor))} results"
Comment on lines +439 to 440
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid exhausting SQL cursor before composing response

The new f-string log call iterates cursor once (len(list(cursor))) before the response is built, so in any case where the query succeeds and returns rows, the subsequent len(list(cursor)) in the return path will always be 0 because the cursor has already been consumed. This changes endpoint behavior from reporting actual row count to always reporting zero; compute the count once and reuse it for both log and response.

Useful? React with 👍 / 👎.

except Exception as e:
print(f"DB request failure: {e!r}", file=sys.stderr)
Expand Down
Loading