From 25f3b0a67463a85b3275e395229bea073120c494 Mon Sep 17 00:00:00 2001
From: Oskari Lahtinen <osklahti@jyu.fi>
Date: Fri, 5 Apr 2024 14:31:12 +0300
Subject: [PATCH] SQL-injektioesimerkki

---
 alusta.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/alusta.py b/alusta.py
index 640a1ec..4a97ef4 100644
--- a/alusta.py
+++ b/alusta.py
@@ -19,6 +19,9 @@ for paiva in data["MenusForDays"]:
         if len(ruoka['Components']) != 0:
             # yhdistetään ruokavaihtoehdon eri komponentit
             ruokastring = ' '.join(ruoka['Components'])
+            # EI näin, SQL injection:
+            #stmt = f"INSERT INTO ateria (paiva, ruoka) VALUES({pvm}, {ruokastring})"
+            #cur.execute(stmt)
             cur.execute("INSERT INTO ateria (paiva, ruoka) VALUES(?, ?)", (pvm, ruokastring))
             con.commit()
 
-- 
GitLab