From 7755f5a1edc75c3e05d3edacdf7c0e222555ea3a Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 14:44:48 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=92=20Fix=20potential=20SQL=20injectio?= =?UTF-8?q?n=20in=20database=20migration=20preview?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `preview_migration` function in `app/utils/db_migrate.py` used string interpolation to dynamically execute a COUNT query on the source database (`f"SELECT COUNT(*) FROM {quoted_table}"`). While the table name was quoted via the dialect's identifier preparer and validated with a regex, string interpolation for raw SQL should be avoided as it represents an anti-pattern and a theoretical risk for SQL injection if validation controls are ever bypassed or modified. This commit replaces the raw string interpolation with safe, parameterized SQLAlchemy Core query construction `select(func.count()).select_from(table(table_name))`, which automatically handles table quoting and execution safely. It also removes the unused `text` import to keep the code clean. Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>