From 47779c7aa9703fa37064d69e11f5c5b78ad41109 Mon Sep 17 00:00:00 2001 From: Jonathan Sarrazin <49979415+jonath92@users.noreply.github.com> Date: Fri, 11 Apr 2025 11:26:39 +0200 Subject: [PATCH] Potential fix for code scanning alert no. 2: SQL query built from user-controlled sources Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- server/routes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/routes.py b/server/routes.py index bab7594..db25a6d 100644 --- a/server/routes.py +++ b/server/routes.py @@ -13,13 +13,13 @@ def index(): if name: cursor.execute( - "SELECT * FROM books WHERE name LIKE '%" + name + "%'" + "SELECT * FROM books WHERE name LIKE %s", ('%' + name + '%',) ) books = [Book(*row) for row in cursor] elif author: cursor.execute( - "SELECT * FROM books WHERE author LIKE '%" + author + "%'" + "SELECT * FROM books WHERE author LIKE %s", ('%' + author + '%',) ) books = [Book(*row) for row in cursor]