-
Notifications
You must be signed in to change notification settings - Fork 336
fix(sql): Escape #4861
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
base: develop
Are you sure you want to change the base?
fix(sql): Escape #4861
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -76,7 +76,9 @@ def get_erpnext_bench(): | |||||
| server.use_for_new_sites DESC, bench.creation DESC | ||||||
| LIMIT 1 | ||||||
| """ | ||||||
| return frappe.db.sql(query, [proxy_servers, release_group], as_dict=True)[0].name | ||||||
| return frappe.db.sql( | ||||||
| query, (frappe.db.escape(proxy_servers), frappe.db.escape(release_group)), as_dict=True | ||||||
|
||||||
| query, (frappe.db.escape(proxy_servers), frappe.db.escape(release_group)), as_dict=True | |
| query, (tuple(proxy_servers), release_group), as_dict=True |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -787,12 +787,12 @@ def benches_with_available_update(site=None, server=None): | |
| if server: | ||
| values["server"] = server | ||
| source_benches_info = frappe.db.sql( | ||
| f""" | ||
| """ | ||
| SELECT sb.name AS source_bench, sb.candidate AS source_candidate, sb.server AS server, dcd.destination AS destination_candidate | ||
| FROM `tabBench` sb, `tabDeploy Candidate Difference` dcd | ||
| WHERE sb.status IN ('Active', 'Broken') AND sb.candidate = dcd.source | ||
| {"AND sb.name = %(site_bench)s" if site else ""} | ||
| {"AND sb.server = %(server)s" if server else ""} | ||
| AND (%(site_bench)s IS NULL OR sb.name = %(site_bench)s) | ||
| AND (%(server)s IS NULL OR sb.server = %(server)s) | ||
|
Comment on lines
+794
to
+795
|
||
| """, | ||
| values=values, | ||
| as_dict=True, | ||
|
|
||
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.
This query now uses
%splaceholders but still passesfrappe.db.escape(user)/frappe.db.escape(groups)as parameters.escapereturns SQL-quoted strings, so the driver will quote them again and the lookup will not match (andIN %swill likely break). Pass the rawuserandgroupstuple as parameters instead (or use named placeholders with avaluesdict).