prompt
stringclasses
1 value
completions
listlengths
2
1.33k
labels
listlengths
2
1.33k
source
stringclasses
1 value
other_info
dict
index
int64
0
719
cwe
stringclasses
9 values
language
stringclasses
6 values
Determine whether the {function_name} code is vulnerable or not.
[ "def set_language(self, lang):\n \"\"\"\n Update language of user in the User object and in the database\n :param lang: string with language tag like \"en-US\"\n :return: None\n \"\"\"\n log.debug('Updating info about user %s language '\n 'in memory & database...', self)", " self.language = lang", " query = (\"UPDATE users \"", " f\"SET language='{self.language}' \"\n f\"WHERE chat_id='{self.chat_id}'\")", "", "", " try:", " db.add(query)", " except DatabaseError:\n log.error(\"Can't add new language of %s to the database\", self)\n else:\n log.debug('Language updated.')" ]
[ 1, 1, 1, 0, 1, 0, 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 416, "char_start": 415, "chars": "%" }, { "char_end": 495, "char_start": 453, "chars": "%s\")\n\n parameters = self.language, " }, { "char_end": 557, "char_start": 545, "chars": ", parameters" } ], "deleted": [ { "char_end": 417, "char_start": 415, "chars": "'{" }, { "char_end": 432, "char_start": 418, "chars": "elf.language}'" }, { "char_end": 470, "char_start": 468, "chars": "'{" }, { "char_end": 487, "char_start": 482, "chars": "}'\")\n" } ] }, "commit_link": "github.com/RandyRomero/photoGPSbot/commit/0e9f57f13e61863b3672f5730e27f149da00786a", "file_name": "photogpsbot/users.py", "func_name": "set_language", "line_changes": { "added": [ { "char_end": 420, "char_start": 383, "line": " f\"SET language=%s \"\n", "line_no": 13 }, { "char_end": 458, "char_start": 420, "line": " f\"WHERE chat_id=%s\")\n", "line_no": 14 }, { "char_end": 508, "char_start": 459, "line": " parameters = self.language, self.chat_id\n", "line_no": 16 }, { "char_end": 559, "char_start": 521, "line": " db.add(query, parameters)\n", "line_no": 18 } ], "deleted": [ { "char_end": 435, "char_start": 383, "line": " f\"SET language='{self.language}' \"\n", "line_no": 13 }, { "char_end": 487, "char_start": 435, "line": " f\"WHERE chat_id='{self.chat_id}'\")\n", "line_no": 14 }, { "char_end": 527, "char_start": 501, "line": " db.add(query)\n", "line_no": 17 } ] }, "vul_type": "cwe-089" }
200
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def set_language(self, lang):\n \"\"\"\n Update language of user in the User object and in the database\n :param lang: string with language tag like \"en-US\"\n :return: None\n \"\"\"\n log.debug('Updating info about user %s language '\n 'in memory & database...', self)", " self.language = lang", " query = (\"UPDATE users \"", " f\"SET language=%s \"\n f\"WHERE chat_id=%s\")", "", " parameters = self.language, self.chat_id", " try:", " db.add(query, parameters)", " except DatabaseError:\n log.error(\"Can't add new language of %s to the database\", self)\n else:\n log.debug('Language updated.')" ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 416, "char_start": 415, "chars": "%" }, { "char_end": 495, "char_start": 453, "chars": "%s\")\n\n parameters = self.language, " }, { "char_end": 557, "char_start": 545, "chars": ", parameters" } ], "deleted": [ { "char_end": 417, "char_start": 415, "chars": "'{" }, { "char_end": 432, "char_start": 418, "chars": "elf.language}'" }, { "char_end": 470, "char_start": 468, "chars": "'{" }, { "char_end": 487, "char_start": 482, "chars": "}'\")\n" } ] }, "commit_link": "github.com/RandyRomero/photoGPSbot/commit/0e9f57f13e61863b3672f5730e27f149da00786a", "file_name": "photogpsbot/users.py", "func_name": "set_language", "line_changes": { "added": [ { "char_end": 420, "char_start": 383, "line": " f\"SET language=%s \"\n", "line_no": 13 }, { "char_end": 458, "char_start": 420, "line": " f\"WHERE chat_id=%s\")\n", "line_no": 14 }, { "char_end": 508, "char_start": 459, "line": " parameters = self.language, self.chat_id\n", "line_no": 16 }, { "char_end": 559, "char_start": 521, "line": " db.add(query, parameters)\n", "line_no": 18 } ], "deleted": [ { "char_end": 435, "char_start": 383, "line": " f\"SET language='{self.language}' \"\n", "line_no": 13 }, { "char_end": 487, "char_start": 435, "line": " f\"WHERE chat_id='{self.chat_id}'\")\n", "line_no": 14 }, { "char_end": 527, "char_start": 501, "line": " db.add(query)\n", "line_no": 17 } ] }, "vul_type": "cwe-089" }
200
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def tid_num_to_tag_nums(self, tid_num):\n ''' Returns list of the associated tag_nums to the given tid_num. '''\n", " q = \"SELECT tag FROM tid_tag WHERE tid = '\" + str(tid_num) + \"'\"\n self.query(q)", " return [i[0] for i in self.c.fetchall()]" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 173, "char_start": 172, "chars": "?" }, { "char_end": 204, "char_start": 195, "chars": ", tid_num" } ], "deleted": [ { "char_end": 194, "char_start": 172, "chars": "'\" + str(tid_num) + \"'" } ] }, "commit_link": "github.com/pukkapies/urop2019/commit/3ca2e2c291d2d5fe262d20a8e0520bdfb622432b", "file_name": "modules/query_lastfm.py", "func_name": "tid_num_to_tag_nums", "line_changes": { "added": [ { "char_end": 175, "char_start": 123, "line": " q = \"SELECT tag FROM tid_tag WHERE tid = ?\"\n", "line_no": 4 }, { "char_end": 206, "char_start": 175, "line": " self.query(q, tid_num)\n", "line_no": 5 } ], "deleted": [ { "char_end": 196, "char_start": 123, "line": " q = \"SELECT tag FROM tid_tag WHERE tid = '\" + str(tid_num) + \"'\"\n", "line_no": 4 }, { "char_end": 218, "char_start": 196, "line": " self.query(q)\n", "line_no": 5 } ] }, "vul_type": "cwe-089" }
201
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def tid_num_to_tag_nums(self, tid_num):\n ''' Returns list of the associated tag_nums to the given tid_num. '''\n", " q = \"SELECT tag FROM tid_tag WHERE tid = ?\"\n self.query(q, tid_num)", " return [i[0] for i in self.c.fetchall()]" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 173, "char_start": 172, "chars": "?" }, { "char_end": 204, "char_start": 195, "chars": ", tid_num" } ], "deleted": [ { "char_end": 194, "char_start": 172, "chars": "'\" + str(tid_num) + \"'" } ] }, "commit_link": "github.com/pukkapies/urop2019/commit/3ca2e2c291d2d5fe262d20a8e0520bdfb622432b", "file_name": "modules/query_lastfm.py", "func_name": "tid_num_to_tag_nums", "line_changes": { "added": [ { "char_end": 175, "char_start": 123, "line": " q = \"SELECT tag FROM tid_tag WHERE tid = ?\"\n", "line_no": 4 }, { "char_end": 206, "char_start": 175, "line": " self.query(q, tid_num)\n", "line_no": 5 } ], "deleted": [ { "char_end": 196, "char_start": 123, "line": " q = \"SELECT tag FROM tid_tag WHERE tid = '\" + str(tid_num) + \"'\"\n", "line_no": 4 }, { "char_end": 218, "char_start": 196, "line": " self.query(q)\n", "line_no": 5 } ] }, "vul_type": "cwe-089" }
201
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@app.route('/summary', methods=['GET'])\ndef summary():\n\tif 'username' in session:", "\t\tconn = mysql.connect()\n\t\tcursor = conn.cursor()", "\t\t#select the maximum score from the results table", "\t\tcursor.execute(\"SELECT courseConcentration FROM results WHERE total = (SELECT MAX(total) FROM (SELECT * FROM results WHERE courseId > 4) Temp) and courseId > 4 and emailAccount='\" + session['username'] + \"'\");", "\t\tcourseConcentration = cursor.fetchone()", "\t\treturn render_template('summary.html', courseConcentration = courseConcentration[0])\n\treturn redirect(url_for('login'))" ]
[ 1, 1, 1, 0, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 366, "char_start": 364, "chars": "%s" }, { "char_end": 368, "char_start": 367, "chars": "," }, { "char_end": 370, "char_start": 369, "chars": "(" }, { "char_end": 390, "char_start": 389, "chars": ")" } ], "deleted": [ { "char_end": 365, "char_start": 364, "chars": "'" }, { "char_end": 369, "char_start": 367, "chars": "+ " }, { "char_end": 394, "char_start": 388, "chars": " + \"'\"" } ] }, "commit_link": "github.com/CaitlinKennedy/Tech-Track/commit/20ef2d4010f9497b8221524edd0c706e2c6a4147", "file_name": "src/tech_track.py", "func_name": "summary", "line_changes": { "added": [ { "char_end": 393, "char_start": 185, "line": "\t\tcursor.execute(\"SELECT courseConcentration FROM results WHERE total = (SELECT MAX(total) FROM (SELECT * FROM results WHERE courseId > 4) Temp) and courseId > 4 and emailAccount=%s\", (session['username']));\n", "line_no": 9 } ], "deleted": [ { "char_end": 397, "char_start": 185, "line": "\t\tcursor.execute(\"SELECT courseConcentration FROM results WHERE total = (SELECT MAX(total) FROM (SELECT * FROM results WHERE courseId > 4) Temp) and courseId > 4 and emailAccount='\" + session['username'] + \"'\");\n", "line_no": 9 } ] }, "vul_type": "cwe-089" }
202
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@app.route('/summary', methods=['GET'])\ndef summary():\n\tif 'username' in session:", "\t\tconn = mysql.connect()\n\t\tcursor = conn.cursor()", "\t\t#select the maximum score from the results table", "\t\tcursor.execute(\"SELECT courseConcentration FROM results WHERE total = (SELECT MAX(total) FROM (SELECT * FROM results WHERE courseId > 4) Temp) and courseId > 4 and emailAccount=%s\", (session['username']));", "\t\tcourseConcentration = cursor.fetchone()", "\t\treturn render_template('summary.html', courseConcentration = courseConcentration[0])\n\treturn redirect(url_for('login'))" ]
[ 1, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 366, "char_start": 364, "chars": "%s" }, { "char_end": 368, "char_start": 367, "chars": "," }, { "char_end": 370, "char_start": 369, "chars": "(" }, { "char_end": 390, "char_start": 389, "chars": ")" } ], "deleted": [ { "char_end": 365, "char_start": 364, "chars": "'" }, { "char_end": 369, "char_start": 367, "chars": "+ " }, { "char_end": 394, "char_start": 388, "chars": " + \"'\"" } ] }, "commit_link": "github.com/CaitlinKennedy/Tech-Track/commit/20ef2d4010f9497b8221524edd0c706e2c6a4147", "file_name": "src/tech_track.py", "func_name": "summary", "line_changes": { "added": [ { "char_end": 393, "char_start": 185, "line": "\t\tcursor.execute(\"SELECT courseConcentration FROM results WHERE total = (SELECT MAX(total) FROM (SELECT * FROM results WHERE courseId > 4) Temp) and courseId > 4 and emailAccount=%s\", (session['username']));\n", "line_no": 9 } ], "deleted": [ { "char_end": 397, "char_start": 185, "line": "\t\tcursor.execute(\"SELECT courseConcentration FROM results WHERE total = (SELECT MAX(total) FROM (SELECT * FROM results WHERE courseId > 4) Temp) and courseId > 4 and emailAccount='\" + session['username'] + \"'\");\n", "line_no": 9 } ] }, "vul_type": "cwe-089" }
202
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def add_post(content):\n \"\"\"Add a post to the 'database' with the current timestamp.\"\"\"\n conn = psycopg2.connect(\"dbname=forum\")\n cursor = conn.cursor()", " cursor.execute(\"insert into posts values ('%s')\" % content)", " conn.commit()\n conn.close()" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 178, "char_start": 157, "chars": "one_post = content\n " }, { "char_end": 225, "char_start": 224, "chars": "," }, { "char_end": 227, "char_start": 226, "chars": "(" }, { "char_end": 234, "char_start": 230, "chars": "_pos" }, { "char_end": 237, "char_start": 235, "chars": ",)" } ], "deleted": [ { "char_end": 200, "char_start": 199, "chars": "'" }, { "char_end": 203, "char_start": 202, "chars": "'" }, { "char_end": 207, "char_start": 205, "chars": " %" }, { "char_end": 209, "char_start": 208, "chars": "c" }, { "char_end": 212, "char_start": 211, "chars": "t" }, { "char_end": 214, "char_start": 213, "chars": "n" } ] }, "commit_link": "github.com/paulc1600/DB-API-Forum/commit/069700fb4beec79182fff3c556e9cccce3230d6f", "file_name": "forumdb.py", "func_name": "add_post", "line_changes": { "added": [ { "char_end": 176, "char_start": 155, "line": " one_post = content\n", "line_no": 5 }, { "char_end": 239, "char_start": 176, "line": " cursor.execute(\"insert into posts values (%s)\", (one_post,))\n", "line_no": 6 } ], "deleted": [ { "char_end": 217, "char_start": 155, "line": " cursor.execute(\"insert into posts values ('%s')\" % content)\n", "line_no": 5 } ] }, "vul_type": "cwe-089" }
203
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def add_post(content):\n \"\"\"Add a post to the 'database' with the current timestamp.\"\"\"\n conn = psycopg2.connect(\"dbname=forum\")\n cursor = conn.cursor()", " one_post = content\n cursor.execute(\"insert into posts values (%s)\", (one_post,))", " conn.commit()\n conn.close()" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 178, "char_start": 157, "chars": "one_post = content\n " }, { "char_end": 225, "char_start": 224, "chars": "," }, { "char_end": 227, "char_start": 226, "chars": "(" }, { "char_end": 234, "char_start": 230, "chars": "_pos" }, { "char_end": 237, "char_start": 235, "chars": ",)" } ], "deleted": [ { "char_end": 200, "char_start": 199, "chars": "'" }, { "char_end": 203, "char_start": 202, "chars": "'" }, { "char_end": 207, "char_start": 205, "chars": " %" }, { "char_end": 209, "char_start": 208, "chars": "c" }, { "char_end": 212, "char_start": 211, "chars": "t" }, { "char_end": 214, "char_start": 213, "chars": "n" } ] }, "commit_link": "github.com/paulc1600/DB-API-Forum/commit/069700fb4beec79182fff3c556e9cccce3230d6f", "file_name": "forumdb.py", "func_name": "add_post", "line_changes": { "added": [ { "char_end": 176, "char_start": 155, "line": " one_post = content\n", "line_no": 5 }, { "char_end": 239, "char_start": 176, "line": " cursor.execute(\"insert into posts values (%s)\", (one_post,))\n", "line_no": 6 } ], "deleted": [ { "char_end": 217, "char_start": 155, "line": " cursor.execute(\"insert into posts values ('%s')\" % content)\n", "line_no": 5 } ] }, "vul_type": "cwe-089" }
203
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def delete_playlist(id, db):", " db.execute(\"DELETE FROM playlist where id={id};\".format(id=id))" ]
[ 1, 0 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 77, "char_start": 75, "chars": "%s" }, { "char_end": 81, "char_start": 79, "chars": ", " }, { "char_end": 85, "char_start": 84, "chars": "," } ], "deleted": [ { "char_end": 79, "char_start": 75, "chars": "{id}" }, { "char_end": 88, "char_start": 81, "chars": ".format" }, { "char_end": 94, "char_start": 91, "chars": "=id" } ] }, "commit_link": "github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6", "file_name": "playlist/playlist_repository.py", "func_name": "delete_playlist", "line_changes": { "added": [ { "char_end": 87, "char_start": 29, "line": " db.execute(\"DELETE FROM playlist where id=%s;\", (id,))\n", "line_no": 2 } ], "deleted": [ { "char_end": 96, "char_start": 29, "line": " db.execute(\"DELETE FROM playlist where id={id};\".format(id=id))\n", "line_no": 2 } ] }, "vul_type": "cwe-089" }
204
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def delete_playlist(id, db):", " db.execute(\"DELETE FROM playlist where id=%s;\", (id,))" ]
[ 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 77, "char_start": 75, "chars": "%s" }, { "char_end": 81, "char_start": 79, "chars": ", " }, { "char_end": 85, "char_start": 84, "chars": "," } ], "deleted": [ { "char_end": 79, "char_start": 75, "chars": "{id}" }, { "char_end": 88, "char_start": 81, "chars": ".format" }, { "char_end": 94, "char_start": 91, "chars": "=id" } ] }, "commit_link": "github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6", "file_name": "playlist/playlist_repository.py", "func_name": "delete_playlist", "line_changes": { "added": [ { "char_end": 87, "char_start": 29, "line": " db.execute(\"DELETE FROM playlist where id=%s;\", (id,))\n", "line_no": 2 } ], "deleted": [ { "char_end": 96, "char_start": 29, "line": " db.execute(\"DELETE FROM playlist where id={id};\".format(id=id))\n", "line_no": 2 } ] }, "vul_type": "cwe-089" }
204
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def writeToDb(self, url):\n try:", " self.cursor.execute(\"INSERT INTO queue (url, visited) VALUES ('{}', '0');\".format(url))", " self.db.commit()\n except Exception as e:\n print(e)" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 118, "char_start": 117, "chars": "?" }, { "char_end": 128, "char_start": 126, "chars": ", " } ], "deleted": [ { "char_end": 121, "char_start": 117, "chars": "'{}'" }, { "char_end": 137, "char_start": 129, "chars": ".format(" }, { "char_end": 141, "char_start": 140, "chars": ")" } ] }, "commit_link": "github.com/jappe999/WebScraper/commit/46a4e0843aa44d903293637afad53dfcbc37b480", "file_name": "beta/database.py", "func_name": "writeToDb", "line_changes": { "added": [ { "char_end": 133, "char_start": 43, "line": " self.cursor.execute(\"INSERT INTO queue (url, visited) VALUES (?, '0');\", url)\n", "line_no": 3 } ], "deleted": [ { "char_end": 143, "char_start": 43, "line": " self.cursor.execute(\"INSERT INTO queue (url, visited) VALUES ('{}', '0');\".format(url))\n", "line_no": 3 } ] }, "vul_type": "cwe-089" }
205
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def writeToDb(self, url):\n try:", " self.cursor.execute(\"INSERT INTO queue (url, visited) VALUES (?, '0');\", url)", " self.db.commit()\n except Exception as e:\n print(e)" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 118, "char_start": 117, "chars": "?" }, { "char_end": 128, "char_start": 126, "chars": ", " } ], "deleted": [ { "char_end": 121, "char_start": 117, "chars": "'{}'" }, { "char_end": 137, "char_start": 129, "chars": ".format(" }, { "char_end": 141, "char_start": 140, "chars": ")" } ] }, "commit_link": "github.com/jappe999/WebScraper/commit/46a4e0843aa44d903293637afad53dfcbc37b480", "file_name": "beta/database.py", "func_name": "writeToDb", "line_changes": { "added": [ { "char_end": 133, "char_start": 43, "line": " self.cursor.execute(\"INSERT INTO queue (url, visited) VALUES (?, '0');\", url)\n", "line_no": 3 } ], "deleted": [ { "char_end": 143, "char_start": 43, "line": " self.cursor.execute(\"INSERT INTO queue (url, visited) VALUES ('{}', '0');\".format(url))\n", "line_no": 3 } ] }, "vul_type": "cwe-089" }
205
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@frappe.whitelist(allow_guest=True)\ndef send_message(subject=\"Website Query\", message=\"\", sender=\"\", status=\"Open\"):\n\tfrom frappe.www.contact import send_message as website_send_message\n\tlead = customer = None", "\twebsite_send_message(subject, message, sender)", "\tcustomer = frappe.db.sql(\"\"\"select distinct dl.link_name from `tabDynamic Link` dl\n\t\tleft join `tabContact` c on dl.parent=c.name where dl.link_doctype='Customer'", "\t\tand c.email_id='{email_id}'\"\"\".format(email_id=sender))", "\n\tif not customer:\n\t\tlead = frappe.db.get_value('Lead', dict(email_id=sender))\n\t\tif not lead:\n\t\t\tnew_lead = frappe.get_doc(dict(\n\t\t\t\tdoctype='Lead',\n\t\t\t\temail_id = sender,\n\t\t\t\tlead_name = sender.split('@')[0].title()\n\t\t\t)).insert(ignore_permissions=True)", "\topportunity = frappe.get_doc(dict(\n\t\tdoctype ='Opportunity',\n\t\tenquiry_from = 'Customer' if customer else 'Lead',\n\t\tstatus = 'Open',\n\t\ttitle = subject,\n\t\tcontact_email = sender,\n\t\tto_discuss = message\n\t))", "\tif customer:\n\t\topportunity.customer = customer[0][0]\n\telif lead:\n\t\topportunity.lead = lead\n\telse:\n\t\topportunity.lead = new_lead.name", "\topportunity.insert(ignore_permissions=True)", "\tcomm = frappe.get_doc({\n\t\t\"doctype\":\"Communication\",\n\t\t\"subject\": subject,\n\t\t\"content\": message,\n\t\t\"sender\": sender,\n\t\t\"sent_or_received\": \"Received\",\n\t\t'reference_doctype': 'Opportunity',\n\t\t'reference_name': opportunity.name\n\t})\n\tcomm.insert(ignore_permissions=True)", "\treturn \"okay\"" ]
[ 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 441, "char_start": 440, "chars": " " }, { "char_end": 445, "char_start": 442, "chars": " %s" }, { "char_end": 450, "char_start": 448, "chars": ", " } ], "deleted": [ { "char_end": 453, "char_start": 441, "chars": "'{email_id}'" }, { "char_end": 473, "char_start": 456, "chars": ".format(email_id=" }, { "char_end": 480, "char_start": 479, "chars": ")" } ] }, "commit_link": "github.com/libracore/erpnext/commit/9acb885e60f77cd4e9ea8c98bdc39c18abcac731", "file_name": "erpnext/templates/utils.py", "func_name": "send_message", "line_changes": { "added": [ { "char_end": 458, "char_start": 424, "line": "\t\tand c.email_id = %s\"\"\", sender)\n", "line_no": 10 } ], "deleted": [ { "char_end": 482, "char_start": 424, "line": "\t\tand c.email_id='{email_id}'\"\"\".format(email_id=sender))\n", "line_no": 10 } ] }, "vul_type": "cwe-089" }
206
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@frappe.whitelist(allow_guest=True)\ndef send_message(subject=\"Website Query\", message=\"\", sender=\"\", status=\"Open\"):\n\tfrom frappe.www.contact import send_message as website_send_message\n\tlead = customer = None", "\twebsite_send_message(subject, message, sender)", "\tcustomer = frappe.db.sql(\"\"\"select distinct dl.link_name from `tabDynamic Link` dl\n\t\tleft join `tabContact` c on dl.parent=c.name where dl.link_doctype='Customer'", "\t\tand c.email_id = %s\"\"\", sender)", "\n\tif not customer:\n\t\tlead = frappe.db.get_value('Lead', dict(email_id=sender))\n\t\tif not lead:\n\t\t\tnew_lead = frappe.get_doc(dict(\n\t\t\t\tdoctype='Lead',\n\t\t\t\temail_id = sender,\n\t\t\t\tlead_name = sender.split('@')[0].title()\n\t\t\t)).insert(ignore_permissions=True)", "\topportunity = frappe.get_doc(dict(\n\t\tdoctype ='Opportunity',\n\t\tenquiry_from = 'Customer' if customer else 'Lead',\n\t\tstatus = 'Open',\n\t\ttitle = subject,\n\t\tcontact_email = sender,\n\t\tto_discuss = message\n\t))", "\tif customer:\n\t\topportunity.customer = customer[0][0]\n\telif lead:\n\t\topportunity.lead = lead\n\telse:\n\t\topportunity.lead = new_lead.name", "\topportunity.insert(ignore_permissions=True)", "\tcomm = frappe.get_doc({\n\t\t\"doctype\":\"Communication\",\n\t\t\"subject\": subject,\n\t\t\"content\": message,\n\t\t\"sender\": sender,\n\t\t\"sent_or_received\": \"Received\",\n\t\t'reference_doctype': 'Opportunity',\n\t\t'reference_name': opportunity.name\n\t})\n\tcomm.insert(ignore_permissions=True)", "\treturn \"okay\"" ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 441, "char_start": 440, "chars": " " }, { "char_end": 445, "char_start": 442, "chars": " %s" }, { "char_end": 450, "char_start": 448, "chars": ", " } ], "deleted": [ { "char_end": 453, "char_start": 441, "chars": "'{email_id}'" }, { "char_end": 473, "char_start": 456, "chars": ".format(email_id=" }, { "char_end": 480, "char_start": 479, "chars": ")" } ] }, "commit_link": "github.com/libracore/erpnext/commit/9acb885e60f77cd4e9ea8c98bdc39c18abcac731", "file_name": "erpnext/templates/utils.py", "func_name": "send_message", "line_changes": { "added": [ { "char_end": 458, "char_start": 424, "line": "\t\tand c.email_id = %s\"\"\", sender)\n", "line_no": 10 } ], "deleted": [ { "char_end": 482, "char_start": 424, "line": "\t\tand c.email_id='{email_id}'\"\"\".format(email_id=sender))\n", "line_no": 10 } ] }, "vul_type": "cwe-089" }
206
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@jwt_required\n def delete(self, email):\n \"\"\" Deletes admin with the corresponding email \"\"\"", " return database_utilities.execute_query(f\"\"\"delete from admins where email = '{email}'\"\"\")" ]
[ 1, 0 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 199, "char_start": 191, "chars": "%s\"\"\", (" }, { "char_end": 207, "char_start": 204, "chars": ", )" } ], "deleted": [ { "char_end": 193, "char_start": 191, "chars": "'{" }, { "char_end": 203, "char_start": 198, "chars": "}'\"\"\"" } ] }, "commit_link": "github.com/sgosal2/tiger-boards-backend/commit/4670109dd613df2f2fe7e8403ebd149df2b55485", "file_name": "apis/admins.py", "func_name": "delete", "line_changes": { "added": [ { "char_end": 208, "char_start": 106, "line": " return database_utilities.execute_query(f\"\"\"delete from admins where email = %s\"\"\", (email, ))", "line_no": 4 } ], "deleted": [ { "char_end": 204, "char_start": 106, "line": " return database_utilities.execute_query(f\"\"\"delete from admins where email = '{email}'\"\"\")\n", "line_no": 4 } ] }, "vul_type": "cwe-089" }
207
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@jwt_required\n def delete(self, email):\n \"\"\" Deletes admin with the corresponding email \"\"\"", " return database_utilities.execute_query(f\"\"\"delete from admins where email = %s\"\"\", (email, ))" ]
[ 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 199, "char_start": 191, "chars": "%s\"\"\", (" }, { "char_end": 207, "char_start": 204, "chars": ", )" } ], "deleted": [ { "char_end": 193, "char_start": 191, "chars": "'{" }, { "char_end": 203, "char_start": 198, "chars": "}'\"\"\"" } ] }, "commit_link": "github.com/sgosal2/tiger-boards-backend/commit/4670109dd613df2f2fe7e8403ebd149df2b55485", "file_name": "apis/admins.py", "func_name": "delete", "line_changes": { "added": [ { "char_end": 208, "char_start": 106, "line": " return database_utilities.execute_query(f\"\"\"delete from admins where email = %s\"\"\", (email, ))", "line_no": 4 } ], "deleted": [ { "char_end": 204, "char_start": 106, "line": " return database_utilities.execute_query(f\"\"\"delete from admins where email = '{email}'\"\"\")\n", "line_no": 4 } ] }, "vul_type": "cwe-089" }
207
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def delete_playlists_videos(playlist_id, db):", " db.execute(\"DELETE FROM video where playlist_id={playlist_id};\".format(\n playlist_id=playlist_id))" ]
[ 1, 0 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 99, "char_start": 98, "chars": "%" }, { "char_end": 104, "char_start": 102, "chars": ", " }, { "char_end": 117, "char_start": 116, "chars": "," } ], "deleted": [ { "char_end": 105, "char_start": 98, "chars": "{playli" }, { "char_end": 111, "char_start": 106, "chars": "t_id}" }, { "char_end": 127, "char_start": 113, "chars": ".format(\n " }, { "char_end": 142, "char_start": 128, "chars": " playlist_id=" } ] }, "commit_link": "github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6", "file_name": "video/video_repository.py", "func_name": "delete_playlists_videos", "line_changes": { "added": [ { "char_end": 119, "char_start": 46, "line": " db.execute(\"DELETE FROM video where playlist_id=%s;\", (playlist_id,))\n", "line_no": 2 } ], "deleted": [ { "char_end": 122, "char_start": 46, "line": " db.execute(\"DELETE FROM video where playlist_id={playlist_id};\".format(\n", "line_no": 2 }, { "char_end": 155, "char_start": 122, "line": " playlist_id=playlist_id))\n", "line_no": 3 } ] }, "vul_type": "cwe-089" }
208
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def delete_playlists_videos(playlist_id, db):", " db.execute(\"DELETE FROM video where playlist_id=%s;\", (playlist_id,))" ]
[ 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 99, "char_start": 98, "chars": "%" }, { "char_end": 104, "char_start": 102, "chars": ", " }, { "char_end": 117, "char_start": 116, "chars": "," } ], "deleted": [ { "char_end": 105, "char_start": 98, "chars": "{playli" }, { "char_end": 111, "char_start": 106, "chars": "t_id}" }, { "char_end": 127, "char_start": 113, "chars": ".format(\n " }, { "char_end": 142, "char_start": 128, "chars": " playlist_id=" } ] }, "commit_link": "github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6", "file_name": "video/video_repository.py", "func_name": "delete_playlists_videos", "line_changes": { "added": [ { "char_end": 119, "char_start": 46, "line": " db.execute(\"DELETE FROM video where playlist_id=%s;\", (playlist_id,))\n", "line_no": 2 } ], "deleted": [ { "char_end": 122, "char_start": 46, "line": " db.execute(\"DELETE FROM video where playlist_id={playlist_id};\".format(\n", "line_no": 2 }, { "char_end": 155, "char_start": 122, "line": " playlist_id=playlist_id))\n", "line_no": 3 } ] }, "vul_type": "cwe-089" }
208
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@staticmethod\n def upsert_mapped_projects(user_id: int, project_id: int):\n \"\"\" Adds projects to mapped_projects if it doesn't exist \"\"\"", " sql = \"select * from users where id = {0} and projects_mapped @> '{{{1}}}'\".format(user_id, project_id)\n result = db.engine.execute(sql)", "\n if result.rowcount > 0:\n return # User has previously mapped this project so return", " sql = '''update users", " set projects_mapped = array_append(projects_mapped, {0})\n where id = {1}'''.format(project_id, user_id)", "", " db.engine.execute(sql)" ]
[ 1, 0, 1, 1, 0, 1, 0 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 204, "char_start": 196, "chars": ":user_id" }, { "char_end": 232, "char_start": 231, "chars": ":" }, { "char_end": 246, "char_start": 242, "chars": "}}'\"" }, { "char_end": 287, "char_start": 282, "chars": "text(" }, { "char_end": 331, "char_start": 290, "chars": "), user_id=user_id, project_id=project_id" }, { "char_end": 552, "char_start": 541, "chars": ":project_id" }, { "char_end": 584, "char_start": 583, "chars": ":" }, { "char_end": 594, "char_start": 591, "chars": "'''" }, { "char_end": 627, "char_start": 622, "chars": "text(" }, { "char_end": 672, "char_start": 631, "chars": ", project_id=project_id, user_id=user_id)" } ], "deleted": [ { "char_end": 199, "char_start": 196, "chars": "{0}" }, { "char_end": 250, "char_start": 226, "chars": "{1}}}'\".format(user_id, " }, { "char_end": 261, "char_start": 260, "chars": ")" }, { "char_end": 513, "char_start": 510, "chars": "{0}" }, { "char_end": 570, "char_start": 544, "chars": "{1}'''.format(project_id, " }, { "char_end": 578, "char_start": 577, "chars": ")" } ] }, "commit_link": "github.com/hotosm/tasking-manager/commit/dee040a2d22b3c4d5e38e2dbf8c6b651ad4c241a", "file_name": "server/models/postgis/user.py", "func_name": "upsert_mapped_projects", "line_changes": { "added": [ { "char_end": 247, "char_start": 150, "line": " sql = \"select * from users where id = :user_id and projects_mapped @> '{{:project_id}}'\"\n", "line_no": 4 }, { "char_end": 333, "char_start": 247, "line": " result = db.engine.execute(text(sql), user_id=user_id, project_id=project_id)\n", "line_no": 5 }, { "char_end": 554, "char_start": 469, "line": " set projects_mapped = array_append(projects_mapped, :project_id)\n", "line_no": 11 }, { "char_end": 595, "char_start": 554, "line": " where id = :user_id'''\n", "line_no": 12 }, { "char_end": 672, "char_start": 596, "line": " db.engine.execute(text(sql), project_id=project_id, user_id=user_id)\n", "line_no": 14 } ], "deleted": [ { "char_end": 262, "char_start": 150, "line": " sql = \"select * from users where id = {0} and projects_mapped @> '{{{1}}}'\".format(user_id, project_id)\n", "line_no": 4 }, { "char_end": 302, "char_start": 262, "line": " result = db.engine.execute(sql)\n", "line_no": 5 }, { "char_end": 515, "char_start": 438, "line": " set projects_mapped = array_append(projects_mapped, {0})\n", "line_no": 11 }, { "char_end": 579, "char_start": 515, "line": " where id = {1}'''.format(project_id, user_id)\n", "line_no": 12 }, { "char_end": 610, "char_start": 580, "line": " db.engine.execute(sql)\n", "line_no": 14 } ] }, "vul_type": "cwe-089" }
209
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@staticmethod\n def upsert_mapped_projects(user_id: int, project_id: int):\n \"\"\" Adds projects to mapped_projects if it doesn't exist \"\"\"", " sql = \"select * from users where id = :user_id and projects_mapped @> '{{:project_id}}'\"\n result = db.engine.execute(text(sql), user_id=user_id, project_id=project_id)", "\n if result.rowcount > 0:\n return # User has previously mapped this project so return", " sql = '''update users", " set projects_mapped = array_append(projects_mapped, :project_id)\n where id = :user_id'''", "", " db.engine.execute(text(sql), project_id=project_id, user_id=user_id)" ]
[ 1, 1, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 204, "char_start": 196, "chars": ":user_id" }, { "char_end": 232, "char_start": 231, "chars": ":" }, { "char_end": 246, "char_start": 242, "chars": "}}'\"" }, { "char_end": 287, "char_start": 282, "chars": "text(" }, { "char_end": 331, "char_start": 290, "chars": "), user_id=user_id, project_id=project_id" }, { "char_end": 552, "char_start": 541, "chars": ":project_id" }, { "char_end": 584, "char_start": 583, "chars": ":" }, { "char_end": 594, "char_start": 591, "chars": "'''" }, { "char_end": 627, "char_start": 622, "chars": "text(" }, { "char_end": 672, "char_start": 631, "chars": ", project_id=project_id, user_id=user_id)" } ], "deleted": [ { "char_end": 199, "char_start": 196, "chars": "{0}" }, { "char_end": 250, "char_start": 226, "chars": "{1}}}'\".format(user_id, " }, { "char_end": 261, "char_start": 260, "chars": ")" }, { "char_end": 513, "char_start": 510, "chars": "{0}" }, { "char_end": 570, "char_start": 544, "chars": "{1}'''.format(project_id, " }, { "char_end": 578, "char_start": 577, "chars": ")" } ] }, "commit_link": "github.com/hotosm/tasking-manager/commit/dee040a2d22b3c4d5e38e2dbf8c6b651ad4c241a", "file_name": "server/models/postgis/user.py", "func_name": "upsert_mapped_projects", "line_changes": { "added": [ { "char_end": 247, "char_start": 150, "line": " sql = \"select * from users where id = :user_id and projects_mapped @> '{{:project_id}}'\"\n", "line_no": 4 }, { "char_end": 333, "char_start": 247, "line": " result = db.engine.execute(text(sql), user_id=user_id, project_id=project_id)\n", "line_no": 5 }, { "char_end": 554, "char_start": 469, "line": " set projects_mapped = array_append(projects_mapped, :project_id)\n", "line_no": 11 }, { "char_end": 595, "char_start": 554, "line": " where id = :user_id'''\n", "line_no": 12 }, { "char_end": 672, "char_start": 596, "line": " db.engine.execute(text(sql), project_id=project_id, user_id=user_id)\n", "line_no": 14 } ], "deleted": [ { "char_end": 262, "char_start": 150, "line": " sql = \"select * from users where id = {0} and projects_mapped @> '{{{1}}}'\".format(user_id, project_id)\n", "line_no": 4 }, { "char_end": 302, "char_start": 262, "line": " result = db.engine.execute(sql)\n", "line_no": 5 }, { "char_end": 515, "char_start": 438, "line": " set projects_mapped = array_append(projects_mapped, {0})\n", "line_no": 11 }, { "char_end": 579, "char_start": 515, "line": " where id = {1}'''.format(project_id, user_id)\n", "line_no": 12 }, { "char_end": 610, "char_start": 580, "line": " db.engine.execute(sql)\n", "line_no": 14 } ] }, "vul_type": "cwe-089" }
209
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def get_first_ranked_month(db, scene, player):", " sql = \"select date from ranks where scene='{}' and player='{}' order by date limit 1;\".format(scene, player)\n res = db.exec(sql)", " date = res[0][0]\n return date" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 100, "char_start": 95, "chars": "scene" }, { "char_end": 122, "char_start": 116, "chars": "player" }, { "char_end": 153, "char_start": 148, "chars": "\n " }, { "char_end": 170, "char_start": 154, "chars": "rgs = {'scene': " }, { "char_end": 178, "char_start": 177, "chars": "'" }, { "char_end": 194, "char_start": 184, "chars": "': player}" }, { "char_end": 222, "char_start": 216, "chars": ", args" } ], "deleted": [ { "char_end": 140, "char_start": 137, "chars": ".fo" }, { "char_end": 145, "char_start": 141, "chars": "mat(" }, { "char_end": 159, "char_start": 158, "chars": ")" } ] }, "commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63", "file_name": "bracket_utils.py", "func_name": "get_first_ranked_month", "line_changes": { "added": [ { "char_end": 149, "char_start": 47, "line": " sql = \"select date from ranks where scene='{scene}' and player='{player}' order by date limit 1;\"\n", "line_no": 2 }, { "char_end": 195, "char_start": 149, "line": " args = {'scene': scene, 'player': player}\n", "line_no": 3 }, { "char_end": 224, "char_start": 195, "line": " res = db.exec(sql, args)\n", "line_no": 4 } ], "deleted": [ { "char_end": 160, "char_start": 47, "line": " sql = \"select date from ranks where scene='{}' and player='{}' order by date limit 1;\".format(scene, player)\n", "line_no": 2 }, { "char_end": 183, "char_start": 160, "line": " res = db.exec(sql)\n", "line_no": 3 } ] }, "vul_type": "cwe-089" }
210
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def get_first_ranked_month(db, scene, player):", " sql = \"select date from ranks where scene='{scene}' and player='{player}' order by date limit 1;\"\n args = {'scene': scene, 'player': player}\n res = db.exec(sql, args)", " date = res[0][0]\n return date" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 100, "char_start": 95, "chars": "scene" }, { "char_end": 122, "char_start": 116, "chars": "player" }, { "char_end": 153, "char_start": 148, "chars": "\n " }, { "char_end": 170, "char_start": 154, "chars": "rgs = {'scene': " }, { "char_end": 178, "char_start": 177, "chars": "'" }, { "char_end": 194, "char_start": 184, "chars": "': player}" }, { "char_end": 222, "char_start": 216, "chars": ", args" } ], "deleted": [ { "char_end": 140, "char_start": 137, "chars": ".fo" }, { "char_end": 145, "char_start": 141, "chars": "mat(" }, { "char_end": 159, "char_start": 158, "chars": ")" } ] }, "commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63", "file_name": "bracket_utils.py", "func_name": "get_first_ranked_month", "line_changes": { "added": [ { "char_end": 149, "char_start": 47, "line": " sql = \"select date from ranks where scene='{scene}' and player='{player}' order by date limit 1;\"\n", "line_no": 2 }, { "char_end": 195, "char_start": 149, "line": " args = {'scene': scene, 'player': player}\n", "line_no": 3 }, { "char_end": 224, "char_start": 195, "line": " res = db.exec(sql, args)\n", "line_no": 4 } ], "deleted": [ { "char_end": 160, "char_start": 47, "line": " sql = \"select date from ranks where scene='{}' and player='{}' order by date limit 1;\".format(scene, player)\n", "line_no": 2 }, { "char_end": 183, "char_start": 160, "line": " res = db.exec(sql)\n", "line_no": 3 } ] }, "vul_type": "cwe-089" }
210
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@hook.command(adminonly=True)\ndef openPoll(question, reply=None, db=None):\n \"\"\"Creates a new poll.\"\"\"\n if not db_ready: db_init(db)\n try:\n active = db.execute(\"SELECT pollID FROM polls WHERE active = 1\").fetchone()[0]\n if active: \n reply(\"There already is an open poll.\")\n return\n except:", " db.execute(\"INSERT INTO polls (question, active) VALUES ('{}', 1)\".format(question))", " reply(\"Opened new poll: {}\".format(question))\n #reply(\"Poll opened!\")\n return" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 403, "char_start": 402, "chars": "?" }, { "char_end": 410, "char_start": 408, "chars": ", " }, { "char_end": 420, "char_start": 419, "chars": "," } ], "deleted": [ { "char_end": 406, "char_start": 402, "chars": "'{}'" }, { "char_end": 418, "char_start": 411, "chars": ".format" } ] }, "commit_link": "github.com/FrozenPigs/Taigabot/commit/ea9b83a66ae1f0f38a1895f3e8dfa2833d77e3a6", "file_name": "plugins/poll.py", "func_name": "openPoll", "line_changes": { "added": [ { "char_end": 423, "char_start": 337, "line": " db.execute(\"INSERT INTO polls (question, active) VALUES (?, 1)\", (question,))\n", "line_no": 11 } ], "deleted": [ { "char_end": 430, "char_start": 337, "line": " db.execute(\"INSERT INTO polls (question, active) VALUES ('{}', 1)\".format(question))\n", "line_no": 11 } ] }, "vul_type": "cwe-089" }
211
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@hook.command(adminonly=True)\ndef openPoll(question, reply=None, db=None):\n \"\"\"Creates a new poll.\"\"\"\n if not db_ready: db_init(db)\n try:\n active = db.execute(\"SELECT pollID FROM polls WHERE active = 1\").fetchone()[0]\n if active: \n reply(\"There already is an open poll.\")\n return\n except:", " db.execute(\"INSERT INTO polls (question, active) VALUES (?, 1)\", (question,))", " reply(\"Opened new poll: {}\".format(question))\n #reply(\"Poll opened!\")\n return" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 403, "char_start": 402, "chars": "?" }, { "char_end": 410, "char_start": 408, "chars": ", " }, { "char_end": 420, "char_start": 419, "chars": "," } ], "deleted": [ { "char_end": 406, "char_start": 402, "chars": "'{}'" }, { "char_end": 418, "char_start": 411, "chars": ".format" } ] }, "commit_link": "github.com/FrozenPigs/Taigabot/commit/ea9b83a66ae1f0f38a1895f3e8dfa2833d77e3a6", "file_name": "plugins/poll.py", "func_name": "openPoll", "line_changes": { "added": [ { "char_end": 423, "char_start": 337, "line": " db.execute(\"INSERT INTO polls (question, active) VALUES (?, 1)\", (question,))\n", "line_no": 11 } ], "deleted": [ { "char_end": 430, "char_start": 337, "line": " db.execute(\"INSERT INTO polls (question, active) VALUES ('{}', 1)\".format(question))\n", "line_no": 11 } ] }, "vul_type": "cwe-089" }
211
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def view_grocery_list():\n print(\"grocery== list\")\n groceryListFrame = Frame(self)\n groceryListFrame.rowconfigure(0, weight=1)\n groceryListFrame.columnconfigure(0, weight=1)\n groceryListFrame.rowconfigure(1, weight=3)\n groceryListFrame.columnconfigure(1, weight=3)\n groceryListFrame.pack()", " menu.pack_forget()\n groceryButton.pack_forget()\n label.configure(text=\"Grocery List\")", " i = 0\n database_file = \"meal_planner.db\"\n item_array = []\n with sqlite3.connect(database_file) as conn:\n cursor = conn.cursor()\n tableName = \"ingredients_\" + str(weekNumber)", " selection = cursor.execute(\"\"\"SELECT * FROM \"\"\" + tableName)", " for result in [selection]:\n for row in result.fetchall():\n print(row)\n for ingredient in row:\n print(ingredient)\n item_array.append(str(ingredient).split())\n i = i +1\n Label(groceryListFrame, text=ingredient, font=MEDIUM_FONT, justify=LEFT).grid(row=i, column=0, sticky=\"w\")\n ", " j = 0\n for item in item_array:\n print(item)", "\n returnButton = Button(menuFrame, text = \"Return to Menu\", highlightbackground=\"#e7e7e7\", command=lambda: [groceryListFrame.pack_forget(),\n menu.pack(), returnButton.pack_forget(), label.configure(text=\"Meal Planer\"),\n groceryButton.pack(side=RIGHT)])\n returnButton.pack(side=RIGHT)" ]
[ 1, 1, 1, 0, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 807, "char_start": 805, "chars": "?;" }, { "char_end": 811, "char_start": 810, "chars": "," }, { "char_end": 813, "char_start": 812, "chars": "(" }, { "char_end": 825, "char_start": 822, "chars": ", )" } ], "deleted": [ { "char_end": 811, "char_start": 809, "chars": "+ " } ] }, "commit_link": "github.com/trishamoyer/RecipePlanner-Python/commit/44d2ce370715d9344fad34b3b749322ab095a925", "file_name": "mealPlan.py", "func_name": "__init__.view_grocery_list", "line_changes": { "added": [ { "char_end": 827, "char_start": 745, "line": " selection = cursor.execute(\"\"\"SELECT * FROM ?;\"\"\", (tableName, ))\n", "line_no": 20 } ], "deleted": [ { "char_end": 822, "char_start": 745, "line": " selection = cursor.execute(\"\"\"SELECT * FROM \"\"\" + tableName)\n", "line_no": 20 } ] }, "vul_type": "cwe-089" }
212
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def view_grocery_list():\n print(\"grocery== list\")\n groceryListFrame = Frame(self)\n groceryListFrame.rowconfigure(0, weight=1)\n groceryListFrame.columnconfigure(0, weight=1)\n groceryListFrame.rowconfigure(1, weight=3)\n groceryListFrame.columnconfigure(1, weight=3)\n groceryListFrame.pack()", " menu.pack_forget()\n groceryButton.pack_forget()\n label.configure(text=\"Grocery List\")", " i = 0\n database_file = \"meal_planner.db\"\n item_array = []\n with sqlite3.connect(database_file) as conn:\n cursor = conn.cursor()\n tableName = \"ingredients_\" + str(weekNumber)", " selection = cursor.execute(\"\"\"SELECT * FROM ?;\"\"\", (tableName, ))", " for result in [selection]:\n for row in result.fetchall():\n print(row)\n for ingredient in row:\n print(ingredient)\n item_array.append(str(ingredient).split())\n i = i +1\n Label(groceryListFrame, text=ingredient, font=MEDIUM_FONT, justify=LEFT).grid(row=i, column=0, sticky=\"w\")\n ", " j = 0\n for item in item_array:\n print(item)", "\n returnButton = Button(menuFrame, text = \"Return to Menu\", highlightbackground=\"#e7e7e7\", command=lambda: [groceryListFrame.pack_forget(),\n menu.pack(), returnButton.pack_forget(), label.configure(text=\"Meal Planer\"),\n groceryButton.pack(side=RIGHT)])\n returnButton.pack(side=RIGHT)" ]
[ 1, 1, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 807, "char_start": 805, "chars": "?;" }, { "char_end": 811, "char_start": 810, "chars": "," }, { "char_end": 813, "char_start": 812, "chars": "(" }, { "char_end": 825, "char_start": 822, "chars": ", )" } ], "deleted": [ { "char_end": 811, "char_start": 809, "chars": "+ " } ] }, "commit_link": "github.com/trishamoyer/RecipePlanner-Python/commit/44d2ce370715d9344fad34b3b749322ab095a925", "file_name": "mealPlan.py", "func_name": "__init__.view_grocery_list", "line_changes": { "added": [ { "char_end": 827, "char_start": 745, "line": " selection = cursor.execute(\"\"\"SELECT * FROM ?;\"\"\", (tableName, ))\n", "line_no": 20 } ], "deleted": [ { "char_end": 822, "char_start": 745, "line": " selection = cursor.execute(\"\"\"SELECT * FROM \"\"\" + tableName)\n", "line_no": 20 } ] }, "vul_type": "cwe-089" }
212
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@app.route('/<page_name>/history/record')\ndef view_page_record(page_name):\n content_id = request.args.get('id')", " query = db.query(\"select page_content.content, page_content.timestamp from page, page_content where page.id = page_content.page_id and page_content.id = '%s'\" % content_id)", " page_record = query.namedresult()[0]", " return render_template(\n 'page_record.html',\n page_name = page_name,\n page_record = page_record\n )" ]
[ 1, 0, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 274, "char_start": 272, "chars": "$1" }, { "char_end": 276, "char_start": 275, "chars": "," } ], "deleted": [ { "char_end": 276, "char_start": 272, "chars": "'%s'" }, { "char_end": 279, "char_start": 277, "chars": " %" } ] }, "commit_link": "github.com/Pumala/python_wiki_app_redo/commit/65d60747cd8efb05970304234d3bd949d2088e8b", "file_name": "server.py", "func_name": "view_page_record", "line_changes": { "added": [ { "char_end": 289, "char_start": 115, "line": " query = db.query(\"select page_content.content, page_content.timestamp from page, page_content where page.id = page_content.page_id and page_content.id = $1\", content_id)\n", "line_no": 4 } ], "deleted": [ { "char_end": 292, "char_start": 115, "line": " query = db.query(\"select page_content.content, page_content.timestamp from page, page_content where page.id = page_content.page_id and page_content.id = '%s'\" % content_id)\n", "line_no": 4 } ] }, "vul_type": "cwe-089" }
213
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@app.route('/<page_name>/history/record')\ndef view_page_record(page_name):\n content_id = request.args.get('id')", " query = db.query(\"select page_content.content, page_content.timestamp from page, page_content where page.id = page_content.page_id and page_content.id = $1\", content_id)", " page_record = query.namedresult()[0]", " return render_template(\n 'page_record.html',\n page_name = page_name,\n page_record = page_record\n )" ]
[ 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 274, "char_start": 272, "chars": "$1" }, { "char_end": 276, "char_start": 275, "chars": "," } ], "deleted": [ { "char_end": 276, "char_start": 272, "chars": "'%s'" }, { "char_end": 279, "char_start": 277, "chars": " %" } ] }, "commit_link": "github.com/Pumala/python_wiki_app_redo/commit/65d60747cd8efb05970304234d3bd949d2088e8b", "file_name": "server.py", "func_name": "view_page_record", "line_changes": { "added": [ { "char_end": 289, "char_start": 115, "line": " query = db.query(\"select page_content.content, page_content.timestamp from page, page_content where page.id = page_content.page_id and page_content.id = $1\", content_id)\n", "line_no": 4 } ], "deleted": [ { "char_end": 292, "char_start": 115, "line": " query = db.query(\"select page_content.content, page_content.timestamp from page, page_content where page.id = page_content.page_id and page_content.id = '%s'\" % content_id)\n", "line_no": 4 } ] }, "vul_type": "cwe-089" }
213
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def update_inverter(self, inverter_serial, ts, status, etoday, etotal):\n query = '''\n UPDATE Inverters\n SET ", " TimeStamp='%s', \n Status='%s', \n eToday='%s',\n eTotal='%s'\n WHERE Serial='%s';\n ''' % (ts, status, etoday, etotal, inverter_serial)\n self.c.execute(query)" ]
[ 1, 0 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 173, "char_start": 172, "chars": "?" }, { "char_end": 200, "char_start": 199, "chars": "?" }, { "char_end": 227, "char_start": 226, "chars": "?" }, { "char_end": 253, "char_start": 252, "chars": "?" }, { "char_end": 280, "char_start": 279, "chars": "?" }, { "char_end": 300, "char_start": 293, "chars": "\n " }, { "char_end": 323, "char_start": 301, "chars": " self.c.execute(query," } ], "deleted": [ { "char_end": 176, "char_start": 172, "chars": "'%s'" }, { "char_end": 206, "char_start": 202, "chars": "'%s'" }, { "char_end": 236, "char_start": 232, "chars": "'%s'" }, { "char_end": 265, "char_start": 261, "chars": "'%s'" }, { "char_end": 295, "char_start": 291, "chars": "'%s'" }, { "char_end": 310, "char_start": 309, "chars": "%" }, { "char_end": 385, "char_start": 356, "chars": "\n self.c.execute(query" } ] }, "commit_link": "github.com/philipptrenz/s0-bridge/commit/269b48caa05377b7c58c3e6d1622a4429cb5ba65", "file_name": "util/database.py", "func_name": "update_inverter", "line_changes": { "added": [ { "char_end": 176, "char_start": 146, "line": " TimeStamp=?, \n", "line_no": 5 }, { "char_end": 203, "char_start": 176, "line": " Status=?, \n", "line_no": 6 }, { "char_end": 229, "char_start": 203, "line": " eToday=?,\n", "line_no": 7 }, { "char_end": 254, "char_start": 229, "line": " eTotal=?\n", "line_no": 8 }, { "char_end": 282, "char_start": 254, "line": " WHERE Serial=?;\n", "line_no": 9 }, { "char_end": 294, "char_start": 282, "line": " '''\n", "line_no": 10 }, { "char_end": 370, "char_start": 294, "line": " self.c.execute(query, (ts, status, etoday, etotal, inverter_serial))\n", "line_no": 11 } ], "deleted": [ { "char_end": 179, "char_start": 146, "line": " TimeStamp='%s', \n", "line_no": 5 }, { "char_end": 209, "char_start": 179, "line": " Status='%s', \n", "line_no": 6 }, { "char_end": 238, "char_start": 209, "line": " eToday='%s',\n", "line_no": 7 }, { "char_end": 266, "char_start": 238, "line": " eTotal='%s'\n", "line_no": 8 }, { "char_end": 297, "char_start": 266, "line": " WHERE Serial='%s';\n", "line_no": 9 }, { "char_end": 357, "char_start": 297, "line": " ''' % (ts, status, etoday, etotal, inverter_serial)\n", "line_no": 10 }, { "char_end": 386, "char_start": 357, "line": " self.c.execute(query)\n", "line_no": 11 } ] }, "vul_type": "cwe-089" }
214
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def update_inverter(self, inverter_serial, ts, status, etoday, etotal):\n query = '''\n UPDATE Inverters\n SET ", " TimeStamp=?, \n Status=?, \n eToday=?,\n eTotal=?\n WHERE Serial=?;\n '''\n self.c.execute(query, (ts, status, etoday, etotal, inverter_serial))" ]
[ 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 173, "char_start": 172, "chars": "?" }, { "char_end": 200, "char_start": 199, "chars": "?" }, { "char_end": 227, "char_start": 226, "chars": "?" }, { "char_end": 253, "char_start": 252, "chars": "?" }, { "char_end": 280, "char_start": 279, "chars": "?" }, { "char_end": 300, "char_start": 293, "chars": "\n " }, { "char_end": 323, "char_start": 301, "chars": " self.c.execute(query," } ], "deleted": [ { "char_end": 176, "char_start": 172, "chars": "'%s'" }, { "char_end": 206, "char_start": 202, "chars": "'%s'" }, { "char_end": 236, "char_start": 232, "chars": "'%s'" }, { "char_end": 265, "char_start": 261, "chars": "'%s'" }, { "char_end": 295, "char_start": 291, "chars": "'%s'" }, { "char_end": 310, "char_start": 309, "chars": "%" }, { "char_end": 385, "char_start": 356, "chars": "\n self.c.execute(query" } ] }, "commit_link": "github.com/philipptrenz/s0-bridge/commit/269b48caa05377b7c58c3e6d1622a4429cb5ba65", "file_name": "util/database.py", "func_name": "update_inverter", "line_changes": { "added": [ { "char_end": 176, "char_start": 146, "line": " TimeStamp=?, \n", "line_no": 5 }, { "char_end": 203, "char_start": 176, "line": " Status=?, \n", "line_no": 6 }, { "char_end": 229, "char_start": 203, "line": " eToday=?,\n", "line_no": 7 }, { "char_end": 254, "char_start": 229, "line": " eTotal=?\n", "line_no": 8 }, { "char_end": 282, "char_start": 254, "line": " WHERE Serial=?;\n", "line_no": 9 }, { "char_end": 294, "char_start": 282, "line": " '''\n", "line_no": 10 }, { "char_end": 370, "char_start": 294, "line": " self.c.execute(query, (ts, status, etoday, etotal, inverter_serial))\n", "line_no": 11 } ], "deleted": [ { "char_end": 179, "char_start": 146, "line": " TimeStamp='%s', \n", "line_no": 5 }, { "char_end": 209, "char_start": 179, "line": " Status='%s', \n", "line_no": 6 }, { "char_end": 238, "char_start": 209, "line": " eToday='%s',\n", "line_no": 7 }, { "char_end": 266, "char_start": 238, "line": " eTotal='%s'\n", "line_no": 8 }, { "char_end": 297, "char_start": 266, "line": " WHERE Serial='%s';\n", "line_no": 9 }, { "char_end": 357, "char_start": 297, "line": " ''' % (ts, status, etoday, etotal, inverter_serial)\n", "line_no": 10 }, { "char_end": 386, "char_start": 357, "line": " self.c.execute(query)\n", "line_no": 11 } ] }, "vul_type": "cwe-089" }
214
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def insert(key, value):\n connection = psycopg2.connect(host=config['HOST'], port=config['PORT'], database=config['NAME'], user=config['USER'], password=config['PASSWORD'])\n cur = connection.cursor()\n try:", " cur.execute(\"insert into reply_map values('{}', '{}')\".format(key, value))", " connection.commit()\n except:\n pass" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 265, "char_start": 264, "chars": "?" }, { "char_end": 268, "char_start": 267, "chars": "?" }, { "char_end": 272, "char_start": 270, "chars": ", " } ], "deleted": [ { "char_end": 268, "char_start": 264, "chars": "'{}'" }, { "char_end": 274, "char_start": 270, "chars": "'{}'" }, { "char_end": 283, "char_start": 276, "chars": ".format" } ] }, "commit_link": "github.com/tadaren/reply_bot/commit/5aeafa7e9597a766992af9ff8189e1f050b6579b", "file_name": "db.py", "func_name": "insert", "line_changes": { "added": [ { "char_end": 286, "char_start": 214, "line": " cur.execute(\"insert into reply_map values(?, ?)\", (key, value))\n", "line_no": 5 } ], "deleted": [ { "char_end": 297, "char_start": 214, "line": " cur.execute(\"insert into reply_map values('{}', '{}')\".format(key, value))\n", "line_no": 5 } ] }, "vul_type": "cwe-089" }
215
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def insert(key, value):\n connection = psycopg2.connect(host=config['HOST'], port=config['PORT'], database=config['NAME'], user=config['USER'], password=config['PASSWORD'])\n cur = connection.cursor()\n try:", " cur.execute(\"insert into reply_map values(?, ?)\", (key, value))", " connection.commit()\n except:\n pass" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 265, "char_start": 264, "chars": "?" }, { "char_end": 268, "char_start": 267, "chars": "?" }, { "char_end": 272, "char_start": 270, "chars": ", " } ], "deleted": [ { "char_end": 268, "char_start": 264, "chars": "'{}'" }, { "char_end": 274, "char_start": 270, "chars": "'{}'" }, { "char_end": 283, "char_start": 276, "chars": ".format" } ] }, "commit_link": "github.com/tadaren/reply_bot/commit/5aeafa7e9597a766992af9ff8189e1f050b6579b", "file_name": "db.py", "func_name": "insert", "line_changes": { "added": [ { "char_end": 286, "char_start": 214, "line": " cur.execute(\"insert into reply_map values(?, ?)\", (key, value))\n", "line_no": 5 } ], "deleted": [ { "char_end": 297, "char_start": 214, "line": " cur.execute(\"insert into reply_map values('{}', '{}')\".format(key, value))\n", "line_no": 5 } ] }, "vul_type": "cwe-089" }
215
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def save_failure_transaction(self, user_id, project_id, money):", " self.cursor.execute(\"insert into transactions (project_id,user_id, money, timestamp, state) values (%s, %s, %s, now(), 'failed' )\" % (project_id, user_id, money))", " self.db.commit()" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 215, "char_start": 184, "chars": "\"\n \"" }, { "char_end": 238, "char_start": 237, "chars": "," } ], "deleted": [ { "char_end": 208, "char_start": 206, "chars": " %" } ] }, "commit_link": "github.com/JLucka/kickstarter-dev/commit/e2ffa062697e060fdfbd2eccbb89a8c53a569e0b", "file_name": "backend/transactions/TransactionConnector.py", "func_name": "save_failure_transaction", "line_changes": { "added": [ { "char_end": 186, "char_start": 68, "line": " self.cursor.execute(\"insert into transactions (project_id,user_id, money, timestamp, state) values (%s, %s, \"\n", "line_no": 2 }, { "char_end": 269, "char_start": 186, "line": " \"%s, now(), 'failed' )\", (project_id, user_id, money))\n", "line_no": 3 } ], "deleted": [ { "char_end": 239, "char_start": 68, "line": " self.cursor.execute(\"insert into transactions (project_id,user_id, money, timestamp, state) values (%s, %s, %s, now(), 'failed' )\" % (project_id, user_id, money))\n", "line_no": 2 } ] }, "vul_type": "cwe-089" }
216
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def save_failure_transaction(self, user_id, project_id, money):", " self.cursor.execute(\"insert into transactions (project_id,user_id, money, timestamp, state) values (%s, %s, \"\n \"%s, now(), 'failed' )\", (project_id, user_id, money))", " self.db.commit()" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 215, "char_start": 184, "chars": "\"\n \"" }, { "char_end": 238, "char_start": 237, "chars": "," } ], "deleted": [ { "char_end": 208, "char_start": 206, "chars": " %" } ] }, "commit_link": "github.com/JLucka/kickstarter-dev/commit/e2ffa062697e060fdfbd2eccbb89a8c53a569e0b", "file_name": "backend/transactions/TransactionConnector.py", "func_name": "save_failure_transaction", "line_changes": { "added": [ { "char_end": 186, "char_start": 68, "line": " self.cursor.execute(\"insert into transactions (project_id,user_id, money, timestamp, state) values (%s, %s, \"\n", "line_no": 2 }, { "char_end": 269, "char_start": 186, "line": " \"%s, now(), 'failed' )\", (project_id, user_id, money))\n", "line_no": 3 } ], "deleted": [ { "char_end": 239, "char_start": 68, "line": " self.cursor.execute(\"insert into transactions (project_id,user_id, money, timestamp, state) values (%s, %s, %s, now(), 'failed' )\" % (project_id, user_id, money))\n", "line_no": 2 } ] }, "vul_type": "cwe-089" }
216
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@unpack\n def test_process_as_form(self, job_number, dcn_key, was_prev_matched,\n was_prev_closed, was_prev_tracked):\n email_obj = {\n 'sender' : \"Alex Roy <Alex.Roy@dilfo.com>\",\n 'subject' : \"DO NOT MODIFY MESSAGE BELOW - JUST HIT `SEND`\",\n 'date' : \"Tue, 7 May 2019 17:34:17 +0000\",\n 'content' : (\n f\"job_number={job_number}&title=TEST_ENTRY&city=Ottawa&\"\n f\"address=2562+Del+Zotto+Ave.%2C+Ottawa%2C+Ontario&\"\n f\"contractor=GCN&engineer=Goodkey&owner=Douglas+Stalker&\"\n f\"quality=2&cc_email=&link_to_cert={dcn_key}\\r\\n\"\n )\n }\n # set-up new entries in db, if necessary\n fake_dilfo_insert = \"\"\"\n INSERT INTO df_dilfo (job_number, receiver_email, closed)", " VALUES ({}, 'alex.roy616@gmail.com', {})", " \"\"\"\n fake_match_insert = \"\"\"\n INSERT INTO df_matched (job_number, verifier, ground_truth)", " VALUES ({}, 'alex.roy616@gmail.com', {})", " \"\"\"\n with create_connection() as conn:\n if was_prev_closed or was_prev_tracked:", " conn.cursor().execute(fake_dilfo_insert.format(job_number, was_prev_closed))", " if was_prev_matched:\n if was_prev_closed:", " conn.cursor().execute(fake_match_insert.format(job_number, 1))", " else:", " conn.cursor().execute(fake_match_insert.format(job_number, 0))", " with create_connection() as conn:", " df_dilfo_pre = pd.read_sql(f\"SELECT * FROM df_dilfo WHERE job_number={job_number}\", conn)\n df_matched_pre = pd.read_sql(f\"SELECT * FROM df_matched WHERE job_number={job_number}\", conn)", " process_as_form(email_obj)\n # make assertions about db now that reply has been processed\n with create_connection() as conn:", " df_dilfo_post = pd.read_sql(f\"SELECT * FROM df_dilfo WHERE job_number={job_number}\", conn)\n df_matched_post = pd.read_sql(f\"SELECT * FROM df_matched WHERE job_number={job_number}\", conn)", " self.assertEqual(len(df_dilfo_post), 1)\n self.assertEqual(bool(df_dilfo_post.iloc[0].closed), bool(was_prev_closed or dcn_key))\n self.assertEqual(any(df_matched_post.ground_truth), bool(was_prev_closed or dcn_key))\n self.assertEqual(len(df_matched_pre) + bool(dcn_key and not(was_prev_closed)), len(df_matched_post))\n self.assertEqual(list(df_matched_pre.columns), list(df_matched_post.columns))\n self.assertEqual(list(df_dilfo_pre.columns), list(df_dilfo_post.columns))" ]
[ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 844, "char_start": 843, "chars": "?" }, { "char_end": 872, "char_start": 871, "chars": "?" }, { "char_end": 1011, "char_start": 1010, "chars": "?" }, { "char_end": 1039, "char_start": 1038, "chars": "?" }, { "char_end": 1205, "char_start": 1202, "chars": ", [" }, { "char_end": 1233, "char_start": 1232, "chars": "]" }, { "char_end": 1366, "char_start": 1363, "chars": ", [" }, { "char_end": 1380, "char_start": 1379, "chars": "]" }, { "char_end": 1466, "char_start": 1463, "chars": ", [" }, { "char_end": 1480, "char_start": 1479, "chars": "]" }, { "char_end": 1622, "char_start": 1604, "chars": "?\", conn, params=[" }, { "char_end": 1633, "char_start": 1632, "chars": "]" }, { "char_end": 1737, "char_start": 1719, "chars": "?\", conn, params=[" }, { "char_end": 1748, "char_start": 1747, "chars": "]" }, { "char_end": 1995, "char_start": 1977, "chars": "?\", conn, params=[" }, { "char_end": 2006, "char_start": 2005, "chars": "]" }, { "char_end": 2111, "char_start": 2093, "chars": "?\", conn, params=[" }, { "char_end": 2122, "char_start": 2121, "chars": "]" } ], "deleted": [ { "char_end": 845, "char_start": 843, "chars": "{}" }, { "char_end": 874, "char_start": 872, "chars": "{}" }, { "char_end": 1014, "char_start": 1012, "chars": "{}" }, { "char_end": 1043, "char_start": 1041, "chars": "{}" }, { "char_end": 1214, "char_start": 1206, "chars": ".format(" }, { "char_end": 1242, "char_start": 1241, "chars": ")" }, { "char_end": 1380, "char_start": 1372, "chars": ".format(" }, { "char_end": 1394, "char_start": 1393, "chars": ")" }, { "char_end": 1485, "char_start": 1477, "chars": ".format(" }, { "char_end": 1499, "char_start": 1498, "chars": ")" }, { "char_end": 1583, "char_start": 1582, "chars": "f" }, { "char_end": 1625, "char_start": 1624, "chars": "{" }, { "char_end": 1643, "char_start": 1635, "chars": "}\", conn" }, { "char_end": 1687, "char_start": 1686, "chars": "f" }, { "char_end": 1731, "char_start": 1730, "chars": "{" }, { "char_end": 1749, "char_start": 1741, "chars": "}\", conn" }, { "char_end": 1938, "char_start": 1937, "chars": "f" }, { "char_end": 1980, "char_start": 1979, "chars": "{" }, { "char_end": 1998, "char_start": 1990, "chars": "}\", conn" }, { "char_end": 2043, "char_start": 2042, "chars": "f" }, { "char_end": 2087, "char_start": 2086, "chars": "{" }, { "char_end": 2105, "char_start": 2097, "chars": "}\", conn" } ] }, "commit_link": "github.com/confirmationbias616/certificate_checker/commit/9e890b9613b627e3a5995d0e4a594c8e0831e2ce", "file_name": "tests.py", "func_name": "test_process_as_form", "line_changes": { "added": [ { "char_end": 874, "char_start": 823, "line": " VALUES (?, 'alex.roy616@gmail.com', ?)\n", "line_no": 18 }, { "char_end": 1041, "char_start": 990, "line": " VALUES (?, 'alex.roy616@gmail.com', ?)\n", "line_no": 22 }, { "char_end": 1235, "char_start": 1147, "line": " conn.cursor().execute(fake_dilfo_insert, [job_number, was_prev_closed])\n", "line_no": 26 }, { "char_end": 1382, "char_start": 1304, "line": " conn.cursor().execute(fake_match_insert, [job_number, 1])\n", "line_no": 29 }, { "char_end": 1482, "char_start": 1404, "line": " conn.cursor().execute(fake_match_insert, [job_number, 0])\n", "line_no": 31 }, { "char_end": 1635, "char_start": 1524, "line": " df_dilfo_pre = pd.read_sql(\"SELECT * FROM df_dilfo WHERE job_number=?\", conn, params=[job_number])\n", "line_no": 33 }, { "char_end": 1750, "char_start": 1635, "line": " df_matched_pre = pd.read_sql(\"SELECT * FROM df_matched WHERE job_number=?\", conn, params=[job_number])\n", "line_no": 34 }, { "char_end": 2008, "char_start": 1896, "line": " df_dilfo_post = pd.read_sql(\"SELECT * FROM df_dilfo WHERE job_number=?\", conn, params=[job_number])\n", "line_no": 38 }, { "char_end": 2124, "char_start": 2008, "line": " df_matched_post = pd.read_sql(\"SELECT * FROM df_matched WHERE job_number=?\", conn, params=[job_number])\n", "line_no": 39 } ], "deleted": [ { "char_end": 876, "char_start": 823, "line": " VALUES ({}, 'alex.roy616@gmail.com', {})\n", "line_no": 18 }, { "char_end": 1045, "char_start": 992, "line": " VALUES ({}, 'alex.roy616@gmail.com', {})\n", "line_no": 22 }, { "char_end": 1244, "char_start": 1151, "line": " conn.cursor().execute(fake_dilfo_insert.format(job_number, was_prev_closed))\n", "line_no": 26 }, { "char_end": 1396, "char_start": 1313, "line": " conn.cursor().execute(fake_match_insert.format(job_number, 1))\n", "line_no": 29 }, { "char_end": 1501, "char_start": 1418, "line": " conn.cursor().execute(fake_match_insert.format(job_number, 0))\n", "line_no": 31 }, { "char_end": 1645, "char_start": 1543, "line": " df_dilfo_pre = pd.read_sql(f\"SELECT * FROM df_dilfo WHERE job_number={job_number}\", conn)\n", "line_no": 33 }, { "char_end": 1751, "char_start": 1645, "line": " df_matched_pre = pd.read_sql(f\"SELECT * FROM df_matched WHERE job_number={job_number}\", conn)\n", "line_no": 34 }, { "char_end": 2000, "char_start": 1897, "line": " df_dilfo_post = pd.read_sql(f\"SELECT * FROM df_dilfo WHERE job_number={job_number}\", conn)\n", "line_no": 38 }, { "char_end": 2107, "char_start": 2000, "line": " df_matched_post = pd.read_sql(f\"SELECT * FROM df_matched WHERE job_number={job_number}\", conn)\n", "line_no": 39 } ] }, "vul_type": "cwe-089" }
217
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@unpack\n def test_process_as_form(self, job_number, dcn_key, was_prev_matched,\n was_prev_closed, was_prev_tracked):\n email_obj = {\n 'sender' : \"Alex Roy <Alex.Roy@dilfo.com>\",\n 'subject' : \"DO NOT MODIFY MESSAGE BELOW - JUST HIT `SEND`\",\n 'date' : \"Tue, 7 May 2019 17:34:17 +0000\",\n 'content' : (\n f\"job_number={job_number}&title=TEST_ENTRY&city=Ottawa&\"\n f\"address=2562+Del+Zotto+Ave.%2C+Ottawa%2C+Ontario&\"\n f\"contractor=GCN&engineer=Goodkey&owner=Douglas+Stalker&\"\n f\"quality=2&cc_email=&link_to_cert={dcn_key}\\r\\n\"\n )\n }\n # set-up new entries in db, if necessary\n fake_dilfo_insert = \"\"\"\n INSERT INTO df_dilfo (job_number, receiver_email, closed)", " VALUES (?, 'alex.roy616@gmail.com', ?)", " \"\"\"\n fake_match_insert = \"\"\"\n INSERT INTO df_matched (job_number, verifier, ground_truth)", " VALUES (?, 'alex.roy616@gmail.com', ?)", " \"\"\"\n with create_connection() as conn:\n if was_prev_closed or was_prev_tracked:", " conn.cursor().execute(fake_dilfo_insert, [job_number, was_prev_closed])", " if was_prev_matched:\n if was_prev_closed:", " conn.cursor().execute(fake_match_insert, [job_number, 1])", " else:", " conn.cursor().execute(fake_match_insert, [job_number, 0])", " with create_connection() as conn:", " df_dilfo_pre = pd.read_sql(\"SELECT * FROM df_dilfo WHERE job_number=?\", conn, params=[job_number])\n df_matched_pre = pd.read_sql(\"SELECT * FROM df_matched WHERE job_number=?\", conn, params=[job_number])", " process_as_form(email_obj)\n # make assertions about db now that reply has been processed\n with create_connection() as conn:", " df_dilfo_post = pd.read_sql(\"SELECT * FROM df_dilfo WHERE job_number=?\", conn, params=[job_number])\n df_matched_post = pd.read_sql(\"SELECT * FROM df_matched WHERE job_number=?\", conn, params=[job_number])", " self.assertEqual(len(df_dilfo_post), 1)\n self.assertEqual(bool(df_dilfo_post.iloc[0].closed), bool(was_prev_closed or dcn_key))\n self.assertEqual(any(df_matched_post.ground_truth), bool(was_prev_closed or dcn_key))\n self.assertEqual(len(df_matched_pre) + bool(dcn_key and not(was_prev_closed)), len(df_matched_post))\n self.assertEqual(list(df_matched_pre.columns), list(df_matched_post.columns))\n self.assertEqual(list(df_dilfo_pre.columns), list(df_dilfo_post.columns))" ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 844, "char_start": 843, "chars": "?" }, { "char_end": 872, "char_start": 871, "chars": "?" }, { "char_end": 1011, "char_start": 1010, "chars": "?" }, { "char_end": 1039, "char_start": 1038, "chars": "?" }, { "char_end": 1205, "char_start": 1202, "chars": ", [" }, { "char_end": 1233, "char_start": 1232, "chars": "]" }, { "char_end": 1366, "char_start": 1363, "chars": ", [" }, { "char_end": 1380, "char_start": 1379, "chars": "]" }, { "char_end": 1466, "char_start": 1463, "chars": ", [" }, { "char_end": 1480, "char_start": 1479, "chars": "]" }, { "char_end": 1622, "char_start": 1604, "chars": "?\", conn, params=[" }, { "char_end": 1633, "char_start": 1632, "chars": "]" }, { "char_end": 1737, "char_start": 1719, "chars": "?\", conn, params=[" }, { "char_end": 1748, "char_start": 1747, "chars": "]" }, { "char_end": 1995, "char_start": 1977, "chars": "?\", conn, params=[" }, { "char_end": 2006, "char_start": 2005, "chars": "]" }, { "char_end": 2111, "char_start": 2093, "chars": "?\", conn, params=[" }, { "char_end": 2122, "char_start": 2121, "chars": "]" } ], "deleted": [ { "char_end": 845, "char_start": 843, "chars": "{}" }, { "char_end": 874, "char_start": 872, "chars": "{}" }, { "char_end": 1014, "char_start": 1012, "chars": "{}" }, { "char_end": 1043, "char_start": 1041, "chars": "{}" }, { "char_end": 1214, "char_start": 1206, "chars": ".format(" }, { "char_end": 1242, "char_start": 1241, "chars": ")" }, { "char_end": 1380, "char_start": 1372, "chars": ".format(" }, { "char_end": 1394, "char_start": 1393, "chars": ")" }, { "char_end": 1485, "char_start": 1477, "chars": ".format(" }, { "char_end": 1499, "char_start": 1498, "chars": ")" }, { "char_end": 1583, "char_start": 1582, "chars": "f" }, { "char_end": 1625, "char_start": 1624, "chars": "{" }, { "char_end": 1643, "char_start": 1635, "chars": "}\", conn" }, { "char_end": 1687, "char_start": 1686, "chars": "f" }, { "char_end": 1731, "char_start": 1730, "chars": "{" }, { "char_end": 1749, "char_start": 1741, "chars": "}\", conn" }, { "char_end": 1938, "char_start": 1937, "chars": "f" }, { "char_end": 1980, "char_start": 1979, "chars": "{" }, { "char_end": 1998, "char_start": 1990, "chars": "}\", conn" }, { "char_end": 2043, "char_start": 2042, "chars": "f" }, { "char_end": 2087, "char_start": 2086, "chars": "{" }, { "char_end": 2105, "char_start": 2097, "chars": "}\", conn" } ] }, "commit_link": "github.com/confirmationbias616/certificate_checker/commit/9e890b9613b627e3a5995d0e4a594c8e0831e2ce", "file_name": "tests.py", "func_name": "test_process_as_form", "line_changes": { "added": [ { "char_end": 874, "char_start": 823, "line": " VALUES (?, 'alex.roy616@gmail.com', ?)\n", "line_no": 18 }, { "char_end": 1041, "char_start": 990, "line": " VALUES (?, 'alex.roy616@gmail.com', ?)\n", "line_no": 22 }, { "char_end": 1235, "char_start": 1147, "line": " conn.cursor().execute(fake_dilfo_insert, [job_number, was_prev_closed])\n", "line_no": 26 }, { "char_end": 1382, "char_start": 1304, "line": " conn.cursor().execute(fake_match_insert, [job_number, 1])\n", "line_no": 29 }, { "char_end": 1482, "char_start": 1404, "line": " conn.cursor().execute(fake_match_insert, [job_number, 0])\n", "line_no": 31 }, { "char_end": 1635, "char_start": 1524, "line": " df_dilfo_pre = pd.read_sql(\"SELECT * FROM df_dilfo WHERE job_number=?\", conn, params=[job_number])\n", "line_no": 33 }, { "char_end": 1750, "char_start": 1635, "line": " df_matched_pre = pd.read_sql(\"SELECT * FROM df_matched WHERE job_number=?\", conn, params=[job_number])\n", "line_no": 34 }, { "char_end": 2008, "char_start": 1896, "line": " df_dilfo_post = pd.read_sql(\"SELECT * FROM df_dilfo WHERE job_number=?\", conn, params=[job_number])\n", "line_no": 38 }, { "char_end": 2124, "char_start": 2008, "line": " df_matched_post = pd.read_sql(\"SELECT * FROM df_matched WHERE job_number=?\", conn, params=[job_number])\n", "line_no": 39 } ], "deleted": [ { "char_end": 876, "char_start": 823, "line": " VALUES ({}, 'alex.roy616@gmail.com', {})\n", "line_no": 18 }, { "char_end": 1045, "char_start": 992, "line": " VALUES ({}, 'alex.roy616@gmail.com', {})\n", "line_no": 22 }, { "char_end": 1244, "char_start": 1151, "line": " conn.cursor().execute(fake_dilfo_insert.format(job_number, was_prev_closed))\n", "line_no": 26 }, { "char_end": 1396, "char_start": 1313, "line": " conn.cursor().execute(fake_match_insert.format(job_number, 1))\n", "line_no": 29 }, { "char_end": 1501, "char_start": 1418, "line": " conn.cursor().execute(fake_match_insert.format(job_number, 0))\n", "line_no": 31 }, { "char_end": 1645, "char_start": 1543, "line": " df_dilfo_pre = pd.read_sql(f\"SELECT * FROM df_dilfo WHERE job_number={job_number}\", conn)\n", "line_no": 33 }, { "char_end": 1751, "char_start": 1645, "line": " df_matched_pre = pd.read_sql(f\"SELECT * FROM df_matched WHERE job_number={job_number}\", conn)\n", "line_no": 34 }, { "char_end": 2000, "char_start": 1897, "line": " df_dilfo_post = pd.read_sql(f\"SELECT * FROM df_dilfo WHERE job_number={job_number}\", conn)\n", "line_no": 38 }, { "char_end": 2107, "char_start": 2000, "line": " df_matched_post = pd.read_sql(f\"SELECT * FROM df_matched WHERE job_number={job_number}\", conn)\n", "line_no": 39 } ] }, "vul_type": "cwe-089" }
217
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@app.route('/<page_name>')\ndef render_page_name(page_name):", " query = db.query(\"select page_content.content, page.id as page_id, page_content.id as content_id from page, page_content where page.id = page_content.page_id and page.page_name = '%s' order by page_content.id desc limit 1\" % page_name)", " wiki_page = query.namedresult()\n has_content = False\n page_is_taken = False\n if len(wiki_page) < 1:\n content = \"\"\n else:\n page_is_taken = True\n content = wiki_page[0].content\n if len(content) > 0:\n has_content = True\n else:\n pass\n content = markdown.markdown(wiki_linkify(content))\n return render_template(\n 'pageholder.html',\n page_is_taken = page_is_taken,\n page_name = page_name,\n markdown = markdown,\n wiki_linkify = wiki_linkify,\n has_content = has_content,\n content = content\n )" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 245, "char_start": 243, "chars": "$1" }, { "char_end": 285, "char_start": 284, "chars": "," } ], "deleted": [ { "char_end": 247, "char_start": 243, "chars": "'%s'" }, { "char_end": 288, "char_start": 286, "chars": " %" } ] }, "commit_link": "github.com/Pumala/python_wiki_app_redo/commit/65d60747cd8efb05970304234d3bd949d2088e8b", "file_name": "server.py", "func_name": "render_page_name", "line_changes": { "added": [ { "char_end": 297, "char_start": 60, "line": " query = db.query(\"select page_content.content, page.id as page_id, page_content.id as content_id from page, page_content where page.id = page_content.page_id and page.page_name = $1 order by page_content.id desc limit 1\", page_name)\n", "line_no": 3 } ], "deleted": [ { "char_end": 300, "char_start": 60, "line": " query = db.query(\"select page_content.content, page.id as page_id, page_content.id as content_id from page, page_content where page.id = page_content.page_id and page.page_name = '%s' order by page_content.id desc limit 1\" % page_name)\n", "line_no": 3 } ] }, "vul_type": "cwe-089" }
218
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@app.route('/<page_name>')\ndef render_page_name(page_name):", " query = db.query(\"select page_content.content, page.id as page_id, page_content.id as content_id from page, page_content where page.id = page_content.page_id and page.page_name = $1 order by page_content.id desc limit 1\", page_name)", " wiki_page = query.namedresult()\n has_content = False\n page_is_taken = False\n if len(wiki_page) < 1:\n content = \"\"\n else:\n page_is_taken = True\n content = wiki_page[0].content\n if len(content) > 0:\n has_content = True\n else:\n pass\n content = markdown.markdown(wiki_linkify(content))\n return render_template(\n 'pageholder.html',\n page_is_taken = page_is_taken,\n page_name = page_name,\n markdown = markdown,\n wiki_linkify = wiki_linkify,\n has_content = has_content,\n content = content\n )" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 245, "char_start": 243, "chars": "$1" }, { "char_end": 285, "char_start": 284, "chars": "," } ], "deleted": [ { "char_end": 247, "char_start": 243, "chars": "'%s'" }, { "char_end": 288, "char_start": 286, "chars": " %" } ] }, "commit_link": "github.com/Pumala/python_wiki_app_redo/commit/65d60747cd8efb05970304234d3bd949d2088e8b", "file_name": "server.py", "func_name": "render_page_name", "line_changes": { "added": [ { "char_end": 297, "char_start": 60, "line": " query = db.query(\"select page_content.content, page.id as page_id, page_content.id as content_id from page, page_content where page.id = page_content.page_id and page.page_name = $1 order by page_content.id desc limit 1\", page_name)\n", "line_no": 3 } ], "deleted": [ { "char_end": 300, "char_start": 60, "line": " query = db.query(\"select page_content.content, page.id as page_id, page_content.id as content_id from page, page_content where page.id = page_content.page_id and page.page_name = '%s' order by page_content.id desc limit 1\" % page_name)\n", "line_no": 3 } ] }, "vul_type": "cwe-089" }
218
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def tid_to_tid_num(self, tid):\n ''' Returns tid_num, given tid. '''\n", " q = \"SELECT rowid FROM tids WHERE tid = '\" + tid + \"'\"\n self.query(q)", " return self.c.fetchone()[0]" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 129, "char_start": 128, "chars": "?" }, { "char_end": 156, "char_start": 151, "chars": ", tid" } ], "deleted": [ { "char_end": 141, "char_start": 128, "chars": "'\" + tid + \"'" } ] }, "commit_link": "github.com/pukkapies/urop2019/commit/3ca2e2c291d2d5fe262d20a8e0520bdfb622432b", "file_name": "modules/query_lastfm.py", "func_name": "tid_to_tid_num", "line_changes": { "added": [ { "char_end": 131, "char_start": 80, "line": " q = \"SELECT rowid FROM tids WHERE tid = ?\"\n", "line_no": 4 }, { "char_end": 158, "char_start": 131, "line": " self.query(q, tid)\n", "line_no": 5 } ], "deleted": [ { "char_end": 143, "char_start": 80, "line": " q = \"SELECT rowid FROM tids WHERE tid = '\" + tid + \"'\"\n", "line_no": 4 }, { "char_end": 165, "char_start": 143, "line": " self.query(q)\n", "line_no": 5 } ] }, "vul_type": "cwe-089" }
219
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def tid_to_tid_num(self, tid):\n ''' Returns tid_num, given tid. '''\n", " q = \"SELECT rowid FROM tids WHERE tid = ?\"\n self.query(q, tid)", " return self.c.fetchone()[0]" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 129, "char_start": 128, "chars": "?" }, { "char_end": 156, "char_start": 151, "chars": ", tid" } ], "deleted": [ { "char_end": 141, "char_start": 128, "chars": "'\" + tid + \"'" } ] }, "commit_link": "github.com/pukkapies/urop2019/commit/3ca2e2c291d2d5fe262d20a8e0520bdfb622432b", "file_name": "modules/query_lastfm.py", "func_name": "tid_to_tid_num", "line_changes": { "added": [ { "char_end": 131, "char_start": 80, "line": " q = \"SELECT rowid FROM tids WHERE tid = ?\"\n", "line_no": 4 }, { "char_end": 158, "char_start": 131, "line": " self.query(q, tid)\n", "line_no": 5 } ], "deleted": [ { "char_end": 143, "char_start": 80, "line": " q = \"SELECT rowid FROM tids WHERE tid = '\" + tid + \"'\"\n", "line_no": 4 }, { "char_end": 165, "char_start": 143, "line": " self.query(q)\n", "line_no": 5 } ] }, "vul_type": "cwe-089" }
219
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def get_old_sourcebyinstitution_number(conn, sqlite, sourcebyinstitution):\n \"\"\"\n Get all the old sourcebyinstitution number from the SQLite database.\n \"\"\"\n query = \"\"\"\n SELECT\n titles\n FROM\n history\n WHERE", " sourcebyinstitution = \"%s\"", " ORDER BY\n titles DESC\n LIMIT 1", " \"\"\" % sourcebyinstitution", "", " sqlite.execute(query)", " for record in sqlite:\n old_sourcebyinstitution_number = record[0]\n return old_sourcebyinstitution_number" ]
[ 1, 0, 1, 0, 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 296, "char_start": 295, "chars": "?" }, { "char_end": 411, "char_start": 387, "chars": ", (sourcebyinstitution,)" } ], "deleted": [ { "char_end": 299, "char_start": 295, "chars": "\"%s\"" }, { "char_end": 386, "char_start": 364, "chars": " % sourcebyinstitution" } ] }, "commit_link": "github.com/miku/siskin/commit/7fa398d2fea72bf2e8b4808f75df4b3d35ae959a", "file_name": "bin/solrcheckup.py", "func_name": "get_old_sourcebyinstitution_number", "line_changes": { "added": [ { "char_end": 297, "char_start": 261, "line": " sourcebyinstitution = ?\n", "line_no": 11 }, { "char_end": 362, "char_start": 354, "line": " \"\"\"\n", "line_no": 15 }, { "char_end": 413, "char_start": 363, "line": " sqlite.execute(query, (sourcebyinstitution,))\n", "line_no": 17 } ], "deleted": [ { "char_end": 300, "char_start": 261, "line": " sourcebyinstitution = \"%s\"\n", "line_no": 11 }, { "char_end": 387, "char_start": 357, "line": " \"\"\" % sourcebyinstitution\n", "line_no": 15 }, { "char_end": 414, "char_start": 388, "line": " sqlite.execute(query)\n", "line_no": 17 } ] }, "vul_type": "cwe-089" }
220
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def get_old_sourcebyinstitution_number(conn, sqlite, sourcebyinstitution):\n \"\"\"\n Get all the old sourcebyinstitution number from the SQLite database.\n \"\"\"\n query = \"\"\"\n SELECT\n titles\n FROM\n history\n WHERE", " sourcebyinstitution = ?", " ORDER BY\n titles DESC\n LIMIT 1", " \"\"\"", "", " sqlite.execute(query, (sourcebyinstitution,))", " for record in sqlite:\n old_sourcebyinstitution_number = record[0]\n return old_sourcebyinstitution_number" ]
[ 1, 1, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 296, "char_start": 295, "chars": "?" }, { "char_end": 411, "char_start": 387, "chars": ", (sourcebyinstitution,)" } ], "deleted": [ { "char_end": 299, "char_start": 295, "chars": "\"%s\"" }, { "char_end": 386, "char_start": 364, "chars": " % sourcebyinstitution" } ] }, "commit_link": "github.com/miku/siskin/commit/7fa398d2fea72bf2e8b4808f75df4b3d35ae959a", "file_name": "bin/solrcheckup.py", "func_name": "get_old_sourcebyinstitution_number", "line_changes": { "added": [ { "char_end": 297, "char_start": 261, "line": " sourcebyinstitution = ?\n", "line_no": 11 }, { "char_end": 362, "char_start": 354, "line": " \"\"\"\n", "line_no": 15 }, { "char_end": 413, "char_start": 363, "line": " sqlite.execute(query, (sourcebyinstitution,))\n", "line_no": 17 } ], "deleted": [ { "char_end": 300, "char_start": 261, "line": " sourcebyinstitution = \"%s\"\n", "line_no": 11 }, { "char_end": 387, "char_start": 357, "line": " \"\"\" % sourcebyinstitution\n", "line_no": 15 }, { "char_end": 414, "char_start": 388, "line": " sqlite.execute(query)\n", "line_no": 17 } ] }, "vul_type": "cwe-089" }
220
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def top_karma(bot, trigger):\n \"\"\"\n Show karma status for the top n number of IRC users.\n \"\"\"\n try:\n top_limit = int(trigger.group(2).strip())\n except ValueError:\n top_limit = 5", " query = \"SELECT slug, value FROM nick_values NATURAL JOIN nicknames \\", " WHERE key = 'karma' ORDER BY value DESC LIMIT %d\"\n karmalist = bot.db.execute(query % top_limit).fetchall()", " for user in karmalist:\n bot.say(\"%s == %s\" % (user[0], user[1]))" ]
[ 1, 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 336, "char_start": 335, "chars": "?" }, { "char_end": 375, "char_start": 374, "chars": "," }, { "char_end": 380, "char_start": 376, "chars": "str(" }, { "char_end": 390, "char_start": 389, "chars": ")" } ], "deleted": [ { "char_end": 337, "char_start": 335, "chars": "%d" }, { "char_end": 378, "char_start": 376, "chars": "% " } ] }, "commit_link": "github.com/OpCode1300/sopel-karma/commit/e4d49f7b3d88f8874c7862392f3f4c2065a25695", "file_name": "sopel_modules/karma/karma.py", "func_name": "top_karma", "line_changes": { "added": [ { "char_end": 338, "char_start": 281, "line": " WHERE key = 'karma' ORDER BY value DESC LIMIT ?\"\n", "line_no": 11 }, { "char_end": 403, "char_start": 338, "line": " karmalist = bot.db.execute(query, str(top_limit)).fetchall()\n", "line_no": 12 } ], "deleted": [ { "char_end": 339, "char_start": 281, "line": " WHERE key = 'karma' ORDER BY value DESC LIMIT %d\"\n", "line_no": 11 }, { "char_end": 400, "char_start": 339, "line": " karmalist = bot.db.execute(query % top_limit).fetchall()\n", "line_no": 12 } ] }, "vul_type": "cwe-089" }
221
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def top_karma(bot, trigger):\n \"\"\"\n Show karma status for the top n number of IRC users.\n \"\"\"\n try:\n top_limit = int(trigger.group(2).strip())\n except ValueError:\n top_limit = 5", " query = \"SELECT slug, value FROM nick_values NATURAL JOIN nicknames \\", " WHERE key = 'karma' ORDER BY value DESC LIMIT ?\"\n karmalist = bot.db.execute(query, str(top_limit)).fetchall()", " for user in karmalist:\n bot.say(\"%s == %s\" % (user[0], user[1]))" ]
[ 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 336, "char_start": 335, "chars": "?" }, { "char_end": 375, "char_start": 374, "chars": "," }, { "char_end": 380, "char_start": 376, "chars": "str(" }, { "char_end": 390, "char_start": 389, "chars": ")" } ], "deleted": [ { "char_end": 337, "char_start": 335, "chars": "%d" }, { "char_end": 378, "char_start": 376, "chars": "% " } ] }, "commit_link": "github.com/OpCode1300/sopel-karma/commit/e4d49f7b3d88f8874c7862392f3f4c2065a25695", "file_name": "sopel_modules/karma/karma.py", "func_name": "top_karma", "line_changes": { "added": [ { "char_end": 338, "char_start": 281, "line": " WHERE key = 'karma' ORDER BY value DESC LIMIT ?\"\n", "line_no": 11 }, { "char_end": 403, "char_start": 338, "line": " karmalist = bot.db.execute(query, str(top_limit)).fetchall()\n", "line_no": 12 } ], "deleted": [ { "char_end": 339, "char_start": 281, "line": " WHERE key = 'karma' ORDER BY value DESC LIMIT %d\"\n", "line_no": 11 }, { "char_end": 400, "char_start": 339, "line": " karmalist = bot.db.execute(query % top_limit).fetchall()\n", "line_no": 12 } ] }, "vul_type": "cwe-089" }
221
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def retrieve_playlist_by_id(id, db):\n db.execute(", " \"SELECT id, name, video_position from playlist WHERE id={id};\".format(id=id))", " row = db.fetchone()\n return row" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 119, "char_start": 117, "chars": "%s" }, { "char_end": 123, "char_start": 121, "chars": ", " }, { "char_end": 127, "char_start": 126, "chars": "," } ], "deleted": [ { "char_end": 121, "char_start": 117, "chars": "{id}" }, { "char_end": 130, "char_start": 123, "chars": ".format" }, { "char_end": 136, "char_start": 133, "chars": "=id" } ] }, "commit_link": "github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6", "file_name": "playlist/playlist_repository.py", "func_name": "retrieve_playlist_by_id", "line_changes": { "added": [ { "char_end": 130, "char_start": 53, "line": " \"SELECT id, name, video_position from playlist WHERE id=%s;\", (id,))\n", "line_no": 3 } ], "deleted": [ { "char_end": 139, "char_start": 53, "line": " \"SELECT id, name, video_position from playlist WHERE id={id};\".format(id=id))\n", "line_no": 3 } ] }, "vul_type": "cwe-089" }
222
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def retrieve_playlist_by_id(id, db):\n db.execute(", " \"SELECT id, name, video_position from playlist WHERE id=%s;\", (id,))", " row = db.fetchone()\n return row" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 119, "char_start": 117, "chars": "%s" }, { "char_end": 123, "char_start": 121, "chars": ", " }, { "char_end": 127, "char_start": 126, "chars": "," } ], "deleted": [ { "char_end": 121, "char_start": 117, "chars": "{id}" }, { "char_end": 130, "char_start": 123, "chars": ".format" }, { "char_end": 136, "char_start": 133, "chars": "=id" } ] }, "commit_link": "github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6", "file_name": "playlist/playlist_repository.py", "func_name": "retrieve_playlist_by_id", "line_changes": { "added": [ { "char_end": 130, "char_start": 53, "line": " \"SELECT id, name, video_position from playlist WHERE id=%s;\", (id,))\n", "line_no": 3 } ], "deleted": [ { "char_end": 139, "char_start": 53, "line": " \"SELECT id, name, video_position from playlist WHERE id={id};\".format(id=id))\n", "line_no": 3 } ] }, "vul_type": "cwe-089" }
222
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@bot.message_handler(func = lambda message: get_current_state(message.chat.id) == config.States.S_GET_TASK.value)\ndef get_task(message):\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\bases\\\\settings.db\")\n conn = settings.cursor()", " conn.execute(\"select * from users where chat_id = '\" + str(message.chat.id) + \"'\")", " name = conn.fetchone()\n settings.close()\n if name == None:\n bot.send_message(message.chat.id, \"You should login before get tasks.\")\n else:\n bases.update.update_user(name[1], name[0], name[2])\n bot.send_message(message.chat.id, bases.problem.get_unsolved_problem(message.text, name[1]))\n set_state(message.chat.id, config.States.S_START.value)" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 321, "char_start": 320, "chars": "?" }, { "char_end": 323, "char_start": 322, "chars": "," }, { "char_end": 325, "char_start": 324, "chars": "(" }, { "char_end": 347, "char_start": 345, "chars": ",)" } ], "deleted": [ { "char_end": 321, "char_start": 320, "chars": "'" }, { "char_end": 324, "char_start": 322, "chars": " +" }, { "char_end": 351, "char_start": 345, "chars": " + \"'\"" } ] }, "commit_link": "github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90", "file_name": "bot.py", "func_name": "get_task", "line_changes": { "added": [ { "char_end": 349, "char_start": 266, "line": " conn.execute(\"select * from users where chat_id = ?\", (str(message.chat.id),))\n", "line_no": 5 } ], "deleted": [ { "char_end": 353, "char_start": 266, "line": " conn.execute(\"select * from users where chat_id = '\" + str(message.chat.id) + \"'\")\n", "line_no": 5 } ] }, "vul_type": "cwe-089" }
223
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@bot.message_handler(func = lambda message: get_current_state(message.chat.id) == config.States.S_GET_TASK.value)\ndef get_task(message):\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\bases\\\\settings.db\")\n conn = settings.cursor()", " conn.execute(\"select * from users where chat_id = ?\", (str(message.chat.id),))", " name = conn.fetchone()\n settings.close()\n if name == None:\n bot.send_message(message.chat.id, \"You should login before get tasks.\")\n else:\n bases.update.update_user(name[1], name[0], name[2])\n bot.send_message(message.chat.id, bases.problem.get_unsolved_problem(message.text, name[1]))\n set_state(message.chat.id, config.States.S_START.value)" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 321, "char_start": 320, "chars": "?" }, { "char_end": 323, "char_start": 322, "chars": "," }, { "char_end": 325, "char_start": 324, "chars": "(" }, { "char_end": 347, "char_start": 345, "chars": ",)" } ], "deleted": [ { "char_end": 321, "char_start": 320, "chars": "'" }, { "char_end": 324, "char_start": 322, "chars": " +" }, { "char_end": 351, "char_start": 345, "chars": " + \"'\"" } ] }, "commit_link": "github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90", "file_name": "bot.py", "func_name": "get_task", "line_changes": { "added": [ { "char_end": 349, "char_start": 266, "line": " conn.execute(\"select * from users where chat_id = ?\", (str(message.chat.id),))\n", "line_no": 5 } ], "deleted": [ { "char_end": 353, "char_start": 266, "line": " conn.execute(\"select * from users where chat_id = '\" + str(message.chat.id) + \"'\")\n", "line_no": 5 } ] }, "vul_type": "cwe-089" }
223
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@bot.message_handler(commands=['stats'])\ndef stats(message):\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\bases\\\\settings.db\")\n conn = settings.cursor()", " conn.execute(\"select * from users where chat_id = '\" + str(message.chat.id) + \"'\")", " name = conn.fetchone()\n settings.close()\n if name != None:\n bases.update.update_user(name[1], name[0], name[2])\n bases.problem.create_text_stats(name[1])\n img = open(os.path.abspath(os.path.dirname(__file__)) + \"\\\\bases\\\\users\\\\\" + name[1] + \".png\", \"rb\")\n bot.send_photo(message.chat.id, img)\n img.close()\n if bases.problem.create_stats_picture(name[1]):\n bot.send_message(message.chat.id, \"Sorry, you haven't solved tasks.\")\n return 0\n img = open(os.path.abspath(os.path.dirname(__file__)) + \"\\\\bases\\\\users\\\\\" + name[1] + \".png\", \"rb\")\n bot.send_photo(message.chat.id, img)\n img.close()\n else:\n bot.send_message(message.chat.id, \"You should login before getting statistic.\")" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 245, "char_start": 244, "chars": "?" }, { "char_end": 247, "char_start": 246, "chars": "," }, { "char_end": 249, "char_start": 248, "chars": "(" }, { "char_end": 271, "char_start": 269, "chars": ",)" } ], "deleted": [ { "char_end": 245, "char_start": 244, "chars": "'" }, { "char_end": 248, "char_start": 246, "chars": " +" }, { "char_end": 275, "char_start": 269, "chars": " + \"'\"" } ] }, "commit_link": "github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90", "file_name": "bot.py", "func_name": "stats", "line_changes": { "added": [ { "char_end": 273, "char_start": 190, "line": " conn.execute(\"select * from users where chat_id = ?\", (str(message.chat.id),))\n", "line_no": 5 } ], "deleted": [ { "char_end": 277, "char_start": 190, "line": " conn.execute(\"select * from users where chat_id = '\" + str(message.chat.id) + \"'\")\n", "line_no": 5 } ] }, "vul_type": "cwe-089" }
224
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@bot.message_handler(commands=['stats'])\ndef stats(message):\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\bases\\\\settings.db\")\n conn = settings.cursor()", " conn.execute(\"select * from users where chat_id = ?\", (str(message.chat.id),))", " name = conn.fetchone()\n settings.close()\n if name != None:\n bases.update.update_user(name[1], name[0], name[2])\n bases.problem.create_text_stats(name[1])\n img = open(os.path.abspath(os.path.dirname(__file__)) + \"\\\\bases\\\\users\\\\\" + name[1] + \".png\", \"rb\")\n bot.send_photo(message.chat.id, img)\n img.close()\n if bases.problem.create_stats_picture(name[1]):\n bot.send_message(message.chat.id, \"Sorry, you haven't solved tasks.\")\n return 0\n img = open(os.path.abspath(os.path.dirname(__file__)) + \"\\\\bases\\\\users\\\\\" + name[1] + \".png\", \"rb\")\n bot.send_photo(message.chat.id, img)\n img.close()\n else:\n bot.send_message(message.chat.id, \"You should login before getting statistic.\")" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 245, "char_start": 244, "chars": "?" }, { "char_end": 247, "char_start": 246, "chars": "," }, { "char_end": 249, "char_start": 248, "chars": "(" }, { "char_end": 271, "char_start": 269, "chars": ",)" } ], "deleted": [ { "char_end": 245, "char_start": 244, "chars": "'" }, { "char_end": 248, "char_start": 246, "chars": " +" }, { "char_end": 275, "char_start": 269, "chars": " + \"'\"" } ] }, "commit_link": "github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90", "file_name": "bot.py", "func_name": "stats", "line_changes": { "added": [ { "char_end": 273, "char_start": 190, "line": " conn.execute(\"select * from users where chat_id = ?\", (str(message.chat.id),))\n", "line_no": 5 } ], "deleted": [ { "char_end": 277, "char_start": 190, "line": " conn.execute(\"select * from users where chat_id = '\" + str(message.chat.id) + \"'\")\n", "line_no": 5 } ] }, "vul_type": "cwe-089" }
224
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@jwt_required\n def delete(self, user_id):\n \"\"\" Deletes user with the corresponding user_id \"\"\"", " return database_utilities.execute_query(f\"\"\"delete from users where user_id = '{user_id}'\"\"\")" ]
[ 1, 0 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 203, "char_start": 195, "chars": "%s\"\"\", (" }, { "char_end": 213, "char_start": 210, "chars": ", )" } ], "deleted": [ { "char_end": 197, "char_start": 195, "chars": "'{" }, { "char_end": 209, "char_start": 204, "chars": "}'\"\"\"" } ] }, "commit_link": "github.com/sgosal2/tiger-boards-backend/commit/4670109dd613df2f2fe7e8403ebd149df2b55485", "file_name": "apis/users.py", "func_name": "delete", "line_changes": { "added": [ { "char_end": 214, "char_start": 109, "line": " return database_utilities.execute_query(f\"\"\"delete from users where user_id = %s\"\"\", (user_id, ))\n", "line_no": 4 } ], "deleted": [ { "char_end": 210, "char_start": 109, "line": " return database_utilities.execute_query(f\"\"\"delete from users where user_id = '{user_id}'\"\"\")\n", "line_no": 4 } ] }, "vul_type": "cwe-089" }
225
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@jwt_required\n def delete(self, user_id):\n \"\"\" Deletes user with the corresponding user_id \"\"\"", " return database_utilities.execute_query(f\"\"\"delete from users where user_id = %s\"\"\", (user_id, ))" ]
[ 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 203, "char_start": 195, "chars": "%s\"\"\", (" }, { "char_end": 213, "char_start": 210, "chars": ", )" } ], "deleted": [ { "char_end": 197, "char_start": 195, "chars": "'{" }, { "char_end": 209, "char_start": 204, "chars": "}'\"\"\"" } ] }, "commit_link": "github.com/sgosal2/tiger-boards-backend/commit/4670109dd613df2f2fe7e8403ebd149df2b55485", "file_name": "apis/users.py", "func_name": "delete", "line_changes": { "added": [ { "char_end": 214, "char_start": 109, "line": " return database_utilities.execute_query(f\"\"\"delete from users where user_id = %s\"\"\", (user_id, ))\n", "line_no": 4 } ], "deleted": [ { "char_end": 210, "char_start": 109, "line": " return database_utilities.execute_query(f\"\"\"delete from users where user_id = '{user_id}'\"\"\")\n", "line_no": 4 } ] }, "vul_type": "cwe-089" }
225
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def verify_rno(self, rno):", " query = \"SELECT COUNT(rno) FROM rides WHERE rno = {rno}\".format(rno = rno)\n self.cursor.execute(query)", " result = self.cursor.fetchone()\n if (int(result[0]) > 0):\n return True \n else:\n return False" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 55, "char_start": 39, "chars": "self.cursor.exec" }, { "char_end": 57, "char_start": 56, "chars": "t" }, { "char_end": 59, "char_start": 58, "chars": "(" }, { "char_end": 102, "char_start": 101, "chars": ":" }, { "char_end": 107, "char_start": 106, "chars": "," }, { "char_end": 110, "char_start": 108, "chars": "{'" }, { "char_end": 115, "char_start": 113, "chars": "':" }, { "char_end": 118, "char_start": 117, "chars": "n" }, { "char_end": 120, "char_start": 119, "chars": "}" } ], "deleted": [ { "char_end": 41, "char_start": 39, "chars": "qu" }, { "char_end": 47, "char_start": 43, "chars": "y = " }, { "char_end": 90, "char_start": 89, "chars": "{" }, { "char_end": 94, "char_start": 93, "chars": "}" }, { "char_end": 103, "char_start": 95, "chars": ".format(" }, { "char_end": 108, "char_start": 106, "chars": " =" }, { "char_end": 147, "char_start": 112, "chars": ")\n self.cursor.execute(query" } ] }, "commit_link": "github.com/kenboo98/291-Mini-Project-I/commit/3080ccb687c79c83954ce703faee8fcceec8c9eb", "file_name": "book_rides/book_rides.py", "func_name": "verify_rno", "line_changes": { "added": [ { "char_end": 122, "char_start": 31, "line": " self.cursor.execute(\"SELECT COUNT(rno) FROM rides WHERE rno = :rno\", {'rno': rno})\n", "line_no": 2 } ], "deleted": [ { "char_end": 114, "char_start": 31, "line": " query = \"SELECT COUNT(rno) FROM rides WHERE rno = {rno}\".format(rno = rno)\n", "line_no": 2 }, { "char_end": 149, "char_start": 114, "line": " self.cursor.execute(query)\n", "line_no": 3 } ] }, "vul_type": "cwe-089" }
226
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def verify_rno(self, rno):", " self.cursor.execute(\"SELECT COUNT(rno) FROM rides WHERE rno = :rno\", {'rno': rno})", " result = self.cursor.fetchone()\n if (int(result[0]) > 0):\n return True \n else:\n return False" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 55, "char_start": 39, "chars": "self.cursor.exec" }, { "char_end": 57, "char_start": 56, "chars": "t" }, { "char_end": 59, "char_start": 58, "chars": "(" }, { "char_end": 102, "char_start": 101, "chars": ":" }, { "char_end": 107, "char_start": 106, "chars": "," }, { "char_end": 110, "char_start": 108, "chars": "{'" }, { "char_end": 115, "char_start": 113, "chars": "':" }, { "char_end": 118, "char_start": 117, "chars": "n" }, { "char_end": 120, "char_start": 119, "chars": "}" } ], "deleted": [ { "char_end": 41, "char_start": 39, "chars": "qu" }, { "char_end": 47, "char_start": 43, "chars": "y = " }, { "char_end": 90, "char_start": 89, "chars": "{" }, { "char_end": 94, "char_start": 93, "chars": "}" }, { "char_end": 103, "char_start": 95, "chars": ".format(" }, { "char_end": 108, "char_start": 106, "chars": " =" }, { "char_end": 147, "char_start": 112, "chars": ")\n self.cursor.execute(query" } ] }, "commit_link": "github.com/kenboo98/291-Mini-Project-I/commit/3080ccb687c79c83954ce703faee8fcceec8c9eb", "file_name": "book_rides/book_rides.py", "func_name": "verify_rno", "line_changes": { "added": [ { "char_end": 122, "char_start": 31, "line": " self.cursor.execute(\"SELECT COUNT(rno) FROM rides WHERE rno = :rno\", {'rno': rno})\n", "line_no": 2 } ], "deleted": [ { "char_end": 114, "char_start": 31, "line": " query = \"SELECT COUNT(rno) FROM rides WHERE rno = {rno}\".format(rno = rno)\n", "line_no": 2 }, { "char_end": 149, "char_start": 114, "line": " self.cursor.execute(query)\n", "line_no": 3 } ] }, "vul_type": "cwe-089" }
226
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def get_requested_day(self, date):", " data = dict()", " day_start, day_end = self.get_epoch_day(date)\n data['interval'] = {'from': self.convert_local_ts_to_utc(day_start, self.local_timezone), 'to': self.convert_local_ts_to_utc(day_end, self.local_timezone)}", " query = '''\n SELECT TimeStamp, SUM(Power) AS Power \n FROM DayData ", " WHERE TimeStamp BETWEEN %s AND %s ", " GROUP BY TimeStamp;\n '''", " data['data'] = list()", " for row in self.c.execute(query % (day_start, day_end)):", " data['data'].append({ 'time': row[0], 'power': row[1] })", "\n if self.get_datetime(date).date() == datetime.today().date():\n query = '''\n SELECT SUM(EToday) as EToday\n FROM Inverters;\n '''", "", " else:\n query = '''\n SELECT SUM(DayYield) AS Power \n FROM MonthData ", " WHERE TimeStamp BETWEEN %s AND %s\n GROUP BY TimeStamp\n ''' % (day_start, day_end)\n self.c.execute(query)", " row = self.c.fetchone()\n if row and row[0]: data['total'] = row[0]\n else: data['total'] = 0", "\n query = '''\n SELECT MIN(TimeStamp) as Min, MAX(TimeStamp) as Max \n FROM ( SELECT TimeStamp FROM DayData GROUP BY TimeStamp );\n '''", " self.c.execute(query)\n first_data, last_data = self.c.fetchone()", " if (first_data): data['hasPrevious'] = (first_data < day_start)\n else: data['hasPrevious'] = False", " if (last_data): data['hasNext'] = (last_data > day_end)\n else: data['hasNext'] = False", " #print(json.dumps(data, indent=4))\n return data" ]
[ 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 416, "char_start": 415, "chars": "?" }, { "char_end": 422, "char_start": 421, "chars": "?" }, { "char_end": 538, "char_start": 537, "chars": "," }, { "char_end": 858, "char_start": 824, "chars": " self.c.execute(query)\n" }, { "char_end": 1016, "char_start": 1015, "chars": "?" }, { "char_end": 1022, "char_start": 1021, "chars": "?" }, { "char_end": 1058, "char_start": 1057, "chars": ";" }, { "char_end": 1079, "char_start": 1078, "chars": "\n" }, { "char_end": 1083, "char_start": 1082, "chars": " " }, { "char_end": 1132, "char_start": 1111, "chars": ", (day_start, day_end" }, { "char_end": 1135, "char_start": 1133, "chars": ")\n" } ], "deleted": [ { "char_end": 417, "char_start": 415, "chars": "%s" }, { "char_end": 425, "char_start": 422, "chars": "%s " }, { "char_end": 542, "char_start": 540, "chars": " %" }, { "char_end": 987, "char_start": 985, "chars": "%s" }, { "char_end": 994, "char_start": 992, "chars": "%s" }, { "char_end": 1051, "char_start": 1050, "chars": "%" }, { "char_end": 1063, "char_start": 1052, "chars": "(day_start," }, { "char_end": 1073, "char_start": 1064, "chars": "day_end)\n" } ] }, "commit_link": "github.com/philipptrenz/sunportal/commit/7eef493a168ed4e6731ff800713bfb8aee99a506", "file_name": "util/database.py", "func_name": "get_requested_day", "line_changes": { "added": [ { "char_end": 423, "char_start": 379, "line": " WHERE TimeStamp BETWEEN ? AND ?\n", "line_no": 11 }, { "char_end": 562, "char_start": 498, "line": " for row in self.c.execute(query, (day_start, day_end)):\n", "line_no": 16 }, { "char_end": 858, "char_start": 824, "line": " self.c.execute(query)\n", "line_no": 25 }, { "char_end": 1023, "char_start": 975, "line": " WHERE TimeStamp BETWEEN ? AND ?\n", "line_no": 30 }, { "char_end": 1059, "char_start": 1023, "line": " GROUP BY TimeStamp;\n", "line_no": 31 }, { "char_end": 1079, "char_start": 1059, "line": " '''\n", "line_no": 32 }, { "char_end": 1135, "char_start": 1079, "line": " self.c.execute(query, (day_start, day_end))\n", "line_no": 33 }, { "char_end": 1136, "char_start": 1135, "line": "\n", "line_no": 34 } ], "deleted": [ { "char_end": 426, "char_start": 379, "line": " WHERE TimeStamp BETWEEN %s AND %s \n", "line_no": 11 }, { "char_end": 566, "char_start": 501, "line": " for row in self.c.execute(query % (day_start, day_end)):\n", "line_no": 16 }, { "char_end": 995, "char_start": 945, "line": " WHERE TimeStamp BETWEEN %s AND %s\n", "line_no": 29 }, { "char_end": 1030, "char_start": 995, "line": " GROUP BY TimeStamp\n", "line_no": 30 }, { "char_end": 1073, "char_start": 1030, "line": " ''' % (day_start, day_end)\n", "line_no": 31 }, { "char_end": 1103, "char_start": 1073, "line": " self.c.execute(query)\n", "line_no": 32 } ] }, "vul_type": "cwe-089" }
227
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def get_requested_day(self, date):", " data = dict()", " day_start, day_end = self.get_epoch_day(date)\n data['interval'] = {'from': self.convert_local_ts_to_utc(day_start, self.local_timezone), 'to': self.convert_local_ts_to_utc(day_end, self.local_timezone)}", " query = '''\n SELECT TimeStamp, SUM(Power) AS Power \n FROM DayData ", " WHERE TimeStamp BETWEEN ? AND ?", " GROUP BY TimeStamp;\n '''", " data['data'] = list()", " for row in self.c.execute(query, (day_start, day_end)):", " data['data'].append({ 'time': row[0], 'power': row[1] })", "\n if self.get_datetime(date).date() == datetime.today().date():\n query = '''\n SELECT SUM(EToday) as EToday\n FROM Inverters;\n '''", " self.c.execute(query)", " else:\n query = '''\n SELECT SUM(DayYield) AS Power \n FROM MonthData ", " WHERE TimeStamp BETWEEN ? AND ?\n GROUP BY TimeStamp;\n '''\n self.c.execute(query, (day_start, day_end))\n", " row = self.c.fetchone()\n if row and row[0]: data['total'] = row[0]\n else: data['total'] = 0", "\n query = '''\n SELECT MIN(TimeStamp) as Min, MAX(TimeStamp) as Max \n FROM ( SELECT TimeStamp FROM DayData GROUP BY TimeStamp );\n '''", " self.c.execute(query)\n first_data, last_data = self.c.fetchone()", " if (first_data): data['hasPrevious'] = (first_data < day_start)\n else: data['hasPrevious'] = False", " if (last_data): data['hasNext'] = (last_data > day_end)\n else: data['hasNext'] = False", " #print(json.dumps(data, indent=4))\n return data" ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 416, "char_start": 415, "chars": "?" }, { "char_end": 422, "char_start": 421, "chars": "?" }, { "char_end": 538, "char_start": 537, "chars": "," }, { "char_end": 858, "char_start": 824, "chars": " self.c.execute(query)\n" }, { "char_end": 1016, "char_start": 1015, "chars": "?" }, { "char_end": 1022, "char_start": 1021, "chars": "?" }, { "char_end": 1058, "char_start": 1057, "chars": ";" }, { "char_end": 1079, "char_start": 1078, "chars": "\n" }, { "char_end": 1083, "char_start": 1082, "chars": " " }, { "char_end": 1132, "char_start": 1111, "chars": ", (day_start, day_end" }, { "char_end": 1135, "char_start": 1133, "chars": ")\n" } ], "deleted": [ { "char_end": 417, "char_start": 415, "chars": "%s" }, { "char_end": 425, "char_start": 422, "chars": "%s " }, { "char_end": 542, "char_start": 540, "chars": " %" }, { "char_end": 987, "char_start": 985, "chars": "%s" }, { "char_end": 994, "char_start": 992, "chars": "%s" }, { "char_end": 1051, "char_start": 1050, "chars": "%" }, { "char_end": 1063, "char_start": 1052, "chars": "(day_start," }, { "char_end": 1073, "char_start": 1064, "chars": "day_end)\n" } ] }, "commit_link": "github.com/philipptrenz/sunportal/commit/7eef493a168ed4e6731ff800713bfb8aee99a506", "file_name": "util/database.py", "func_name": "get_requested_day", "line_changes": { "added": [ { "char_end": 423, "char_start": 379, "line": " WHERE TimeStamp BETWEEN ? AND ?\n", "line_no": 11 }, { "char_end": 562, "char_start": 498, "line": " for row in self.c.execute(query, (day_start, day_end)):\n", "line_no": 16 }, { "char_end": 858, "char_start": 824, "line": " self.c.execute(query)\n", "line_no": 25 }, { "char_end": 1023, "char_start": 975, "line": " WHERE TimeStamp BETWEEN ? AND ?\n", "line_no": 30 }, { "char_end": 1059, "char_start": 1023, "line": " GROUP BY TimeStamp;\n", "line_no": 31 }, { "char_end": 1079, "char_start": 1059, "line": " '''\n", "line_no": 32 }, { "char_end": 1135, "char_start": 1079, "line": " self.c.execute(query, (day_start, day_end))\n", "line_no": 33 }, { "char_end": 1136, "char_start": 1135, "line": "\n", "line_no": 34 } ], "deleted": [ { "char_end": 426, "char_start": 379, "line": " WHERE TimeStamp BETWEEN %s AND %s \n", "line_no": 11 }, { "char_end": 566, "char_start": 501, "line": " for row in self.c.execute(query % (day_start, day_end)):\n", "line_no": 16 }, { "char_end": 995, "char_start": 945, "line": " WHERE TimeStamp BETWEEN %s AND %s\n", "line_no": 29 }, { "char_end": 1030, "char_start": 995, "line": " GROUP BY TimeStamp\n", "line_no": 30 }, { "char_end": 1073, "char_start": 1030, "line": " ''' % (day_start, day_end)\n", "line_no": 31 }, { "char_end": 1103, "char_start": 1073, "line": " self.c.execute(query)\n", "line_no": 32 } ] }, "vul_type": "cwe-089" }
227
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def add_language(lang):\n try:", " cur.execute(f\"INSERT INTO language (name) VALUES ('{lang}')\")", " except Exception as e:\n pass", " cur.execute(f\"SELECT language_id FROM language where name='{lang}'\")", " lang_id = cur.fetchone()[0]\n if conn.commit():\n return lang_id\n return lang_id" ]
[ 1, 0, 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 97, "char_start": 90, "chars": "%s)\", (" }, { "char_end": 103, "char_start": 101, "chars": ", " }, { "char_end": 213, "char_start": 207, "chars": "%s\", (" }, { "char_end": 220, "char_start": 217, "chars": ", )" } ], "deleted": [ { "char_end": 54, "char_start": 53, "chars": "f" }, { "char_end": 93, "char_start": 91, "chars": "'{" }, { "char_end": 99, "char_start": 97, "chars": "}'" }, { "char_end": 101, "char_start": 100, "chars": "\"" }, { "char_end": 160, "char_start": 159, "chars": "f" }, { "char_end": 207, "char_start": 205, "chars": "'{" }, { "char_end": 214, "char_start": 211, "chars": "}'\"" } ] }, "commit_link": "github.com/Elbertbiggs360/dvdrental/commit/ad144ae2a08a332498d0831bc255170d57ba754b", "file_name": "app.py", "func_name": "add_language", "line_changes": { "added": [ { "char_end": 106, "char_start": 33, "line": " cur.execute(\"INSERT INTO language (name) VALUES (%s)\", (lang, ))\n", "line_no": 3 }, { "char_end": 222, "char_start": 146, "line": " cur.execute(\"SELECT language_id FROM language where name=%s\", (lang, ))\n", "line_no": 6 } ], "deleted": [ { "char_end": 103, "char_start": 33, "line": " cur.execute(f\"INSERT INTO language (name) VALUES ('{lang}')\")\n", "line_no": 3 }, { "char_end": 216, "char_start": 143, "line": " cur.execute(f\"SELECT language_id FROM language where name='{lang}'\")\n", "line_no": 6 } ] }, "vul_type": "cwe-089" }
228
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def add_language(lang):\n try:", " cur.execute(\"INSERT INTO language (name) VALUES (%s)\", (lang, ))", " except Exception as e:\n pass", " cur.execute(\"SELECT language_id FROM language where name=%s\", (lang, ))", " lang_id = cur.fetchone()[0]\n if conn.commit():\n return lang_id\n return lang_id" ]
[ 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 97, "char_start": 90, "chars": "%s)\", (" }, { "char_end": 103, "char_start": 101, "chars": ", " }, { "char_end": 213, "char_start": 207, "chars": "%s\", (" }, { "char_end": 220, "char_start": 217, "chars": ", )" } ], "deleted": [ { "char_end": 54, "char_start": 53, "chars": "f" }, { "char_end": 93, "char_start": 91, "chars": "'{" }, { "char_end": 99, "char_start": 97, "chars": "}'" }, { "char_end": 101, "char_start": 100, "chars": "\"" }, { "char_end": 160, "char_start": 159, "chars": "f" }, { "char_end": 207, "char_start": 205, "chars": "'{" }, { "char_end": 214, "char_start": 211, "chars": "}'\"" } ] }, "commit_link": "github.com/Elbertbiggs360/dvdrental/commit/ad144ae2a08a332498d0831bc255170d57ba754b", "file_name": "app.py", "func_name": "add_language", "line_changes": { "added": [ { "char_end": 106, "char_start": 33, "line": " cur.execute(\"INSERT INTO language (name) VALUES (%s)\", (lang, ))\n", "line_no": 3 }, { "char_end": 222, "char_start": 146, "line": " cur.execute(\"SELECT language_id FROM language where name=%s\", (lang, ))\n", "line_no": 6 } ], "deleted": [ { "char_end": 103, "char_start": 33, "line": " cur.execute(f\"INSERT INTO language (name) VALUES ('{lang}')\")\n", "line_no": 3 }, { "char_end": 216, "char_start": 143, "line": " cur.execute(f\"SELECT language_id FROM language where name='{lang}'\")\n", "line_no": 6 } ] }, "vul_type": "cwe-089" }
228
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def makeJudge(judge):", "\tdb.execute(\"UPDATE players SET Judge = 1 WHERE Name = '%s' COLLATE NOCASE\" % (judge)) ", "\tdatabase.commit()" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 78, "char_start": 77, "chars": "?" }, { "char_end": 95, "char_start": 94, "chars": "," } ], "deleted": [ { "char_end": 81, "char_start": 77, "chars": "'%s'" }, { "char_end": 99, "char_start": 97, "chars": " %" }, { "char_end": 101, "char_start": 100, "chars": "(" }, { "char_end": 107, "char_start": 106, "chars": ")" } ] }, "commit_link": "github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2", "file_name": "plugins/database.py", "func_name": "makeJudge", "line_changes": { "added": [ { "char_end": 104, "char_start": 22, "line": "\tdb.execute(\"UPDATE players SET Judge = 1 WHERE Name = ? COLLATE NOCASE\", judge) \n", "line_no": 2 } ], "deleted": [ { "char_end": 110, "char_start": 22, "line": "\tdb.execute(\"UPDATE players SET Judge = 1 WHERE Name = '%s' COLLATE NOCASE\" % (judge)) \n", "line_no": 2 } ] }, "vul_type": "cwe-089" }
229
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def makeJudge(judge):", "\tdb.execute(\"UPDATE players SET Judge = 1 WHERE Name = ? COLLATE NOCASE\", judge) ", "\tdatabase.commit()" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 78, "char_start": 77, "chars": "?" }, { "char_end": 95, "char_start": 94, "chars": "," } ], "deleted": [ { "char_end": 81, "char_start": 77, "chars": "'%s'" }, { "char_end": 99, "char_start": 97, "chars": " %" }, { "char_end": 101, "char_start": 100, "chars": "(" }, { "char_end": 107, "char_start": 106, "chars": ")" } ] }, "commit_link": "github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2", "file_name": "plugins/database.py", "func_name": "makeJudge", "line_changes": { "added": [ { "char_end": 104, "char_start": 22, "line": "\tdb.execute(\"UPDATE players SET Judge = 1 WHERE Name = ? COLLATE NOCASE\", judge) \n", "line_no": 2 } ], "deleted": [ { "char_end": 110, "char_start": 22, "line": "\tdb.execute(\"UPDATE players SET Judge = 1 WHERE Name = '%s' COLLATE NOCASE\" % (judge)) \n", "line_no": 2 } ] }, "vul_type": "cwe-089" }
229
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def isValidAdmToken(adm_token):\n conn, c = connectDB()", " req = \"SELECT * from {} where adm_token='{}'\".format(CFG(\"admintoken_table_name\"), adm_token)\n answer = bool(queryOne(c, req))", " closeDB(conn)\n return answer" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 104, "char_start": 103, "chars": "?" }, { "char_end": 190, "char_start": 176, "chars": ", (adm_token,)" } ], "deleted": [ { "char_end": 107, "char_start": 103, "chars": "'{}'" }, { "char_end": 155, "char_start": 144, "chars": ", adm_token" } ] }, "commit_link": "github.com/FAUSheppy/simple-python-poll/commit/186c5ff5cdf58272e253a1bb432419ee50d93109", "file_name": "database.py", "func_name": "isValidAdmToken", "line_changes": { "added": [ { "char_end": 143, "char_start": 58, "line": " req = \"SELECT * from {} where adm_token=?\".format(CFG(\"admintoken_table_name\"))\n", "line_no": 3 }, { "char_end": 193, "char_start": 143, "line": " answer = bool(queryOne(c, req, (adm_token,)))\n", "line_no": 4 } ], "deleted": [ { "char_end": 157, "char_start": 58, "line": " req = \"SELECT * from {} where adm_token='{}'\".format(CFG(\"admintoken_table_name\"), adm_token)\n", "line_no": 3 }, { "char_end": 193, "char_start": 157, "line": " answer = bool(queryOne(c, req))\n", "line_no": 4 } ] }, "vul_type": "cwe-089" }
230
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def isValidAdmToken(adm_token):\n conn, c = connectDB()", " req = \"SELECT * from {} where adm_token=?\".format(CFG(\"admintoken_table_name\"))\n answer = bool(queryOne(c, req, (adm_token,)))", " closeDB(conn)\n return answer" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 104, "char_start": 103, "chars": "?" }, { "char_end": 190, "char_start": 176, "chars": ", (adm_token,)" } ], "deleted": [ { "char_end": 107, "char_start": 103, "chars": "'{}'" }, { "char_end": 155, "char_start": 144, "chars": ", adm_token" } ] }, "commit_link": "github.com/FAUSheppy/simple-python-poll/commit/186c5ff5cdf58272e253a1bb432419ee50d93109", "file_name": "database.py", "func_name": "isValidAdmToken", "line_changes": { "added": [ { "char_end": 143, "char_start": 58, "line": " req = \"SELECT * from {} where adm_token=?\".format(CFG(\"admintoken_table_name\"))\n", "line_no": 3 }, { "char_end": 193, "char_start": 143, "line": " answer = bool(queryOne(c, req, (adm_token,)))\n", "line_no": 4 } ], "deleted": [ { "char_end": 157, "char_start": 58, "line": " req = \"SELECT * from {} where adm_token='{}'\".format(CFG(\"admintoken_table_name\"), adm_token)\n", "line_no": 3 }, { "char_end": 193, "char_start": 157, "line": " answer = bool(queryOne(c, req))\n", "line_no": 4 } ] }, "vul_type": "cwe-089" }
230
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@staticmethod\n def get_mapped_projects(user_id: int, preferred_locale: str) -> UserMappedProjectsDTO:\n \"\"\" Get all projects a user has mapped on \"\"\"", " # This query looks scary, but we're really just creating an outer join between the query that gets the\n # counts of all mapped tasks and the query that gets counts of all validated tasks. This is necessary to\n # handle cases where users have only validated tasks on a project, or only mapped on a project.\n sql = '''SELECT p.id,\n p.status,\n p.default_locale,\n c.mapped,\n c.validated,\n st_asgeojson(p.centroid)\n FROM projects p,\n (SELECT coalesce(v.project_id, m.project_id) project_id,\n coalesce(v.validated, 0) validated,\n coalesce(m.mapped, 0) mapped\n FROM (SELECT t.project_id,\n count (t.validated_by) validated\n FROM tasks t", " WHERE t.project_id IN (SELECT unnest(projects_mapped) FROM users WHERE id = {0})\n AND t.validated_by = {0}", " GROUP BY t.project_id, t.validated_by) v\n FULL OUTER JOIN\n (SELECT t.project_id,\n count(t.mapped_by) mapped\n FROM tasks t", " WHERE t.project_id IN (SELECT unnest(projects_mapped) FROM users WHERE id = {0})\n AND t.mapped_by = {0}", " GROUP BY t.project_id, t.mapped_by) m\n ON v.project_id = m.project_id) c", " WHERE p.id = c.project_id ORDER BY p.id DESC'''.format(user_id)", "", " results = db.engine.execute(sql)", "\n if results.rowcount == 0:\n raise NotFound()", " mapped_projects_dto = UserMappedProjectsDTO()\n for row in results:\n mapped_project = MappedProject()\n mapped_project.project_id = row[0]\n mapped_project.status = ProjectStatus(row[1]).name\n mapped_project.tasks_mapped = row[3]\n mapped_project.tasks_validated = row[4]\n mapped_project.centroid = geojson.loads(row[5])", " project_info = ProjectInfo.get_dto_for_locale(row[0], preferred_locale, row[2])\n mapped_project.name = project_info.name", " mapped_projects_dto.mapped_projects.append(mapped_project)", " return mapped_projects_dto" ]
[ 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 1254, "char_start": 1246, "chars": ":user_id" }, { "char_end": 1320, "char_start": 1312, "chars": ":user_id" }, { "char_end": 1690, "char_start": 1682, "chars": ":user_id" }, { "char_end": 1746, "char_start": 1738, "chars": ":user_id" }, { "char_end": 1979, "char_start": 1974, "chars": "text(" }, { "char_end": 2000, "char_start": 1982, "chars": "), user_id=user_id" } ], "deleted": [ { "char_end": 1249, "char_start": 1246, "chars": "{0}" }, { "char_end": 1310, "char_start": 1307, "chars": "{0}" }, { "char_end": 1675, "char_start": 1672, "chars": "{0}" }, { "char_end": 1726, "char_start": 1723, "chars": "{0}" }, { "char_end": 1932, "char_start": 1916, "chars": ".format(user_id)" } ] }, "commit_link": "github.com/hotosm/tasking-manager/commit/dee040a2d22b3c4d5e38e2dbf8c6b651ad4c241a", "file_name": "server/models/postgis/user.py", "func_name": "get_mapped_projects", "line_changes": { "added": [ { "char_end": 1256, "char_start": 1137, "line": " WHERE t.project_id IN (SELECT unnest(projects_mapped) FROM users WHERE id = :user_id)\n", "line_no": 21 }, { "char_end": 1321, "char_start": 1256, "line": " AND t.validated_by = :user_id\n", "line_no": 22 }, { "char_end": 1692, "char_start": 1580, "line": " WHERE t.project_id IN (SELECT unnest(projects_mapped) FROM users WHERE id = :user_id)\n", "line_no": 28 }, { "char_end": 1747, "char_start": 1692, "line": " AND t.mapped_by = :user_id\n", "line_no": 29 }, { "char_end": 1937, "char_start": 1870, "line": " WHERE p.id = c.project_id ORDER BY p.id DESC'''\n", "line_no": 32 }, { "char_end": 2002, "char_start": 1938, "line": " results = db.engine.execute(text(sql), user_id=user_id)\n", "line_no": 34 } ], "deleted": [ { "char_end": 1251, "char_start": 1137, "line": " WHERE t.project_id IN (SELECT unnest(projects_mapped) FROM users WHERE id = {0})\n", "line_no": 21 }, { "char_end": 1311, "char_start": 1251, "line": " AND t.validated_by = {0}\n", "line_no": 22 }, { "char_end": 1677, "char_start": 1570, "line": " WHERE t.project_id IN (SELECT unnest(projects_mapped) FROM users WHERE id = {0})\n", "line_no": 28 }, { "char_end": 1727, "char_start": 1677, "line": " AND t.mapped_by = {0}\n", "line_no": 29 }, { "char_end": 1933, "char_start": 1850, "line": " WHERE p.id = c.project_id ORDER BY p.id DESC'''.format(user_id)\n", "line_no": 32 }, { "char_end": 1975, "char_start": 1934, "line": " results = db.engine.execute(sql)\n", "line_no": 34 } ] }, "vul_type": "cwe-089" }
231
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@staticmethod\n def get_mapped_projects(user_id: int, preferred_locale: str) -> UserMappedProjectsDTO:\n \"\"\" Get all projects a user has mapped on \"\"\"", " # This query looks scary, but we're really just creating an outer join between the query that gets the\n # counts of all mapped tasks and the query that gets counts of all validated tasks. This is necessary to\n # handle cases where users have only validated tasks on a project, or only mapped on a project.\n sql = '''SELECT p.id,\n p.status,\n p.default_locale,\n c.mapped,\n c.validated,\n st_asgeojson(p.centroid)\n FROM projects p,\n (SELECT coalesce(v.project_id, m.project_id) project_id,\n coalesce(v.validated, 0) validated,\n coalesce(m.mapped, 0) mapped\n FROM (SELECT t.project_id,\n count (t.validated_by) validated\n FROM tasks t", " WHERE t.project_id IN (SELECT unnest(projects_mapped) FROM users WHERE id = :user_id)\n AND t.validated_by = :user_id", " GROUP BY t.project_id, t.validated_by) v\n FULL OUTER JOIN\n (SELECT t.project_id,\n count(t.mapped_by) mapped\n FROM tasks t", " WHERE t.project_id IN (SELECT unnest(projects_mapped) FROM users WHERE id = :user_id)\n AND t.mapped_by = :user_id", " GROUP BY t.project_id, t.mapped_by) m\n ON v.project_id = m.project_id) c", " WHERE p.id = c.project_id ORDER BY p.id DESC'''", "", " results = db.engine.execute(text(sql), user_id=user_id)", "\n if results.rowcount == 0:\n raise NotFound()", " mapped_projects_dto = UserMappedProjectsDTO()\n for row in results:\n mapped_project = MappedProject()\n mapped_project.project_id = row[0]\n mapped_project.status = ProjectStatus(row[1]).name\n mapped_project.tasks_mapped = row[3]\n mapped_project.tasks_validated = row[4]\n mapped_project.centroid = geojson.loads(row[5])", " project_info = ProjectInfo.get_dto_for_locale(row[0], preferred_locale, row[2])\n mapped_project.name = project_info.name", " mapped_projects_dto.mapped_projects.append(mapped_project)", " return mapped_projects_dto" ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 1254, "char_start": 1246, "chars": ":user_id" }, { "char_end": 1320, "char_start": 1312, "chars": ":user_id" }, { "char_end": 1690, "char_start": 1682, "chars": ":user_id" }, { "char_end": 1746, "char_start": 1738, "chars": ":user_id" }, { "char_end": 1979, "char_start": 1974, "chars": "text(" }, { "char_end": 2000, "char_start": 1982, "chars": "), user_id=user_id" } ], "deleted": [ { "char_end": 1249, "char_start": 1246, "chars": "{0}" }, { "char_end": 1310, "char_start": 1307, "chars": "{0}" }, { "char_end": 1675, "char_start": 1672, "chars": "{0}" }, { "char_end": 1726, "char_start": 1723, "chars": "{0}" }, { "char_end": 1932, "char_start": 1916, "chars": ".format(user_id)" } ] }, "commit_link": "github.com/hotosm/tasking-manager/commit/dee040a2d22b3c4d5e38e2dbf8c6b651ad4c241a", "file_name": "server/models/postgis/user.py", "func_name": "get_mapped_projects", "line_changes": { "added": [ { "char_end": 1256, "char_start": 1137, "line": " WHERE t.project_id IN (SELECT unnest(projects_mapped) FROM users WHERE id = :user_id)\n", "line_no": 21 }, { "char_end": 1321, "char_start": 1256, "line": " AND t.validated_by = :user_id\n", "line_no": 22 }, { "char_end": 1692, "char_start": 1580, "line": " WHERE t.project_id IN (SELECT unnest(projects_mapped) FROM users WHERE id = :user_id)\n", "line_no": 28 }, { "char_end": 1747, "char_start": 1692, "line": " AND t.mapped_by = :user_id\n", "line_no": 29 }, { "char_end": 1937, "char_start": 1870, "line": " WHERE p.id = c.project_id ORDER BY p.id DESC'''\n", "line_no": 32 }, { "char_end": 2002, "char_start": 1938, "line": " results = db.engine.execute(text(sql), user_id=user_id)\n", "line_no": 34 } ], "deleted": [ { "char_end": 1251, "char_start": 1137, "line": " WHERE t.project_id IN (SELECT unnest(projects_mapped) FROM users WHERE id = {0})\n", "line_no": 21 }, { "char_end": 1311, "char_start": 1251, "line": " AND t.validated_by = {0}\n", "line_no": 22 }, { "char_end": 1677, "char_start": 1570, "line": " WHERE t.project_id IN (SELECT unnest(projects_mapped) FROM users WHERE id = {0})\n", "line_no": 28 }, { "char_end": 1727, "char_start": 1677, "line": " AND t.mapped_by = {0}\n", "line_no": 29 }, { "char_end": 1933, "char_start": 1850, "line": " WHERE p.id = c.project_id ORDER BY p.id DESC'''.format(user_id)\n", "line_no": 32 }, { "char_end": 1975, "char_start": 1934, "line": " results = db.engine.execute(sql)\n", "line_no": 34 } ] }, "vul_type": "cwe-089" }
231
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def delete_data(self, session, id):\n self._openContainer(session)\n sid = str(id)\n if (self.idNormalizer is not None):\n sid = self.idNormalizer.process_string(session, str(id))", " query = \"DELETE FROM %s WHERE identifier = '%s';\" % (self.table, sid)\n self._query(query)", " return None" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 265, "char_start": 263, "chars": "$1" }, { "char_end": 313, "char_start": 308, "chars": ", sid" } ], "deleted": [ { "char_end": 267, "char_start": 263, "chars": "'%s'" }, { "char_end": 288, "char_start": 283, "chars": ", sid" } ] }, "commit_link": "github.com/cheshire3/cheshire3/commit/d350363b4ea10f102c24c8f26d7b76b006323e8e", "file_name": "cheshire3/sql/postgresStore.py", "func_name": "delete_data", "line_changes": { "added": [ { "char_end": 283, "char_start": 212, "line": " query = \"DELETE FROM %s WHERE identifier = $1;\" % (self.table)\n", "line_no": 6 }, { "char_end": 315, "char_start": 283, "line": " self._query(query, sid)\n", "line_no": 7 } ], "deleted": [ { "char_end": 290, "char_start": 212, "line": " query = \"DELETE FROM %s WHERE identifier = '%s';\" % (self.table, sid)\n", "line_no": 6 }, { "char_end": 317, "char_start": 290, "line": " self._query(query)\n", "line_no": 7 } ] }, "vul_type": "cwe-089" }
232
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def delete_data(self, session, id):\n self._openContainer(session)\n sid = str(id)\n if (self.idNormalizer is not None):\n sid = self.idNormalizer.process_string(session, str(id))", " query = \"DELETE FROM %s WHERE identifier = $1;\" % (self.table)\n self._query(query, sid)", " return None" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 265, "char_start": 263, "chars": "$1" }, { "char_end": 313, "char_start": 308, "chars": ", sid" } ], "deleted": [ { "char_end": 267, "char_start": 263, "chars": "'%s'" }, { "char_end": 288, "char_start": 283, "chars": ", sid" } ] }, "commit_link": "github.com/cheshire3/cheshire3/commit/d350363b4ea10f102c24c8f26d7b76b006323e8e", "file_name": "cheshire3/sql/postgresStore.py", "func_name": "delete_data", "line_changes": { "added": [ { "char_end": 283, "char_start": 212, "line": " query = \"DELETE FROM %s WHERE identifier = $1;\" % (self.table)\n", "line_no": 6 }, { "char_end": 315, "char_start": 283, "line": " self._query(query, sid)\n", "line_no": 7 } ], "deleted": [ { "char_end": 290, "char_start": 212, "line": " query = \"DELETE FROM %s WHERE identifier = '%s';\" % (self.table, sid)\n", "line_no": 6 }, { "char_end": 317, "char_start": 290, "line": " self._query(query)\n", "line_no": 7 } ] }, "vul_type": "cwe-089" }
232
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def user_verify(self):\n eid = self.email\n code = self.password\n if eid.strip() == '':\n return\n if code.strip() == '':\n return", " query = '''select * from usr where email like\\''''+eid+'\\''\n cursor = g.conn.execute(query)", " for row in cursor:\n key = str(row.password)\n if key.strip() == code.strip():\n self.name = str(row.name)\n self.email = eid\n self.id = eid\n self.valid = True\n break" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 234, "char_start": 231, "chars": " %s" }, { "char_end": 282, "char_start": 273, "chars": ", (eid, )" } ], "deleted": [ { "char_end": 199, "char_start": 197, "chars": "''" }, { "char_end": 246, "char_start": 233, "chars": "\\''''+eid+'\\'" } ] }, "commit_link": "github.com/Daniel-Bu/w4111-project1/commit/fe04bedc72e62fd4c4ee046a9af29fd81e9b3340", "file_name": "Web-app/User.py", "func_name": "user_verify", "line_changes": { "added": [ { "char_end": 236, "char_start": 180, "line": " query = 'select * from usr where email like %s'\n", "line_no": 8 }, { "char_end": 284, "char_start": 236, "line": " cursor = g.conn.execute(query, (eid, ))\n", "line_no": 9 } ], "deleted": [ { "char_end": 248, "char_start": 180, "line": " query = '''select * from usr where email like\\''''+eid+'\\''\n", "line_no": 8 }, { "char_end": 287, "char_start": 248, "line": " cursor = g.conn.execute(query)\n", "line_no": 9 } ] }, "vul_type": "cwe-089" }
233
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def user_verify(self):\n eid = self.email\n code = self.password\n if eid.strip() == '':\n return\n if code.strip() == '':\n return", " query = 'select * from usr where email like %s'\n cursor = g.conn.execute(query, (eid, ))", " for row in cursor:\n key = str(row.password)\n if key.strip() == code.strip():\n self.name = str(row.name)\n self.email = eid\n self.id = eid\n self.valid = True\n break" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 234, "char_start": 231, "chars": " %s" }, { "char_end": 282, "char_start": 273, "chars": ", (eid, )" } ], "deleted": [ { "char_end": 199, "char_start": 197, "chars": "''" }, { "char_end": 246, "char_start": 233, "chars": "\\''''+eid+'\\'" } ] }, "commit_link": "github.com/Daniel-Bu/w4111-project1/commit/fe04bedc72e62fd4c4ee046a9af29fd81e9b3340", "file_name": "Web-app/User.py", "func_name": "user_verify", "line_changes": { "added": [ { "char_end": 236, "char_start": 180, "line": " query = 'select * from usr where email like %s'\n", "line_no": 8 }, { "char_end": 284, "char_start": 236, "line": " cursor = g.conn.execute(query, (eid, ))\n", "line_no": 9 } ], "deleted": [ { "char_end": 248, "char_start": 180, "line": " query = '''select * from usr where email like\\''''+eid+'\\''\n", "line_no": 8 }, { "char_end": 287, "char_start": 248, "line": " cursor = g.conn.execute(query)\n", "line_no": 9 } ] }, "vul_type": "cwe-089" }
233
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@app.route('/movies/search', methods=['GET', 'POST'])\ndef search_films():\n form = SearchForm()\n if not form.validate_on_submit():\n return render_template('search.html', title='Search for films', form=form)\n search_terms = form.data['term'].split(' ')\n search_string = ' & '.join(search_terms)", " cur.execute(f\"SELECT * FROM film where fulltext @@ to_tsquery('{search_string}')\")", " res = cur.fetchall()\n return render_template('search_results.html', title='Home', res=len(res))" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 384, "char_start": 377, "chars": "%s)\", (" }, { "char_end": 399, "char_start": 397, "chars": ", " } ], "deleted": [ { "char_end": 329, "char_start": 328, "chars": "f" }, { "char_end": 380, "char_start": 378, "chars": "'{" }, { "char_end": 395, "char_start": 393, "chars": "}'" }, { "char_end": 397, "char_start": 396, "chars": "\"" } ] }, "commit_link": "github.com/Elbertbiggs360/dvdrental/commit/ad144ae2a08a332498d0831bc255170d57ba754b", "file_name": "app.py", "func_name": "search_films", "line_changes": { "added": [ { "char_end": 402, "char_start": 312, "line": " cur.execute(\"SELECT * FROM film where fulltext @@ to_tsquery(%s)\", (search_string, ))\n", "line_no": 8 } ], "deleted": [ { "char_end": 399, "char_start": 312, "line": " cur.execute(f\"SELECT * FROM film where fulltext @@ to_tsquery('{search_string}')\")\n", "line_no": 8 } ] }, "vul_type": "cwe-089" }
234
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@app.route('/movies/search', methods=['GET', 'POST'])\ndef search_films():\n form = SearchForm()\n if not form.validate_on_submit():\n return render_template('search.html', title='Search for films', form=form)\n search_terms = form.data['term'].split(' ')\n search_string = ' & '.join(search_terms)", " cur.execute(\"SELECT * FROM film where fulltext @@ to_tsquery(%s)\", (search_string, ))", " res = cur.fetchall()\n return render_template('search_results.html', title='Home', res=len(res))" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 384, "char_start": 377, "chars": "%s)\", (" }, { "char_end": 399, "char_start": 397, "chars": ", " } ], "deleted": [ { "char_end": 329, "char_start": 328, "chars": "f" }, { "char_end": 380, "char_start": 378, "chars": "'{" }, { "char_end": 395, "char_start": 393, "chars": "}'" }, { "char_end": 397, "char_start": 396, "chars": "\"" } ] }, "commit_link": "github.com/Elbertbiggs360/dvdrental/commit/ad144ae2a08a332498d0831bc255170d57ba754b", "file_name": "app.py", "func_name": "search_films", "line_changes": { "added": [ { "char_end": 402, "char_start": 312, "line": " cur.execute(\"SELECT * FROM film where fulltext @@ to_tsquery(%s)\", (search_string, ))\n", "line_no": 8 } ], "deleted": [ { "char_end": 399, "char_start": 312, "line": " cur.execute(f\"SELECT * FROM film where fulltext @@ to_tsquery('{search_string}')\")\n", "line_no": 8 } ] }, "vul_type": "cwe-089" }
234
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def getGameCountInSeriesSoFar(submission):\n database = sqlite3.connect('database.db')\n cursor = database.cursor()", " return cursor.execute(\"SELECT COUNT(*) FROM ChallengeRankings WHERE SeriesTitle = '\" + getTitle(submission) + \"' AND Date <= '\" + getSubmissionDateFromDatabase(submission) + \"'\").fetchone()[0]", " database.close()" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 207, "char_start": 206, "chars": "?" }, { "char_end": 211, "char_start": 208, "chars": "AND" }, { "char_end": 225, "char_start": 212, "chars": "Date <= ?\", [" }, { "char_end": 246, "char_start": 245, "chars": "," }, { "char_end": 289, "char_start": 288, "chars": "]" } ], "deleted": [ { "char_end": 208, "char_start": 206, "chars": "'\"" }, { "char_end": 210, "char_start": 209, "chars": "+" }, { "char_end": 253, "char_start": 231, "chars": " + \"' AND Date <= '\" +" }, { "char_end": 301, "char_start": 295, "chars": " + \"'\"" } ] }, "commit_link": "github.com/LiquidFun/Reddit-GeoGuessr-Tracking-Bot/commit/0cad2d52e24b05da32789fbc8face7a9999a71f9", "file_name": "CheckAndPostForSeriesSubmissions.py", "func_name": "getGameCountInSeriesSoFar", "line_changes": { "added": [ { "char_end": 305, "char_start": 120, "line": " return cursor.execute(\"SELECT COUNT(*) FROM ChallengeRankings WHERE SeriesTitle = ? AND Date <= ?\", [getTitle(submission), getSubmissionDateFromDatabase(submission)]).fetchone()[0]\n", "line_no": 4 } ], "deleted": [ { "char_end": 317, "char_start": 120, "line": " return cursor.execute(\"SELECT COUNT(*) FROM ChallengeRankings WHERE SeriesTitle = '\" + getTitle(submission) + \"' AND Date <= '\" + getSubmissionDateFromDatabase(submission) + \"'\").fetchone()[0]\n", "line_no": 4 } ] }, "vul_type": "cwe-089" }
235
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def getGameCountInSeriesSoFar(submission):\n database = sqlite3.connect('database.db')\n cursor = database.cursor()", " return cursor.execute(\"SELECT COUNT(*) FROM ChallengeRankings WHERE SeriesTitle = ? AND Date <= ?\", [getTitle(submission), getSubmissionDateFromDatabase(submission)]).fetchone()[0]", " database.close()" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 207, "char_start": 206, "chars": "?" }, { "char_end": 211, "char_start": 208, "chars": "AND" }, { "char_end": 225, "char_start": 212, "chars": "Date <= ?\", [" }, { "char_end": 246, "char_start": 245, "chars": "," }, { "char_end": 289, "char_start": 288, "chars": "]" } ], "deleted": [ { "char_end": 208, "char_start": 206, "chars": "'\"" }, { "char_end": 210, "char_start": 209, "chars": "+" }, { "char_end": 253, "char_start": 231, "chars": " + \"' AND Date <= '\" +" }, { "char_end": 301, "char_start": 295, "chars": " + \"'\"" } ] }, "commit_link": "github.com/LiquidFun/Reddit-GeoGuessr-Tracking-Bot/commit/0cad2d52e24b05da32789fbc8face7a9999a71f9", "file_name": "CheckAndPostForSeriesSubmissions.py", "func_name": "getGameCountInSeriesSoFar", "line_changes": { "added": [ { "char_end": 305, "char_start": 120, "line": " return cursor.execute(\"SELECT COUNT(*) FROM ChallengeRankings WHERE SeriesTitle = ? AND Date <= ?\", [getTitle(submission), getSubmissionDateFromDatabase(submission)]).fetchone()[0]\n", "line_no": 4 } ], "deleted": [ { "char_end": 317, "char_start": 120, "line": " return cursor.execute(\"SELECT COUNT(*) FROM ChallengeRankings WHERE SeriesTitle = '\" + getTitle(submission) + \"' AND Date <= '\" + getSubmissionDateFromDatabase(submission) + \"'\").fetchone()[0]\n", "line_no": 4 } ] }, "vul_type": "cwe-089" }
235
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@mod.route('/add', methods=['GET', 'POST'])\ndef add():\n if request.method == 'POST':\n msg_id = int(request.form['msg_id'])\n user_id = session['logged_id']\n content = request.form['content']\n c_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')", " sql = \"INSERT INTO comment(msg_id,user_id,content,c_time) \" + \\\n \"VALUES(%d,%d,'%s','%s');\" % (msg_id, user_id, content, c_time)\n cursor.execute(sql)", " conn.commit()\n return redirect(url_for('comment.show', msg_id=msg_id))" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 287, "char_start": 284, "chars": "cur" }, { "char_end": 299, "char_start": 288, "chars": "or.execute(" }, { "char_end": 360, "char_start": 359, "chars": "s" }, { "char_end": 363, "char_start": 362, "chars": "s" }, { "char_end": 373, "char_start": 372, "chars": "," } ], "deleted": [ { "char_end": 290, "char_start": 285, "chars": "ql = " }, { "char_end": 365, "char_start": 342, "chars": "\" + \\\n \"" }, { "char_end": 374, "char_start": 373, "chars": "d" }, { "char_end": 377, "char_start": 376, "chars": "d" }, { "char_end": 379, "char_start": 378, "chars": "'" }, { "char_end": 382, "char_start": 381, "chars": "'" }, { "char_end": 384, "char_start": 383, "chars": "'" }, { "char_end": 387, "char_start": 386, "chars": "'" }, { "char_end": 392, "char_start": 390, "chars": " %" }, { "char_end": 454, "char_start": 427, "chars": "\n cursor.execute(sql" } ] }, "commit_link": "github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9", "file_name": "flaskr/flaskr/views/comment.py", "func_name": "add", "line_changes": { "added": [ { "char_end": 410, "char_start": 276, "line": " cursor.execute(\"INSERT INTO comment(msg_id,user_id,content,c_time) VALUES(%s,%s,%s,%s);\", (msg_id, user_id, content, c_time))\n", "line_no": 8 } ], "deleted": [ { "char_end": 348, "char_start": 276, "line": " sql = \"INSERT INTO comment(msg_id,user_id,content,c_time) \" + \\\n", "line_no": 8 }, { "char_end": 428, "char_start": 348, "line": " \"VALUES(%d,%d,'%s','%s');\" % (msg_id, user_id, content, c_time)\n", "line_no": 9 }, { "char_end": 456, "char_start": 428, "line": " cursor.execute(sql)\n", "line_no": 10 } ] }, "vul_type": "cwe-089" }
236
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@mod.route('/add', methods=['GET', 'POST'])\ndef add():\n if request.method == 'POST':\n msg_id = int(request.form['msg_id'])\n user_id = session['logged_id']\n content = request.form['content']\n c_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')", " cursor.execute(\"INSERT INTO comment(msg_id,user_id,content,c_time) VALUES(%s,%s,%s,%s);\", (msg_id, user_id, content, c_time))", " conn.commit()\n return redirect(url_for('comment.show', msg_id=msg_id))" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 287, "char_start": 284, "chars": "cur" }, { "char_end": 299, "char_start": 288, "chars": "or.execute(" }, { "char_end": 360, "char_start": 359, "chars": "s" }, { "char_end": 363, "char_start": 362, "chars": "s" }, { "char_end": 373, "char_start": 372, "chars": "," } ], "deleted": [ { "char_end": 290, "char_start": 285, "chars": "ql = " }, { "char_end": 365, "char_start": 342, "chars": "\" + \\\n \"" }, { "char_end": 374, "char_start": 373, "chars": "d" }, { "char_end": 377, "char_start": 376, "chars": "d" }, { "char_end": 379, "char_start": 378, "chars": "'" }, { "char_end": 382, "char_start": 381, "chars": "'" }, { "char_end": 384, "char_start": 383, "chars": "'" }, { "char_end": 387, "char_start": 386, "chars": "'" }, { "char_end": 392, "char_start": 390, "chars": " %" }, { "char_end": 454, "char_start": 427, "chars": "\n cursor.execute(sql" } ] }, "commit_link": "github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9", "file_name": "flaskr/flaskr/views/comment.py", "func_name": "add", "line_changes": { "added": [ { "char_end": 410, "char_start": 276, "line": " cursor.execute(\"INSERT INTO comment(msg_id,user_id,content,c_time) VALUES(%s,%s,%s,%s);\", (msg_id, user_id, content, c_time))\n", "line_no": 8 } ], "deleted": [ { "char_end": 348, "char_start": 276, "line": " sql = \"INSERT INTO comment(msg_id,user_id,content,c_time) \" + \\\n", "line_no": 8 }, { "char_end": 428, "char_start": 348, "line": " \"VALUES(%d,%d,'%s','%s');\" % (msg_id, user_id, content, c_time)\n", "line_no": 9 }, { "char_end": 456, "char_start": 428, "line": " cursor.execute(sql)\n", "line_no": 10 } ] }, "vul_type": "cwe-089" }
236
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def get_mod_taken_together_with(code):\n '''\n Retrieves the list of modules taken together with the specified\n module code in the same semester.", " Returns a table of lists (up to 10 top results). Each list contains\n (specified code, module code of mod taken together, aySem, number of students)", " e.g. [(CS1010, CS1231, AY 16/17 Sem 1, 5)] means there are 5 students\n taking CS1010 and CS1231 together in AY 16/17 Sem 1.\n '''\n NUM_TOP_RESULTS_TO_RETURN = 10", " sql_command = \"SELECT sp1.moduleCode, sp2.moduleCode, sp1.acadYearAndSem, COUNT(*) \" + \\\n \"FROM studentPlans sp1, studentPlans sp2 \" + \\", " \"WHERE sp1.moduleCode = '\" + code + \"' AND \" + \\", " \"sp2.moduleCode <> sp1.moduleCode AND \" + \\\n \"sp1.studentId = sp2.studentId AND \" + \\\n \"sp1.acadYearAndSem = sp2.acadYearAndSem \" + \\\n \"GROUP BY sp1.moduleCode, sp2.moduleCode, sp1.acadYearAndSem \" + \\\n \"ORDER BY COUNT(*) DESC\"\n", " DB_CURSOR.execute(sql_command)", "\n return DB_CURSOR.fetchmany(NUM_TOP_RESULTS_TO_RETURN)" ]
[ 1, 1, 1, 1, 0, 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 707, "char_start": 705, "chars": "%s" }, { "char_end": 1065, "char_start": 1056, "chars": ", (code,)" } ], "deleted": [ { "char_end": 719, "char_start": 705, "chars": "'\" + code + \"'" } ] }, "commit_link": "github.com/nus-mtp/cs-modify/commit/79b4b1dd7eba5445751808e4c50b49d2dd08366b", "file_name": "components/model.py", "func_name": "get_mod_taken_together_with", "line_changes": { "added": [ { "char_end": 718, "char_start": 665, "line": " \"WHERE sp1.moduleCode = %s AND \" + \\\n", "line_no": 16 }, { "char_end": 1067, "char_start": 1023, "line": " DB_CURSOR.execute(sql_command, (code,))\n", "line_no": 23 } ], "deleted": [ { "char_end": 730, "char_start": 665, "line": " \"WHERE sp1.moduleCode = '\" + code + \"' AND \" + \\\n", "line_no": 16 }, { "char_end": 1070, "char_start": 1035, "line": " DB_CURSOR.execute(sql_command)\n", "line_no": 23 } ] }, "vul_type": "cwe-089" }
237
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def get_mod_taken_together_with(code):\n '''\n Retrieves the list of modules taken together with the specified\n module code in the same semester.", " Returns a table of lists (up to 10 top results). Each list contains\n (specified code, module code of mod taken together, aySem, number of students)", " e.g. [(CS1010, CS1231, AY 16/17 Sem 1, 5)] means there are 5 students\n taking CS1010 and CS1231 together in AY 16/17 Sem 1.\n '''\n NUM_TOP_RESULTS_TO_RETURN = 10", " sql_command = \"SELECT sp1.moduleCode, sp2.moduleCode, sp1.acadYearAndSem, COUNT(*) \" + \\\n \"FROM studentPlans sp1, studentPlans sp2 \" + \\", " \"WHERE sp1.moduleCode = %s AND \" + \\", " \"sp2.moduleCode <> sp1.moduleCode AND \" + \\\n \"sp1.studentId = sp2.studentId AND \" + \\\n \"sp1.acadYearAndSem = sp2.acadYearAndSem \" + \\\n \"GROUP BY sp1.moduleCode, sp2.moduleCode, sp1.acadYearAndSem \" + \\\n \"ORDER BY COUNT(*) DESC\"\n", " DB_CURSOR.execute(sql_command, (code,))", "\n return DB_CURSOR.fetchmany(NUM_TOP_RESULTS_TO_RETURN)" ]
[ 1, 1, 1, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 707, "char_start": 705, "chars": "%s" }, { "char_end": 1065, "char_start": 1056, "chars": ", (code,)" } ], "deleted": [ { "char_end": 719, "char_start": 705, "chars": "'\" + code + \"'" } ] }, "commit_link": "github.com/nus-mtp/cs-modify/commit/79b4b1dd7eba5445751808e4c50b49d2dd08366b", "file_name": "components/model.py", "func_name": "get_mod_taken_together_with", "line_changes": { "added": [ { "char_end": 718, "char_start": 665, "line": " \"WHERE sp1.moduleCode = %s AND \" + \\\n", "line_no": 16 }, { "char_end": 1067, "char_start": 1023, "line": " DB_CURSOR.execute(sql_command, (code,))\n", "line_no": 23 } ], "deleted": [ { "char_end": 730, "char_start": 665, "line": " \"WHERE sp1.moduleCode = '\" + code + \"' AND \" + \\\n", "line_no": 16 }, { "char_end": 1070, "char_start": 1035, "line": " DB_CURSOR.execute(sql_command)\n", "line_no": 23 } ] }, "vul_type": "cwe-089" }
237
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@endpoints.route(\"/wins\")\ndef wins():\n if db == None:\n init()", " player = request.args.get('tag', default=\"christmasmike\")", " sql = \"SELECT * FROM matches WHERE winner = '\"+str(player)+\"' ORDER BY date DESC;\"\n result = db.exec(sql)", "\n result = [str(x) for x in result]\n result = '\\n'.join(result)\n return json.dumps(result)" ]
[ 1, 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 185, "char_start": 184, "chars": "{" }, { "char_end": 192, "char_start": 191, "chars": "}" }, { "char_end": 249, "char_start": 219, "chars": "args = {'player': player}\n " }, { "char_end": 275, "char_start": 269, "chars": ", args" } ], "deleted": [ { "char_end": 190, "char_start": 184, "chars": "\"+str(" }, { "char_end": 199, "char_start": 196, "chars": ")+\"" } ] }, "commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63", "file_name": "endpoints.py", "func_name": "wins", "line_changes": { "added": [ { "char_end": 215, "char_start": 135, "line": " sql = \"SELECT * FROM matches WHERE winner = '{player}' ORDER BY date DESC;\"\n", "line_no": 7 }, { "char_end": 245, "char_start": 215, "line": " args = {'player': player}\n", "line_no": 8 }, { "char_end": 277, "char_start": 245, "line": " result = db.exec(sql, args)\n", "line_no": 9 } ], "deleted": [ { "char_end": 222, "char_start": 135, "line": " sql = \"SELECT * FROM matches WHERE winner = '\"+str(player)+\"' ORDER BY date DESC;\"\n", "line_no": 7 }, { "char_end": 248, "char_start": 222, "line": " result = db.exec(sql)\n", "line_no": 8 } ] }, "vul_type": "cwe-089" }
238
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@endpoints.route(\"/wins\")\ndef wins():\n if db == None:\n init()", " player = request.args.get('tag', default=\"christmasmike\")", " sql = \"SELECT * FROM matches WHERE winner = '{player}' ORDER BY date DESC;\"\n args = {'player': player}\n result = db.exec(sql, args)", "\n result = [str(x) for x in result]\n result = '\\n'.join(result)\n return json.dumps(result)" ]
[ 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 185, "char_start": 184, "chars": "{" }, { "char_end": 192, "char_start": 191, "chars": "}" }, { "char_end": 249, "char_start": 219, "chars": "args = {'player': player}\n " }, { "char_end": 275, "char_start": 269, "chars": ", args" } ], "deleted": [ { "char_end": 190, "char_start": 184, "chars": "\"+str(" }, { "char_end": 199, "char_start": 196, "chars": ")+\"" } ] }, "commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63", "file_name": "endpoints.py", "func_name": "wins", "line_changes": { "added": [ { "char_end": 215, "char_start": 135, "line": " sql = \"SELECT * FROM matches WHERE winner = '{player}' ORDER BY date DESC;\"\n", "line_no": 7 }, { "char_end": 245, "char_start": 215, "line": " args = {'player': player}\n", "line_no": 8 }, { "char_end": 277, "char_start": 245, "line": " result = db.exec(sql, args)\n", "line_no": 9 } ], "deleted": [ { "char_end": 222, "char_start": 135, "line": " sql = \"SELECT * FROM matches WHERE winner = '\"+str(player)+\"' ORDER BY date DESC;\"\n", "line_no": 7 }, { "char_end": 248, "char_start": 222, "line": " result = db.exec(sql)\n", "line_no": 8 } ] }, "vul_type": "cwe-089" }
238
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def delete_event(self, event_id):", " sql = \"\"\"DELETE FROM events\n WHERE event_id = {0}\n \"\"\".format(event_id)\n affected_count = self.cur.execute(sql)", " self.conn.commit()\n return affected_count" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 70, "char_start": 55, "chars": "\n " }, { "char_end": 122, "char_start": 120, "chars": "%s" }, { "char_end": 199, "char_start": 186, "chars": ", (event_id,)" } ], "deleted": [ { "char_end": 91, "char_start": 88, "chars": " " }, { "char_end": 111, "char_start": 108, "chars": "{0}" }, { "char_end": 115, "char_start": 112, "chars": " " }, { "char_end": 149, "char_start": 132, "chars": ".format(event_id)" } ] }, "commit_link": "github.com/jgayfer/spirit/commit/01c846c534c8d3cf6763f8b7444a0efe2caa3799", "file_name": "db/dbase.py", "func_name": "delete_event", "line_changes": { "added": [ { "char_end": 56, "char_start": 38, "line": " sql = \"\"\"\n", "line_no": 2 }, { "char_end": 89, "char_start": 56, "line": " DELETE FROM events\n", "line_no": 3 }, { "char_end": 123, "char_start": 89, "line": " WHERE event_id = %s\n", "line_no": 4 }, { "char_end": 141, "char_start": 123, "line": " \"\"\"\n", "line_no": 5 }, { "char_end": 201, "char_start": 141, "line": " affected_count = self.cur.execute(sql, (event_id,))\n", "line_no": 6 } ], "deleted": [ { "char_end": 74, "char_start": 38, "line": " sql = \"\"\"DELETE FROM events\n", "line_no": 2 }, { "char_end": 112, "char_start": 74, "line": " WHERE event_id = {0}\n", "line_no": 3 }, { "char_end": 150, "char_start": 112, "line": " \"\"\".format(event_id)\n", "line_no": 4 }, { "char_end": 197, "char_start": 150, "line": " affected_count = self.cur.execute(sql)\n", "line_no": 5 } ] }, "vul_type": "cwe-089" }
239
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def delete_event(self, event_id):", " sql = \"\"\"\n DELETE FROM events\n WHERE event_id = %s\n \"\"\"\n affected_count = self.cur.execute(sql, (event_id,))", " self.conn.commit()\n return affected_count" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 70, "char_start": 55, "chars": "\n " }, { "char_end": 122, "char_start": 120, "chars": "%s" }, { "char_end": 199, "char_start": 186, "chars": ", (event_id,)" } ], "deleted": [ { "char_end": 91, "char_start": 88, "chars": " " }, { "char_end": 111, "char_start": 108, "chars": "{0}" }, { "char_end": 115, "char_start": 112, "chars": " " }, { "char_end": 149, "char_start": 132, "chars": ".format(event_id)" } ] }, "commit_link": "github.com/jgayfer/spirit/commit/01c846c534c8d3cf6763f8b7444a0efe2caa3799", "file_name": "db/dbase.py", "func_name": "delete_event", "line_changes": { "added": [ { "char_end": 56, "char_start": 38, "line": " sql = \"\"\"\n", "line_no": 2 }, { "char_end": 89, "char_start": 56, "line": " DELETE FROM events\n", "line_no": 3 }, { "char_end": 123, "char_start": 89, "line": " WHERE event_id = %s\n", "line_no": 4 }, { "char_end": 141, "char_start": 123, "line": " \"\"\"\n", "line_no": 5 }, { "char_end": 201, "char_start": 141, "line": " affected_count = self.cur.execute(sql, (event_id,))\n", "line_no": 6 } ], "deleted": [ { "char_end": 74, "char_start": 38, "line": " sql = \"\"\"DELETE FROM events\n", "line_no": 2 }, { "char_end": 112, "char_start": 74, "line": " WHERE event_id = {0}\n", "line_no": 3 }, { "char_end": 150, "char_start": 112, "line": " \"\"\".format(event_id)\n", "line_no": 4 }, { "char_end": 197, "char_start": 150, "line": " affected_count = self.cur.execute(sql)\n", "line_no": 5 } ] }, "vul_type": "cwe-089" }
239
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def add_item(self, item):\n \"\"\"\"Add new item.\"\"\"\n if self.connection:", " self.cursor.execute('insert into item (name, shoppinglistid) values (\"%s\", \"%s\")' % (item[0], item[1]))", " self.connection.commit()" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 136, "char_start": 99, "chars": "t = (item[0], item[1], )\n " }, { "char_end": 206, "char_start": 205, "chars": "?" }, { "char_end": 209, "char_start": 208, "chars": "?" } ], "deleted": [ { "char_end": 172, "char_start": 168, "chars": "\"%s\"" }, { "char_end": 178, "char_start": 174, "chars": "\"%s\"" }, { "char_end": 191, "char_start": 180, "chars": " % (item[0]" }, { "char_end": 194, "char_start": 193, "chars": "i" }, { "char_end": 201, "char_start": 195, "chars": "em[1])" } ] }, "commit_link": "github.com/ecosl-developers/ecosl/commit/8af050a513338bf68ff2a243e4a2482d24e9aa3a", "file_name": "ecosldb/ecosldb.py", "func_name": "add_item", "line_changes": { "added": [ { "char_end": 124, "char_start": 87, "line": " t = (item[0], item[1], )\n", "line_no": 4 }, { "char_end": 216, "char_start": 124, "line": " self.cursor.execute('insert into item (name, shoppinglistid) values (?, ?)', t)\n", "line_no": 5 } ], "deleted": [ { "char_end": 203, "char_start": 87, "line": " self.cursor.execute('insert into item (name, shoppinglistid) values (\"%s\", \"%s\")' % (item[0], item[1]))\n", "line_no": 4 } ] }, "vul_type": "cwe-089" }
240
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def add_item(self, item):\n \"\"\"\"Add new item.\"\"\"\n if self.connection:", " t = (item[0], item[1], )\n self.cursor.execute('insert into item (name, shoppinglistid) values (?, ?)', t)", " self.connection.commit()" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 136, "char_start": 99, "chars": "t = (item[0], item[1], )\n " }, { "char_end": 206, "char_start": 205, "chars": "?" }, { "char_end": 209, "char_start": 208, "chars": "?" } ], "deleted": [ { "char_end": 172, "char_start": 168, "chars": "\"%s\"" }, { "char_end": 178, "char_start": 174, "chars": "\"%s\"" }, { "char_end": 191, "char_start": 180, "chars": " % (item[0]" }, { "char_end": 194, "char_start": 193, "chars": "i" }, { "char_end": 201, "char_start": 195, "chars": "em[1])" } ] }, "commit_link": "github.com/ecosl-developers/ecosl/commit/8af050a513338bf68ff2a243e4a2482d24e9aa3a", "file_name": "ecosldb/ecosldb.py", "func_name": "add_item", "line_changes": { "added": [ { "char_end": 124, "char_start": 87, "line": " t = (item[0], item[1], )\n", "line_no": 4 }, { "char_end": 216, "char_start": 124, "line": " self.cursor.execute('insert into item (name, shoppinglistid) values (?, ?)', t)\n", "line_no": 5 } ], "deleted": [ { "char_end": 203, "char_start": 87, "line": " self.cursor.execute('insert into item (name, shoppinglistid) values (\"%s\", \"%s\")' % (item[0], item[1]))\n", "line_no": 4 } ] }, "vul_type": "cwe-089" }
240
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def fetch_issue(cursor, id):\n \"\"\"\n Fetch an issue by id along with its tags. Returns None if no issue\n with the specified id exists in the database.\n \"\"\"", " cursor.execute(f\"\"\"", " SELECT\n issue.id,\n issue.title,\n issue.description,\n tag.namespace,\n tag.predicate,\n tag.value\n FROM\n issue LEFT JOIN tag\n ON issue.id = tag.issue_id\n WHERE", " issue.id = {id}\n \"\"\")", "\n issue = None\n for row in cursor:\n if issue is None:\n issue = {\n \"id\": row[\"id\"],\n \"title\": row[\"title\"],\n \"description\": row[\"description\"],\n \"tags\": [],\n }\n # If tag exists in row, add to issue.\n if row[\"value\"]:\n issue[\"tags\"].append({\n \"namespace\": row[\"namespace\"],\n \"predicate\": row[\"predicate\"],\n \"value\": row[\"value\"],\n })", " return issue" ]
[ 1, 0, 1, 0, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 480, "char_start": 479, "chars": "?" }, { "char_end": 495, "char_start": 488, "chars": ", (id,)" } ], "deleted": [ { "char_end": 186, "char_start": 185, "chars": "f" }, { "char_end": 484, "char_start": 480, "chars": "{id}" } ] }, "commit_link": "github.com/nutty7t/tissue/commit/306dd094749bb39cbd5c74a6ded3d3b191033061", "file_name": "server/server.py", "func_name": "fetch_issue", "line_changes": { "added": [ { "char_end": 189, "char_start": 166, "line": " cursor.execute(\"\"\"\n", "line_no": 6 }, { "char_end": 481, "char_start": 456, "line": " issue.id = ?\n", "line_no": 18 }, { "char_end": 497, "char_start": 481, "line": " \"\"\", (id,))\n", "line_no": 19 } ], "deleted": [ { "char_end": 190, "char_start": 166, "line": " cursor.execute(f\"\"\"\n", "line_no": 6 }, { "char_end": 485, "char_start": 457, "line": " issue.id = {id}\n", "line_no": 18 }, { "char_end": 494, "char_start": 485, "line": " \"\"\")\n", "line_no": 19 } ] }, "vul_type": "cwe-089" }
241
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def fetch_issue(cursor, id):\n \"\"\"\n Fetch an issue by id along with its tags. Returns None if no issue\n with the specified id exists in the database.\n \"\"\"", " cursor.execute(\"\"\"", " SELECT\n issue.id,\n issue.title,\n issue.description,\n tag.namespace,\n tag.predicate,\n tag.value\n FROM\n issue LEFT JOIN tag\n ON issue.id = tag.issue_id\n WHERE", " issue.id = ?\n \"\"\", (id,))", "\n issue = None\n for row in cursor:\n if issue is None:\n issue = {\n \"id\": row[\"id\"],\n \"title\": row[\"title\"],\n \"description\": row[\"description\"],\n \"tags\": [],\n }\n # If tag exists in row, add to issue.\n if row[\"value\"]:\n issue[\"tags\"].append({\n \"namespace\": row[\"namespace\"],\n \"predicate\": row[\"predicate\"],\n \"value\": row[\"value\"],\n })", " return issue" ]
[ 1, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 480, "char_start": 479, "chars": "?" }, { "char_end": 495, "char_start": 488, "chars": ", (id,)" } ], "deleted": [ { "char_end": 186, "char_start": 185, "chars": "f" }, { "char_end": 484, "char_start": 480, "chars": "{id}" } ] }, "commit_link": "github.com/nutty7t/tissue/commit/306dd094749bb39cbd5c74a6ded3d3b191033061", "file_name": "server/server.py", "func_name": "fetch_issue", "line_changes": { "added": [ { "char_end": 189, "char_start": 166, "line": " cursor.execute(\"\"\"\n", "line_no": 6 }, { "char_end": 481, "char_start": 456, "line": " issue.id = ?\n", "line_no": 18 }, { "char_end": 497, "char_start": 481, "line": " \"\"\", (id,))\n", "line_no": 19 } ], "deleted": [ { "char_end": 190, "char_start": 166, "line": " cursor.execute(f\"\"\"\n", "line_no": 6 }, { "char_end": 485, "char_start": 457, "line": " issue.id = {id}\n", "line_no": 18 }, { "char_end": 494, "char_start": 485, "line": " \"\"\")\n", "line_no": 19 } ] }, "vul_type": "cwe-089" }
241
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def also_add(name, also):\n db = db_connect()\n cursor = db.cursor()\n try:\n cursor.execute('''", " INSERT INTO isalso(name,also) VALUES('{}','{}')\n '''.format(name, also))", " db.commit()\n logger.debug('added to isalso name {} with value {}'.format(\n name, also))\n db.close()\n except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 166, "char_start": 158, "chars": "%(name)s" }, { "char_end": 175, "char_start": 167, "chars": "%(also)s" }, { "char_end": 194, "char_start": 192, "chars": ", " }, { "char_end": 208, "char_start": 195, "chars": "\n " }, { "char_end": 225, "char_start": 213, "chars": "\n " }, { "char_end": 240, "char_start": 230, "chars": ",\n " } ], "deleted": [ { "char_end": 162, "char_start": 158, "chars": "'{}'" }, { "char_end": 167, "char_start": 163, "chars": "'{}'" }, { "char_end": 191, "char_start": 184, "chars": ".format" } ] }, "commit_link": "github.com/tylarb/KarmaBoi-PCF/commit/c1d00a27d7f6b7eb6f15a3dacd4269654a32c10a", "file_name": "KarmaBoi/dbopts.py", "func_name": "also_add", "line_changes": { "added": [ { "char_end": 177, "char_start": 109, "line": " INSERT INTO isalso(name,also) VALUES(%(name)s,%(also)s)\n", "line_no": 6 }, { "char_end": 196, "char_start": 177, "line": " ''', (\n", "line_no": 7 }, { "char_end": 214, "char_start": 196, "line": " name,\n", "line_no": 8 }, { "char_end": 232, "char_start": 214, "line": " also,\n", "line_no": 9 }, { "char_end": 243, "char_start": 232, "line": " ))\n", "line_no": 10 } ], "deleted": [ { "char_end": 169, "char_start": 109, "line": " INSERT INTO isalso(name,also) VALUES('{}','{}')\n", "line_no": 6 }, { "char_end": 205, "char_start": 169, "line": " '''.format(name, also))\n", "line_no": 7 } ] }, "vul_type": "cwe-089" }
242
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def also_add(name, also):\n db = db_connect()\n cursor = db.cursor()\n try:\n cursor.execute('''", " INSERT INTO isalso(name,also) VALUES(%(name)s,%(also)s)\n ''', (\n name,\n also,\n ))", " db.commit()\n logger.debug('added to isalso name {} with value {}'.format(\n name, also))\n db.close()\n except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 166, "char_start": 158, "chars": "%(name)s" }, { "char_end": 175, "char_start": 167, "chars": "%(also)s" }, { "char_end": 194, "char_start": 192, "chars": ", " }, { "char_end": 208, "char_start": 195, "chars": "\n " }, { "char_end": 225, "char_start": 213, "chars": "\n " }, { "char_end": 240, "char_start": 230, "chars": ",\n " } ], "deleted": [ { "char_end": 162, "char_start": 158, "chars": "'{}'" }, { "char_end": 167, "char_start": 163, "chars": "'{}'" }, { "char_end": 191, "char_start": 184, "chars": ".format" } ] }, "commit_link": "github.com/tylarb/KarmaBoi-PCF/commit/c1d00a27d7f6b7eb6f15a3dacd4269654a32c10a", "file_name": "KarmaBoi/dbopts.py", "func_name": "also_add", "line_changes": { "added": [ { "char_end": 177, "char_start": 109, "line": " INSERT INTO isalso(name,also) VALUES(%(name)s,%(also)s)\n", "line_no": 6 }, { "char_end": 196, "char_start": 177, "line": " ''', (\n", "line_no": 7 }, { "char_end": 214, "char_start": 196, "line": " name,\n", "line_no": 8 }, { "char_end": 232, "char_start": 214, "line": " also,\n", "line_no": 9 }, { "char_end": 243, "char_start": 232, "line": " ))\n", "line_no": 10 } ], "deleted": [ { "char_end": 169, "char_start": 109, "line": " INSERT INTO isalso(name,also) VALUES('{}','{}')\n", "line_no": 6 }, { "char_end": 205, "char_start": 169, "line": " '''.format(name, also))\n", "line_no": 7 } ] }, "vul_type": "cwe-089" }
242
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def getCommentsLike(self,commentid):", " sqlText=\"select userid from comment_like where commentid=%d\"%(commentid)\n result=sql.queryDB(self.conn,sqlText)", " return result;" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 108, "char_start": 107, "chars": "s" }, { "char_end": 126, "char_start": 109, "chars": "\n params=[" }, { "char_end": 136, "char_start": 135, "chars": "]" }, { "char_end": 188, "char_start": 181, "chars": ",params" } ], "deleted": [ { "char_end": 108, "char_start": 107, "chars": "d" }, { "char_end": 111, "char_start": 109, "chars": "%(" }, { "char_end": 121, "char_start": 120, "chars": ")" } ] }, "commit_link": "github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9", "file_name": "modules/comment.py", "func_name": "getCommentsLike", "line_changes": { "added": [ { "char_end": 110, "char_start": 41, "line": " sqlText=\"select userid from comment_like where commentid=%s\"\n", "line_no": 2 }, { "char_end": 137, "char_start": 110, "line": " params=[commentid]\n", "line_no": 3 }, { "char_end": 190, "char_start": 137, "line": " result=sql.queryDB(self.conn,sqlText,params)\n", "line_no": 4 } ], "deleted": [ { "char_end": 122, "char_start": 41, "line": " sqlText=\"select userid from comment_like where commentid=%d\"%(commentid)\n", "line_no": 2 }, { "char_end": 168, "char_start": 122, "line": " result=sql.queryDB(self.conn,sqlText)\n", "line_no": 3 } ] }, "vul_type": "cwe-089" }
243
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def getCommentsLike(self,commentid):", " sqlText=\"select userid from comment_like where commentid=%s\"\n params=[commentid]\n result=sql.queryDB(self.conn,sqlText,params)", " return result;" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 108, "char_start": 107, "chars": "s" }, { "char_end": 126, "char_start": 109, "chars": "\n params=[" }, { "char_end": 136, "char_start": 135, "chars": "]" }, { "char_end": 188, "char_start": 181, "chars": ",params" } ], "deleted": [ { "char_end": 108, "char_start": 107, "chars": "d" }, { "char_end": 111, "char_start": 109, "chars": "%(" }, { "char_end": 121, "char_start": 120, "chars": ")" } ] }, "commit_link": "github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9", "file_name": "modules/comment.py", "func_name": "getCommentsLike", "line_changes": { "added": [ { "char_end": 110, "char_start": 41, "line": " sqlText=\"select userid from comment_like where commentid=%s\"\n", "line_no": 2 }, { "char_end": 137, "char_start": 110, "line": " params=[commentid]\n", "line_no": 3 }, { "char_end": 190, "char_start": 137, "line": " result=sql.queryDB(self.conn,sqlText,params)\n", "line_no": 4 } ], "deleted": [ { "char_end": 122, "char_start": 41, "line": " sqlText=\"select userid from comment_like where commentid=%d\"%(commentid)\n", "line_no": 2 }, { "char_end": 168, "char_start": 122, "line": " result=sql.queryDB(self.conn,sqlText)\n", "line_no": 3 } ] }, "vul_type": "cwe-089" }
243
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def update_theory_base(tag, link):\n theory = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\theory.db\")\n conn = theory.cursor()", " conn.execute(\"insert into \" + str(tag) + \" values (?)\", (str(link), ))", " theory.commit()\n theory.close()" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 182, "char_start": 181, "chars": "?" }, { "char_end": 202, "char_start": 197, "chars": "tag, " } ], "deleted": [ { "char_end": 197, "char_start": 181, "chars": "\" + str(tag) + \"" }, { "char_end": 223, "char_start": 221, "chars": ", " } ] }, "commit_link": "github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90", "file_name": "bases/update.py", "func_name": "update_theory_base", "line_changes": { "added": [ { "char_end": 214, "char_start": 151, "line": " conn.execute(\"insert into ? values (?)\", (tag, str(link)))\n", "line_no": 4 } ], "deleted": [ { "char_end": 226, "char_start": 151, "line": " conn.execute(\"insert into \" + str(tag) + \" values (?)\", (str(link), ))\n", "line_no": 4 } ] }, "vul_type": "cwe-089" }
244
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def update_theory_base(tag, link):\n theory = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\theory.db\")\n conn = theory.cursor()", " conn.execute(\"insert into ? values (?)\", (tag, str(link)))", " theory.commit()\n theory.close()" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 182, "char_start": 181, "chars": "?" }, { "char_end": 202, "char_start": 197, "chars": "tag, " } ], "deleted": [ { "char_end": 197, "char_start": 181, "chars": "\" + str(tag) + \"" }, { "char_end": 223, "char_start": 221, "chars": ", " } ] }, "commit_link": "github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90", "file_name": "bases/update.py", "func_name": "update_theory_base", "line_changes": { "added": [ { "char_end": 214, "char_start": 151, "line": " conn.execute(\"insert into ? values (?)\", (tag, str(link)))\n", "line_no": 4 } ], "deleted": [ { "char_end": 226, "char_start": 151, "line": " conn.execute(\"insert into \" + str(tag) + \" values (?)\", (str(link), ))\n", "line_no": 4 } ] }, "vul_type": "cwe-089" }
244
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@app.route('/get_asset_and_volume')\ndef get_asset_and_volume():\n asset_id = request.args.get('asset_id')", " if not isObject(asset_id):\n ws.send('{\"id\":1, \"method\":\"call\", \"params\":[0,\"lookup_asset_symbols\",[[\"' + asset_id + '\"], 0]]}')\n result_l = ws.recv()\n j_l = json.loads(result_l)\n asset_id = j_l[\"result\"][0][\"id\"]", " #print asset_id\n ws.send('{\"id\":1, \"method\":\"call\", \"params\":[0,\"get_assets\",[[\"' + asset_id + '\"], 0]]}')\n result = ws.recv()\n j = json.loads(result)", " dynamic_asset_data_id = j[\"result\"][0][\"dynamic_asset_data_id\"]", " ws.send('{\"id\": 1, \"method\": \"call\", \"params\": [0, \"get_objects\", [[\"'+dynamic_asset_data_id+'\"]]]}')\n result2 = ws.recv()\n j2 = json.loads(result2)\n #print j2[\"result\"][0][\"current_supply\"]", " j[\"result\"][0][\"current_supply\"] = j2[\"result\"][0][\"current_supply\"]\n j[\"result\"][0][\"confidential_supply\"] = j2[\"result\"][0][\"confidential_supply\"]\n #print j[\"result\"]", " j[\"result\"][0][\"accumulated_fees\"] = j2[\"result\"][0][\"accumulated_fees\"]\n j[\"result\"][0][\"fee_pool\"] = j2[\"result\"][0][\"fee_pool\"]", " issuer = j[\"result\"][0][\"issuer\"]\n ws.send('{\"id\": 1, \"method\": \"call\", \"params\": [0, \"get_objects\", [[\"'+issuer+'\"]]]}')\n result3 = ws.recv()\n j3 = json.loads(result3)\n j[\"result\"][0][\"issuer_name\"] = j3[\"result\"][0][\"name\"]", "\n con = psycopg2.connect(**config.POSTGRES)\n cur = con.cursor()\n", " query = \"SELECT volume, mcap FROM assets WHERE aid='\"+asset_id+\"'\"\n cur.execute(query)", " results = cur.fetchall()\n con.close()\n try:\n j[\"result\"][0][\"volume\"] = results[0][0]\n j[\"result\"][0][\"mcap\"] = results[0][1]\n except:\n j[\"result\"][0][\"volume\"] = 0\n j[\"result\"][0][\"mcap\"] = 0", " return jsonify(j[\"result\"])" ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 1484, "char_start": 1483, "chars": "%" }, { "char_end": 1521, "char_start": 1508, "chars": ", (asset_id,)" } ], "deleted": [ { "char_end": 1487, "char_start": 1483, "chars": "'\"+a" }, { "char_end": 1497, "char_start": 1488, "chars": "set_id+\"'" } ] }, "commit_link": "github.com/VinChain/vinchain-python-api-backend/commit/b78088a551fbb712121269c6eb7f43ede120ff60", "file_name": "api.py", "func_name": "get_asset_and_volume", "line_changes": { "added": [ { "char_end": 1487, "char_start": 1428, "line": " query = \"SELECT volume, mcap FROM assets WHERE aid=%s\"\n", "line_no": 40 }, { "char_end": 1523, "char_start": 1487, "line": " cur.execute(query, (asset_id,))\n", "line_no": 41 } ], "deleted": [ { "char_end": 1499, "char_start": 1428, "line": " query = \"SELECT volume, mcap FROM assets WHERE aid='\"+asset_id+\"'\"\n", "line_no": 40 }, { "char_end": 1522, "char_start": 1499, "line": " cur.execute(query)\n", "line_no": 41 } ] }, "vul_type": "cwe-089" }
245
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@app.route('/get_asset_and_volume')\ndef get_asset_and_volume():\n asset_id = request.args.get('asset_id')", " if not isObject(asset_id):\n ws.send('{\"id\":1, \"method\":\"call\", \"params\":[0,\"lookup_asset_symbols\",[[\"' + asset_id + '\"], 0]]}')\n result_l = ws.recv()\n j_l = json.loads(result_l)\n asset_id = j_l[\"result\"][0][\"id\"]", " #print asset_id\n ws.send('{\"id\":1, \"method\":\"call\", \"params\":[0,\"get_assets\",[[\"' + asset_id + '\"], 0]]}')\n result = ws.recv()\n j = json.loads(result)", " dynamic_asset_data_id = j[\"result\"][0][\"dynamic_asset_data_id\"]", " ws.send('{\"id\": 1, \"method\": \"call\", \"params\": [0, \"get_objects\", [[\"'+dynamic_asset_data_id+'\"]]]}')\n result2 = ws.recv()\n j2 = json.loads(result2)\n #print j2[\"result\"][0][\"current_supply\"]", " j[\"result\"][0][\"current_supply\"] = j2[\"result\"][0][\"current_supply\"]\n j[\"result\"][0][\"confidential_supply\"] = j2[\"result\"][0][\"confidential_supply\"]\n #print j[\"result\"]", " j[\"result\"][0][\"accumulated_fees\"] = j2[\"result\"][0][\"accumulated_fees\"]\n j[\"result\"][0][\"fee_pool\"] = j2[\"result\"][0][\"fee_pool\"]", " issuer = j[\"result\"][0][\"issuer\"]\n ws.send('{\"id\": 1, \"method\": \"call\", \"params\": [0, \"get_objects\", [[\"'+issuer+'\"]]]}')\n result3 = ws.recv()\n j3 = json.loads(result3)\n j[\"result\"][0][\"issuer_name\"] = j3[\"result\"][0][\"name\"]", "\n con = psycopg2.connect(**config.POSTGRES)\n cur = con.cursor()\n", " query = \"SELECT volume, mcap FROM assets WHERE aid=%s\"\n cur.execute(query, (asset_id,))", " results = cur.fetchall()\n con.close()\n try:\n j[\"result\"][0][\"volume\"] = results[0][0]\n j[\"result\"][0][\"mcap\"] = results[0][1]\n except:\n j[\"result\"][0][\"volume\"] = 0\n j[\"result\"][0][\"mcap\"] = 0", " return jsonify(j[\"result\"])" ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 1484, "char_start": 1483, "chars": "%" }, { "char_end": 1521, "char_start": 1508, "chars": ", (asset_id,)" } ], "deleted": [ { "char_end": 1487, "char_start": 1483, "chars": "'\"+a" }, { "char_end": 1497, "char_start": 1488, "chars": "set_id+\"'" } ] }, "commit_link": "github.com/VinChain/vinchain-python-api-backend/commit/b78088a551fbb712121269c6eb7f43ede120ff60", "file_name": "api.py", "func_name": "get_asset_and_volume", "line_changes": { "added": [ { "char_end": 1487, "char_start": 1428, "line": " query = \"SELECT volume, mcap FROM assets WHERE aid=%s\"\n", "line_no": 40 }, { "char_end": 1523, "char_start": 1487, "line": " cur.execute(query, (asset_id,))\n", "line_no": 41 } ], "deleted": [ { "char_end": 1499, "char_start": 1428, "line": " query = \"SELECT volume, mcap FROM assets WHERE aid='\"+asset_id+\"'\"\n", "line_no": 40 }, { "char_end": 1522, "char_start": 1499, "line": " cur.execute(query)\n", "line_no": 41 } ] }, "vul_type": "cwe-089" }
245
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def reportMatch(winner, loser):\n \"\"\"Records the outcome of a single match between two players.", " Args:\n winner: the id number of the player who won\n loser: the id number of the player who lost\n \"\"\"\n try:\n int(winner)\n int(loser)\n except ValueError:\n raise ValueError(\n \"\\\"winner\\\" and/or \\\"loser\\\" input are not integers.\\n\"\n \"Please use the id number of each player to report match results.\"\n )\n w = str(winner)\n l = str(loser)\n db = connect()\n c = db.cursor()", " statement = \"INSERT INTO matches values ({w}, {l})\".format(w=w, l=l)\n c.execute(statement)", " db.commit()\n db.close()" ]
[ 1, 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 557, "char_start": 555, "chars": "c." }, { "char_end": 559, "char_start": 558, "chars": "x" }, { "char_end": 562, "char_start": 560, "chars": "cu" }, { "char_end": 565, "char_start": 563, "chars": "e(" }, { "char_end": 596, "char_start": 594, "chars": "%s" }, { "char_end": 600, "char_start": 598, "chars": "%s" }, { "char_end": 604, "char_start": 602, "chars": ", " } ], "deleted": [ { "char_end": 559, "char_start": 555, "chars": "stat" }, { "char_end": 561, "char_start": 560, "chars": "m" }, { "char_end": 563, "char_start": 562, "chars": "n" }, { "char_end": 567, "char_start": 564, "chars": " = " }, { "char_end": 599, "char_start": 596, "chars": "{w}" }, { "char_end": 604, "char_start": 601, "chars": "{l}" }, { "char_end": 613, "char_start": 606, "chars": ".format" }, { "char_end": 617, "char_start": 615, "chars": "=w" }, { "char_end": 621, "char_start": 618, "chars": " l=" }, { "char_end": 647, "char_start": 623, "chars": "\n c.execute(statement" } ] }, "commit_link": "github.com/tdnelson2/tournament-db/commit/00f3caeed0e12e806c2808d100908698777d9e98", "file_name": "tournament.py", "func_name": "reportMatch", "line_changes": { "added": [ { "char_end": 611, "char_start": 551, "line": " c.execute(\"INSERT INTO matches values (%s, %s)\", (w,l))\n", "line_no": 20 } ], "deleted": [ { "char_end": 624, "char_start": 551, "line": " statement = \"INSERT INTO matches values ({w}, {l})\".format(w=w, l=l)\n", "line_no": 20 }, { "char_end": 649, "char_start": 624, "line": " c.execute(statement)\n", "line_no": 21 } ] }, "vul_type": "cwe-089" }
246
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def reportMatch(winner, loser):\n \"\"\"Records the outcome of a single match between two players.", " Args:\n winner: the id number of the player who won\n loser: the id number of the player who lost\n \"\"\"\n try:\n int(winner)\n int(loser)\n except ValueError:\n raise ValueError(\n \"\\\"winner\\\" and/or \\\"loser\\\" input are not integers.\\n\"\n \"Please use the id number of each player to report match results.\"\n )\n w = str(winner)\n l = str(loser)\n db = connect()\n c = db.cursor()", " c.execute(\"INSERT INTO matches values (%s, %s)\", (w,l))", " db.commit()\n db.close()" ]
[ 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 557, "char_start": 555, "chars": "c." }, { "char_end": 559, "char_start": 558, "chars": "x" }, { "char_end": 562, "char_start": 560, "chars": "cu" }, { "char_end": 565, "char_start": 563, "chars": "e(" }, { "char_end": 596, "char_start": 594, "chars": "%s" }, { "char_end": 600, "char_start": 598, "chars": "%s" }, { "char_end": 604, "char_start": 602, "chars": ", " } ], "deleted": [ { "char_end": 559, "char_start": 555, "chars": "stat" }, { "char_end": 561, "char_start": 560, "chars": "m" }, { "char_end": 563, "char_start": 562, "chars": "n" }, { "char_end": 567, "char_start": 564, "chars": " = " }, { "char_end": 599, "char_start": 596, "chars": "{w}" }, { "char_end": 604, "char_start": 601, "chars": "{l}" }, { "char_end": 613, "char_start": 606, "chars": ".format" }, { "char_end": 617, "char_start": 615, "chars": "=w" }, { "char_end": 621, "char_start": 618, "chars": " l=" }, { "char_end": 647, "char_start": 623, "chars": "\n c.execute(statement" } ] }, "commit_link": "github.com/tdnelson2/tournament-db/commit/00f3caeed0e12e806c2808d100908698777d9e98", "file_name": "tournament.py", "func_name": "reportMatch", "line_changes": { "added": [ { "char_end": 611, "char_start": 551, "line": " c.execute(\"INSERT INTO matches values (%s, %s)\", (w,l))\n", "line_no": 20 } ], "deleted": [ { "char_end": 624, "char_start": 551, "line": " statement = \"INSERT INTO matches values ({w}, {l})\".format(w=w, l=l)\n", "line_no": 20 }, { "char_end": 649, "char_start": 624, "line": " c.execute(statement)\n", "line_no": 21 } ] }, "vul_type": "cwe-089" }
246
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def getPlayer(player):", "\tdb.execute(\"SELECT * FROM players WHERE Name = '%s' COLLATE NOCASE\" % player)", "\tplayerstats = dict(db.fetchone())\n\treturn playerstats" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 72, "char_start": 71, "chars": "?" }, { "char_end": 89, "char_start": 88, "chars": "," } ], "deleted": [ { "char_end": 75, "char_start": 71, "chars": "'%s'" }, { "char_end": 93, "char_start": 91, "chars": " %" } ] }, "commit_link": "github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2", "file_name": "plugins/database.py", "func_name": "getPlayer", "line_changes": { "added": [ { "char_end": 98, "char_start": 23, "line": "\tdb.execute(\"SELECT * FROM players WHERE Name = ? COLLATE NOCASE\", player)\n", "line_no": 2 } ], "deleted": [ { "char_end": 102, "char_start": 23, "line": "\tdb.execute(\"SELECT * FROM players WHERE Name = '%s' COLLATE NOCASE\" % player)\n", "line_no": 2 } ] }, "vul_type": "cwe-089" }
247
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def getPlayer(player):", "\tdb.execute(\"SELECT * FROM players WHERE Name = ? COLLATE NOCASE\", player)", "\tplayerstats = dict(db.fetchone())\n\treturn playerstats" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 72, "char_start": 71, "chars": "?" }, { "char_end": 89, "char_start": 88, "chars": "," } ], "deleted": [ { "char_end": 75, "char_start": 71, "chars": "'%s'" }, { "char_end": 93, "char_start": 91, "chars": " %" } ] }, "commit_link": "github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2", "file_name": "plugins/database.py", "func_name": "getPlayer", "line_changes": { "added": [ { "char_end": 98, "char_start": 23, "line": "\tdb.execute(\"SELECT * FROM players WHERE Name = ? COLLATE NOCASE\", player)\n", "line_no": 2 } ], "deleted": [ { "char_end": 102, "char_start": 23, "line": "\tdb.execute(\"SELECT * FROM players WHERE Name = '%s' COLLATE NOCASE\" % player)\n", "line_no": 2 } ] }, "vul_type": "cwe-089" }
247
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def karma_sub(name):\n karma = karma_ask(name)\n db = db_connect()\n cursor = db.cursor()\n if karma is None:\n try:\n cursor.execute('''", " INSERT INTO people(name,karma,shame) VALUES('{}',-1,0)\n '''.format(name))", " db.commit()\n logger.debug('Inserted into karmadb -1 karma for {}'.format(name))\n db.close()\n return -1", " except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise\n else:\n karma = karma - 1\n try:\n cursor.execute('''", " UPDATE people SET karma = {0} WHERE name = '{1}'\n '''.format(karma, name))", " db.commit()\n logger.debug('Inserted into karmadb -1 karma for {}'.format(name))\n db.close()\n return karma\n except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise" ]
[ 1, 0, 1, 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 230, "char_start": 222, "chars": "%(name)s" }, { "char_end": 258, "char_start": 256, "chars": ", " }, { "char_end": 265, "char_start": 263, "chars": ", " }, { "char_end": 667, "char_start": 658, "chars": "%(karma)s" }, { "char_end": 689, "char_start": 681, "chars": "%(name)s" }, { "char_end": 711, "char_start": 709, "chars": ", " }, { "char_end": 729, "char_start": 712, "chars": "\n " }, { "char_end": 751, "char_start": 735, "chars": "\n " }, { "char_end": 770, "char_start": 756, "chars": ",\n " } ], "deleted": [ { "char_end": 226, "char_start": 222, "chars": "'{}'" }, { "char_end": 259, "char_start": 252, "chars": ".format" }, { "char_end": 660, "char_start": 657, "chars": "{0}" }, { "char_end": 679, "char_start": 674, "chars": "'{1}'" }, { "char_end": 706, "char_start": 699, "chars": ".format" } ] }, "commit_link": "github.com/tylarb/KarmaBoi-PCF/commit/c1d00a27d7f6b7eb6f15a3dacd4269654a32c10a", "file_name": "KarmaBoi/dbopts.py", "func_name": "karma_sub", "line_changes": { "added": [ { "char_end": 237, "char_start": 162, "line": " INSERT INTO people(name,karma,shame) VALUES(%(name)s,-1,0)\n", "line_no": 8 }, { "char_end": 268, "char_start": 237, "line": " ''', (name, ))\n", "line_no": 9 }, { "char_end": 690, "char_start": 616, "line": " UPDATE people SET karma = %(karma)s WHERE name = %(name)s\n", "line_no": 22 }, { "char_end": 713, "char_start": 690, "line": " ''', (\n", "line_no": 23 }, { "char_end": 736, "char_start": 713, "line": " karma,\n", "line_no": 24 }, { "char_end": 758, "char_start": 736, "line": " name,\n", "line_no": 25 }, { "char_end": 773, "char_start": 758, "line": " ))\n", "line_no": 26 } ], "deleted": [ { "char_end": 233, "char_start": 162, "line": " INSERT INTO people(name,karma,shame) VALUES('{}',-1,0)\n", "line_no": 8 }, { "char_end": 267, "char_start": 233, "line": " '''.format(name))\n", "line_no": 9 }, { "char_end": 680, "char_start": 615, "line": " UPDATE people SET karma = {0} WHERE name = '{1}'\n", "line_no": 22 }, { "char_end": 721, "char_start": 680, "line": " '''.format(karma, name))\n", "line_no": 23 } ] }, "vul_type": "cwe-089" }
248
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "def karma_sub(name):\n karma = karma_ask(name)\n db = db_connect()\n cursor = db.cursor()\n if karma is None:\n try:\n cursor.execute('''", " INSERT INTO people(name,karma,shame) VALUES(%(name)s,-1,0)\n ''', (name, ))", " db.commit()\n logger.debug('Inserted into karmadb -1 karma for {}'.format(name))\n db.close()\n return -1", " except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise\n else:\n karma = karma - 1\n try:\n cursor.execute('''", " UPDATE people SET karma = %(karma)s WHERE name = %(name)s\n ''', (\n karma,\n name,\n ))", " db.commit()\n logger.debug('Inserted into karmadb -1 karma for {}'.format(name))\n db.close()\n return karma\n except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise" ]
[ 1, 1, 1, 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 230, "char_start": 222, "chars": "%(name)s" }, { "char_end": 258, "char_start": 256, "chars": ", " }, { "char_end": 265, "char_start": 263, "chars": ", " }, { "char_end": 667, "char_start": 658, "chars": "%(karma)s" }, { "char_end": 689, "char_start": 681, "chars": "%(name)s" }, { "char_end": 711, "char_start": 709, "chars": ", " }, { "char_end": 729, "char_start": 712, "chars": "\n " }, { "char_end": 751, "char_start": 735, "chars": "\n " }, { "char_end": 770, "char_start": 756, "chars": ",\n " } ], "deleted": [ { "char_end": 226, "char_start": 222, "chars": "'{}'" }, { "char_end": 259, "char_start": 252, "chars": ".format" }, { "char_end": 660, "char_start": 657, "chars": "{0}" }, { "char_end": 679, "char_start": 674, "chars": "'{1}'" }, { "char_end": 706, "char_start": 699, "chars": ".format" } ] }, "commit_link": "github.com/tylarb/KarmaBoi-PCF/commit/c1d00a27d7f6b7eb6f15a3dacd4269654a32c10a", "file_name": "KarmaBoi/dbopts.py", "func_name": "karma_sub", "line_changes": { "added": [ { "char_end": 237, "char_start": 162, "line": " INSERT INTO people(name,karma,shame) VALUES(%(name)s,-1,0)\n", "line_no": 8 }, { "char_end": 268, "char_start": 237, "line": " ''', (name, ))\n", "line_no": 9 }, { "char_end": 690, "char_start": 616, "line": " UPDATE people SET karma = %(karma)s WHERE name = %(name)s\n", "line_no": 22 }, { "char_end": 713, "char_start": 690, "line": " ''', (\n", "line_no": 23 }, { "char_end": 736, "char_start": 713, "line": " karma,\n", "line_no": 24 }, { "char_end": 758, "char_start": 736, "line": " name,\n", "line_no": 25 }, { "char_end": 773, "char_start": 758, "line": " ))\n", "line_no": 26 } ], "deleted": [ { "char_end": 233, "char_start": 162, "line": " INSERT INTO people(name,karma,shame) VALUES('{}',-1,0)\n", "line_no": 8 }, { "char_end": 267, "char_start": 233, "line": " '''.format(name))\n", "line_no": 9 }, { "char_end": 680, "char_start": 615, "line": " UPDATE people SET karma = {0} WHERE name = '{1}'\n", "line_no": 22 }, { "char_end": 721, "char_start": 680, "line": " '''.format(karma, name))\n", "line_no": 23 } ] }, "vul_type": "cwe-089" }
248
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@app.route('/', methods=['POST'])\ndef login():\n print('login')\n user = str(request.form['username'])\n password = str(request.form['password'])", " cur.execute('SELECT * FROM users WHERE name = \\'{}\\' AND password = \\'{}\\';'.format(user, password))", " response = cur.fetchone()\n if response != None:\n print(response, 'OK')\n return redirect(url_for('enter_test_point'))\n else:\n print(response, 'not OK')\n flash('Invalid login or password')\n return render_template('login.html')" ]
[ 1, 0, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 169, "char_start": 168, "chars": "\"" }, { "char_end": 203, "char_start": 202, "chars": "?" }, { "char_end": 220, "char_start": 219, "chars": "?" }, { "char_end": 225, "char_start": 221, "chars": "\", [" }, { "char_end": 240, "char_start": 239, "chars": "]" } ], "deleted": [ { "char_end": 169, "char_start": 168, "chars": "'" }, { "char_end": 208, "char_start": 202, "chars": "\\'{}\\'" }, { "char_end": 230, "char_start": 224, "chars": "\\'{}\\'" }, { "char_end": 240, "char_start": 231, "chars": "'.format(" }, { "char_end": 255, "char_start": 254, "chars": ")" } ] }, "commit_link": "github.com/ChemiKyle/Waterspots/commit/3f9d5099496336f3f34c48abf0cf55acaaa29011", "file_name": "app.py", "func_name": "login", "line_changes": { "added": [ { "char_end": 242, "char_start": 152, "line": " cur.execute(\"SELECT * FROM users WHERE name = ? AND password = ?;\", [user, password])\n", "line_no": 6 } ], "deleted": [ { "char_end": 257, "char_start": 152, "line": " cur.execute('SELECT * FROM users WHERE name = \\'{}\\' AND password = \\'{}\\';'.format(user, password))\n", "line_no": 6 } ] }, "vul_type": "cwe-089" }
249
cwe-089
py
Determine whether the {function_name} code is vulnerable or not.
[ "@app.route('/', methods=['POST'])\ndef login():\n print('login')\n user = str(request.form['username'])\n password = str(request.form['password'])", " cur.execute(\"SELECT * FROM users WHERE name = ? AND password = ?;\", [user, password])", " response = cur.fetchone()\n if response != None:\n print(response, 'OK')\n return redirect(url_for('enter_test_point'))\n else:\n print(response, 'not OK')\n flash('Invalid login or password')\n return render_template('login.html')" ]
[ 1, 1, 1 ]
SVEN
{ "char_changes": { "added": [ { "char_end": 169, "char_start": 168, "chars": "\"" }, { "char_end": 203, "char_start": 202, "chars": "?" }, { "char_end": 220, "char_start": 219, "chars": "?" }, { "char_end": 225, "char_start": 221, "chars": "\", [" }, { "char_end": 240, "char_start": 239, "chars": "]" } ], "deleted": [ { "char_end": 169, "char_start": 168, "chars": "'" }, { "char_end": 208, "char_start": 202, "chars": "\\'{}\\'" }, { "char_end": 230, "char_start": 224, "chars": "\\'{}\\'" }, { "char_end": 240, "char_start": 231, "chars": "'.format(" }, { "char_end": 255, "char_start": 254, "chars": ")" } ] }, "commit_link": "github.com/ChemiKyle/Waterspots/commit/3f9d5099496336f3f34c48abf0cf55acaaa29011", "file_name": "app.py", "func_name": "login", "line_changes": { "added": [ { "char_end": 242, "char_start": 152, "line": " cur.execute(\"SELECT * FROM users WHERE name = ? AND password = ?;\", [user, password])\n", "line_no": 6 } ], "deleted": [ { "char_end": 257, "char_start": 152, "line": " cur.execute('SELECT * FROM users WHERE name = \\'{}\\' AND password = \\'{}\\';'.format(user, password))\n", "line_no": 6 } ] }, "vul_type": "cwe-089" }
249
cwe-089
py