Skip to content

Commit 2a932f2

Browse files
committed
Add example code for CodeQL to flag
1 parent 2fa11a8 commit 2a932f2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import sqlite3
2+
3+
def get_user_data(username):
4+
query = "SELECT * FROM users WHERE username = '" + username + "'"
5+
6+
try:
7+
conn = sqlite3.connect('database.db')
8+
cursor = conn.cursor()
9+
cursor.execute(query)
10+
11+
rows = cursor.fetchall()
12+
for row in rows:
13+
print("User ID:", row[0])
14+
print("Username:", row[1])
15+
print("Email:", row[2])
16+
17+
cursor.close()
18+
conn.close()
19+
except sqlite3.Error as e:
20+
print("Error executing SQLite query:", e)
21+
22+
get_user_data("admin' OR '1'='1")

0 commit comments

Comments
 (0)