From 0ad3d4733e8e2a71eb5baabcb7a5ea81abc500c4 Mon Sep 17 00:00:00 2001 From: "patched.codes[bot]" <298395+patched.codes[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:17:34 +0000 Subject: [PATCH] Patched /tmp/tmpkc700rot/index.py --- index.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.py b/index.py index 83759b9..a0c6e5d 100644 --- a/index.py +++ b/index.py @@ -7,12 +7,12 @@ } def get_data_by_config_value(value): - # This might look suspicious due to string concatenation with values from CONFIG. - query = "SELECT * FROM " + CONFIG["default_table"] + " WHERE " + CONFIG["default_column"] + " = '" + value + "'" + # Use predefined CONFIG values and a parameterized query for protection against SQL Injection + query = f"SELECT * FROM {CONFIG['default_table']} WHERE {CONFIG['default_column']} = ?" connection = sqlite3.connect("database.db") cursor = connection.cursor() - cursor.execute(query) + cursor.execute(query, (value,)) result = cursor.fetchall() connection.close()