-
Notifications
You must be signed in to change notification settings - Fork 0
demo: smoke-test PR for MAS-Ops review pipeline #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,19 @@ | ||||||
| import sqlite3 | ||||||
|
|
||||||
|
|
||||||
| def get_user(db_path, user_id, cache={}): | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: Mutable default argument There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Prompt for AI agents |
||||||
| if user_id in cache: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: The cache is keyed solely by Prompt for AI agents |
||||||
| return cache[user_id] | ||||||
|
Comment on lines
+4
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When this helper is called for more than one SQLite database in the same process, the shared default cache is keyed only by Useful? React with 👍 / 👎. |
||||||
| conn = sqlite3.connect(db_path) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: The Prompt for AI agents |
||||||
| cur = conn.cursor() | ||||||
| cur.execute("SELECT * FROM users WHERE id = '%s'" % user_id) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SQL injection via string interpolation in queryHigh Severity
Reviewed by Cursor Bugbot for commit f0bfbf3. Configure here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CRITICAL: SQL injection vulnerability - using string formatting in SQL query. Use parameterized queries: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P0: This query is vulnerable to SQL injection because it interpolates Prompt for AI agents
Suggested change
|
||||||
| rows = cur.fetchall() | ||||||
| cache[user_id] = rows | ||||||
| return rows | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Database connection is never closed, causing resource leakMedium Severity The Reviewed by Cursor Bugbot for commit f0bfbf3. Configure here.
Comment on lines
+1
to
+12
|
||||||
|
|
||||||
|
|
||||||
| def first_or_none(items=[]): | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: Mutable default argument |
||||||
| try: | ||||||
| return items[0] | ||||||
| except: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: Bare except: catches all exceptions including SystemExit and KeyboardInterrupt. Catch specific exceptions like IndexError instead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Bare Prompt for AI agents |
||||||
| pass | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bare except silently swallows critical system exceptionsLow Severity The bare Reviewed by Cursor Bugbot for commit f0bfbf3. Configure here.
Comment on lines
+15
to
+19
|
||||||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mutable default argument creates persistent shared cache
Medium Severity
Using a mutable default argument (
cache={}) means the dictionary is shared across all calls toget_userfor the lifetime of the process. The cache can never be invalidated, so stale data will be returned indefinitely after the first lookup for a givenuser_id. This is a well-known Python gotcha that leads to surprising behavior.Reviewed by Cursor Bugbot for commit f0bfbf3. Configure here.