func_name
stringlengths
2
53
func_src_before
stringlengths
63
114k
func_src_after
stringlengths
86
114k
line_changes
dict
char_changes
dict
commit_link
stringlengths
66
117
file_name
stringlengths
5
72
vul_type
stringclasses
9 values
set_language
def set_language(self, lang): """ Update language of user in the User object and in the database :param lang: string with language tag like "en-US" :return: None """ log.debug('Updating info about user %s language ' 'in memory & database...', self) ...
def set_language(self, lang): """ Update language of user in the User object and in the database :param lang: string with language tag like "en-US" :return: None """ log.debug('Updating info about user %s language ' 'in memory & database...', self) ...
{ "deleted": [ { "line_no": 13, "char_start": 383, "char_end": 435, "line": " f\"SET language='{self.language}' \"\n" }, { "line_no": 14, "char_start": 435, "char_end": 487, "line": " f\"WHERE chat_id='{self.chat_id}'\")\n" ...
{ "deleted": [ { "char_start": 415, "char_end": 417, "chars": "'{" }, { "char_start": 418, "char_end": 432, "chars": "elf.language}'" }, { "char_start": 468, "char_end": 470, "chars": "'{" }, { "char_start": 482, "char_end":...
github.com/RandyRomero/photoGPSbot/commit/0e9f57f13e61863b3672f5730e27f149da00786a
photogpsbot/users.py
cwe-089
tid_num_to_tag_nums
def tid_num_to_tag_nums(self, tid_num): ''' Returns list of the associated tag_nums to the given tid_num. ''' q = "SELECT tag FROM tid_tag WHERE tid = '" + str(tid_num) + "'" self.query(q) return [i[0] for i in self.c.fetchall()]
def tid_num_to_tag_nums(self, tid_num): ''' Returns list of the associated tag_nums to the given tid_num. ''' q = "SELECT tag FROM tid_tag WHERE tid = ?" self.query(q, tid_num) return [i[0] for i in self.c.fetchall()]
{ "deleted": [ { "line_no": 4, "char_start": 123, "char_end": 196, "line": " q = \"SELECT tag FROM tid_tag WHERE tid = '\" + str(tid_num) + \"'\"\n" }, { "line_no": 5, "char_start": 196, "char_end": 218, "line": " self.query(q)\n" } ], ...
{ "deleted": [ { "char_start": 172, "char_end": 194, "chars": "'\" + str(tid_num) + \"'" } ], "added": [ { "char_start": 172, "char_end": 173, "chars": "?" }, { "char_start": 195, "char_end": 204, "chars": ", tid_num" } ] }
github.com/pukkapies/urop2019/commit/3ca2e2c291d2d5fe262d20a8e0520bdfb622432b
modules/query_lastfm.py
cwe-089
summary
@app.route('/summary', methods=['GET']) def summary(): if 'username' in session: conn = mysql.connect() cursor = conn.cursor() #select the maximum score from the results table cursor.execute("SELECT courseConcentration FROM results WHERE total = (SELECT MAX(total) FROM (SELECT * FROM results WHERE courseId >...
@app.route('/summary', methods=['GET']) def summary(): if 'username' in session: conn = mysql.connect() cursor = conn.cursor() #select the maximum score from the results table cursor.execute("SELECT courseConcentration FROM results WHERE total = (SELECT MAX(total) FROM (SELECT * FROM results WHERE courseId >...
{ "deleted": [ { "line_no": 9, "char_start": 185, "char_end": 397, "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'] + \"'\...
{ "deleted": [ { "char_start": 364, "char_end": 365, "chars": "'" }, { "char_start": 367, "char_end": 369, "chars": "+ " }, { "char_start": 388, "char_end": 394, "chars": " + \"'\"" } ], "added": [ { "char_start": 364, "...
github.com/CaitlinKennedy/Tech-Track/commit/20ef2d4010f9497b8221524edd0c706e2c6a4147
src/tech_track.py
cwe-089
add_post
def add_post(content): """Add a post to the 'database' with the current timestamp.""" conn = psycopg2.connect("dbname=forum") cursor = conn.cursor() cursor.execute("insert into posts values ('%s')" % content) conn.commit() conn.close()
def add_post(content): """Add a post to the 'database' with the current timestamp.""" conn = psycopg2.connect("dbname=forum") cursor = conn.cursor() one_post = content cursor.execute("insert into posts values (%s)", (one_post,)) conn.commit() conn.close()
{ "deleted": [ { "line_no": 5, "char_start": 155, "char_end": 217, "line": " cursor.execute(\"insert into posts values ('%s')\" % content)\n" } ], "added": [ { "line_no": 5, "char_start": 155, "char_end": 176, "line": " one_post = content\n" }, ...
{ "deleted": [ { "char_start": 199, "char_end": 200, "chars": "'" }, { "char_start": 202, "char_end": 203, "chars": "'" }, { "char_start": 205, "char_end": 207, "chars": " %" }, { "char_start": 208, "char_end": 209, "c...
github.com/paulc1600/DB-API-Forum/commit/069700fb4beec79182fff3c556e9cccce3230d6f
forumdb.py
cwe-089
delete_playlist
def delete_playlist(id, db): db.execute("DELETE FROM playlist where id={id};".format(id=id))
def delete_playlist(id, db): db.execute("DELETE FROM playlist where id=%s;", (id,))
{ "deleted": [ { "line_no": 2, "char_start": 29, "char_end": 96, "line": " db.execute(\"DELETE FROM playlist where id={id};\".format(id=id))\n" } ], "added": [ { "line_no": 2, "char_start": 29, "char_end": 87, "line": " db.execute(\"DELETE FROM pla...
{ "deleted": [ { "char_start": 75, "char_end": 79, "chars": "{id}" }, { "char_start": 81, "char_end": 88, "chars": ".format" }, { "char_start": 91, "char_end": 94, "chars": "=id" } ], "added": [ { "char_start": 75, "char...
github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6
playlist/playlist_repository.py
cwe-089
writeToDb
def writeToDb(self, url): try: self.cursor.execute("INSERT INTO queue (url, visited) VALUES ('{}', '0');".format(url)) self.db.commit() except Exception as e: print(e)
def writeToDb(self, url): try: self.cursor.execute("INSERT INTO queue (url, visited) VALUES (?, '0');", url) self.db.commit() except Exception as e: print(e)
{ "deleted": [ { "line_no": 3, "char_start": 43, "char_end": 143, "line": " self.cursor.execute(\"INSERT INTO queue (url, visited) VALUES ('{}', '0');\".format(url))\n" } ], "added": [ { "line_no": 3, "char_start": 43, "char_end": 133, "line":...
{ "deleted": [ { "char_start": 117, "char_end": 121, "chars": "'{}'" }, { "char_start": 129, "char_end": 137, "chars": ".format(" }, { "char_start": 140, "char_end": 141, "chars": ")" } ], "added": [ { "char_start": 117, ...
github.com/jappe999/WebScraper/commit/46a4e0843aa44d903293637afad53dfcbc37b480
beta/database.py
cwe-089
send_message
@frappe.whitelist(allow_guest=True) def send_message(subject="Website Query", message="", sender="", status="Open"): from frappe.www.contact import send_message as website_send_message lead = customer = None website_send_message(subject, message, sender) customer = frappe.db.sql("""select distinct dl.link_name fr...
@frappe.whitelist(allow_guest=True) def send_message(subject="Website Query", message="", sender="", status="Open"): from frappe.www.contact import send_message as website_send_message lead = customer = None website_send_message(subject, message, sender) customer = frappe.db.sql("""select distinct dl.link_name fr...
{ "deleted": [ { "line_no": 10, "char_start": 424, "char_end": 482, "line": "\t\tand c.email_id='{email_id}'\"\"\".format(email_id=sender))\n" } ], "added": [ { "line_no": 10, "char_start": 424, "char_end": 458, "line": "\t\tand c.email_id = %s\"\"\", se...
{ "deleted": [ { "char_start": 441, "char_end": 453, "chars": "'{email_id}'" }, { "char_start": 456, "char_end": 473, "chars": ".format(email_id=" }, { "char_start": 479, "char_end": 480, "chars": ")" } ], "added": [ { "char_s...
github.com/libracore/erpnext/commit/9acb885e60f77cd4e9ea8c98bdc39c18abcac731
erpnext/templates/utils.py
cwe-089
delete
@jwt_required def delete(self, email): """ Deletes admin with the corresponding email """ return database_utilities.execute_query(f"""delete from admins where email = '{email}'""")
@jwt_required def delete(self, email): """ Deletes admin with the corresponding email """ return database_utilities.execute_query(f"""delete from admins where email = %s""", (email, ))
{ "deleted": [ { "line_no": 4, "char_start": 106, "char_end": 204, "line": " return database_utilities.execute_query(f\"\"\"delete from admins where email = '{email}'\"\"\")\n" } ], "added": [ { "line_no": 4, "char_start": 106, "char_end": 208, "l...
{ "deleted": [ { "char_start": 191, "char_end": 193, "chars": "'{" }, { "char_start": 198, "char_end": 203, "chars": "}'\"\"\"" } ], "added": [ { "char_start": 191, "char_end": 199, "chars": "%s\"\"\", (" }, { "char_start": 20...
github.com/sgosal2/tiger-boards-backend/commit/4670109dd613df2f2fe7e8403ebd149df2b55485
apis/admins.py
cwe-089
delete_playlists_videos
def delete_playlists_videos(playlist_id, db): db.execute("DELETE FROM video where playlist_id={playlist_id};".format( playlist_id=playlist_id))
def delete_playlists_videos(playlist_id, db): db.execute("DELETE FROM video where playlist_id=%s;", (playlist_id,))
{ "deleted": [ { "line_no": 2, "char_start": 46, "char_end": 122, "line": " db.execute(\"DELETE FROM video where playlist_id={playlist_id};\".format(\n" }, { "line_no": 3, "char_start": 122, "char_end": 155, "line": " playlist_id=playlist_id))\n" ...
{ "deleted": [ { "char_start": 98, "char_end": 105, "chars": "{playli" }, { "char_start": 106, "char_end": 111, "chars": "t_id}" }, { "char_start": 113, "char_end": 127, "chars": ".format(\n " }, { "char_start": 128, "ch...
github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6
video/video_repository.py
cwe-089
upsert_mapped_projects
@staticmethod def upsert_mapped_projects(user_id: int, project_id: int): """ 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) result = db.engine.execute(sql) if result...
@staticmethod def upsert_mapped_projects(user_id: int, project_id: int): """ Adds projects to mapped_projects if it doesn't exist """ sql = "select * from users where id = :user_id and projects_mapped @> '{{:project_id}}'" result = db.engine.execute(text(sql), user_id=user_id, project_id...
{ "deleted": [ { "line_no": 4, "char_start": 150, "char_end": 262, "line": " sql = \"select * from users where id = {0} and projects_mapped @> '{{{1}}}'\".format(user_id, project_id)\n" }, { "line_no": 5, "char_start": 262, "char_end": 302, "line": " ...
{ "deleted": [ { "char_start": 196, "char_end": 199, "chars": "{0}" }, { "char_start": 226, "char_end": 250, "chars": "{1}}}'\".format(user_id, " }, { "char_start": 260, "char_end": 261, "chars": ")" }, { "char_start": 510, ...
github.com/hotosm/tasking-manager/commit/dee040a2d22b3c4d5e38e2dbf8c6b651ad4c241a
server/models/postgis/user.py
cwe-089
get_first_ranked_month
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) res = db.exec(sql) date = res[0][0] return date
def get_first_ranked_month(db, scene, player): sql = "select date from ranks where scene='{scene}' and player='{player}' order by date limit 1;" args = {'scene': scene, 'player': player} res = db.exec(sql, args) date = res[0][0] return date
{ "deleted": [ { "line_no": 2, "char_start": 47, "char_end": 160, "line": " sql = \"select date from ranks where scene='{}' and player='{}' order by date limit 1;\".format(scene, player)\n" }, { "line_no": 3, "char_start": 160, "char_end": 183, "line": " ...
{ "deleted": [ { "char_start": 137, "char_end": 140, "chars": ".fo" }, { "char_start": 141, "char_end": 145, "chars": "mat(" }, { "char_start": 158, "char_end": 159, "chars": ")" } ], "added": [ { "char_start": 95, "char...
github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63
bracket_utils.py
cwe-089
openPoll
@hook.command(adminonly=True) def openPoll(question, reply=None, db=None): """Creates a new poll.""" if not db_ready: db_init(db) try: active = db.execute("SELECT pollID FROM polls WHERE active = 1").fetchone()[0] if active: reply("There already is an open poll.") re...
@hook.command(adminonly=True) def openPoll(question, reply=None, db=None): """Creates a new poll.""" if not db_ready: db_init(db) try: active = db.execute("SELECT pollID FROM polls WHERE active = 1").fetchone()[0] if active: reply("There already is an open poll.") re...
{ "deleted": [ { "line_no": 11, "char_start": 337, "char_end": 430, "line": " db.execute(\"INSERT INTO polls (question, active) VALUES ('{}', 1)\".format(question))\n" } ], "added": [ { "line_no": 11, "char_start": 337, "char_end": 423, "line": " ...
{ "deleted": [ { "char_start": 402, "char_end": 406, "chars": "'{}'" }, { "char_start": 411, "char_end": 418, "chars": ".format" } ], "added": [ { "char_start": 402, "char_end": 403, "chars": "?" }, { "char_start": 408, ...
github.com/FrozenPigs/Taigabot/commit/ea9b83a66ae1f0f38a1895f3e8dfa2833d77e3a6
plugins/poll.py
cwe-089
__init__.view_grocery_list
def view_grocery_list(): print("grocery== list") groceryListFrame = Frame(self) groceryListFrame.rowconfigure(0, weight=1) groceryListFrame.columnconfigure(0, weight=1) groceryListFrame.rowconfigure(1, weight=3) groceryListFrame.columnconfi...
def view_grocery_list(): print("grocery== list") groceryListFrame = Frame(self) groceryListFrame.rowconfigure(0, weight=1) groceryListFrame.columnconfigure(0, weight=1) groceryListFrame.rowconfigure(1, weight=3) groceryListFrame.columnconfi...
{ "deleted": [ { "line_no": 20, "char_start": 745, "char_end": 822, "line": " selection = cursor.execute(\"\"\"SELECT * FROM \"\"\" + tableName)\n" } ], "added": [ { "line_no": 20, "char_start": 745, "char_end": 827, "line": " ...
{ "deleted": [ { "char_start": 809, "char_end": 811, "chars": "+ " } ], "added": [ { "char_start": 805, "char_end": 807, "chars": "?;" }, { "char_start": 810, "char_end": 811, "chars": "," }, { "char_start": 812, "char_e...
github.com/trishamoyer/RecipePlanner-Python/commit/44d2ce370715d9344fad34b3b749322ab095a925
mealPlan.py
cwe-089
view_page_record
@app.route('/<page_name>/history/record') def view_page_record(page_name): 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.name...
@app.route('/<page_name>/history/record') def view_page_record(page_name): 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.namedre...
{ "deleted": [ { "line_no": 4, "char_start": 115, "char_end": 292, "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" } ], "added": [ { ...
{ "deleted": [ { "char_start": 272, "char_end": 276, "chars": "'%s'" }, { "char_start": 277, "char_end": 279, "chars": " %" } ], "added": [ { "char_start": 272, "char_end": 274, "chars": "$1" }, { "char_start": 275, "cha...
github.com/Pumala/python_wiki_app_redo/commit/65d60747cd8efb05970304234d3bd949d2088e8b
server.py
cwe-089
update_inverter
def update_inverter(self, inverter_serial, ts, status, etoday, etotal): query = ''' UPDATE Inverters SET TimeStamp='%s', Status='%s', eToday='%s', eTotal='%s' WHERE Serial='%s'; ''' % (ts, stat...
def update_inverter(self, inverter_serial, ts, status, etoday, etotal): query = ''' UPDATE Inverters SET TimeStamp=?, Status=?, eToday=?, eTotal=? WHERE Serial=?; ''' self.c.execute(que...
{ "deleted": [ { "line_no": 5, "char_start": 146, "char_end": 179, "line": " TimeStamp='%s', \n" }, { "line_no": 6, "char_start": 179, "char_end": 209, "line": " Status='%s', \n" }, { "line_no": 7, "char_star...
{ "deleted": [ { "char_start": 172, "char_end": 176, "chars": "'%s'" }, { "char_start": 202, "char_end": 206, "chars": "'%s'" }, { "char_start": 232, "char_end": 236, "chars": "'%s'" }, { "char_start": 261, "char_end": 265, ...
github.com/philipptrenz/s0-bridge/commit/269b48caa05377b7c58c3e6d1622a4429cb5ba65
util/database.py
cwe-089
insert
def insert(key, value): connection = psycopg2.connect(host=config['HOST'], port=config['PORT'], database=config['NAME'], user=config['USER'], password=config['PASSWORD']) cur = connection.cursor() try: cur.execute("insert into reply_map values('{}', '{}')".format(key, value)) connection.comm...
def insert(key, value): connection = psycopg2.connect(host=config['HOST'], port=config['PORT'], database=config['NAME'], user=config['USER'], password=config['PASSWORD']) cur = connection.cursor() try: cur.execute("insert into reply_map values(?, ?)", (key, value)) connection.commit() ex...
{ "deleted": [ { "line_no": 5, "char_start": 214, "char_end": 297, "line": " cur.execute(\"insert into reply_map values('{}', '{}')\".format(key, value))\n" } ], "added": [ { "line_no": 5, "char_start": 214, "char_end": 286, "line": " cur.e...
{ "deleted": [ { "char_start": 264, "char_end": 268, "chars": "'{}'" }, { "char_start": 270, "char_end": 274, "chars": "'{}'" }, { "char_start": 276, "char_end": 283, "chars": ".format" } ], "added": [ { "char_start": 264, ...
github.com/tadaren/reply_bot/commit/5aeafa7e9597a766992af9ff8189e1f050b6579b
db.py
cwe-089
save_failure_transaction
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()
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()
{ "deleted": [ { "line_no": 2, "char_start": 68, "char_end": 239, "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" } ], "added": [ { "li...
{ "deleted": [ { "char_start": 206, "char_end": 208, "chars": " %" } ], "added": [ { "char_start": 184, "char_end": 215, "chars": "\"\n \"" }, { "char_start": 237, "char_end": 238, "chars": "," } ] }
github.com/JLucka/kickstarter-dev/commit/e2ffa062697e060fdfbd2eccbb89a8c53a569e0b
backend/transactions/TransactionConnector.py
cwe-089
test_process_as_form
@unpack def test_process_as_form(self, job_number, dcn_key, was_prev_matched, was_prev_closed, was_prev_tracked): email_obj = { 'sender' : "Alex Roy <Alex.Roy@dilfo.com>", 'subject' : "DO NOT MODIFY MESSAGE BELOW - JUST HIT `SEND`", 'date' : "Tue, 7 May 20...
@unpack def test_process_as_form(self, job_number, dcn_key, was_prev_matched, was_prev_closed, was_prev_tracked): email_obj = { 'sender' : "Alex Roy <Alex.Roy@dilfo.com>", 'subject' : "DO NOT MODIFY MESSAGE BELOW - JUST HIT `SEND`", 'date' : "Tue, 7 May 20...
{ "deleted": [ { "line_no": 18, "char_start": 823, "char_end": 876, "line": " VALUES ({}, 'alex.roy616@gmail.com', {})\n" }, { "line_no": 22, "char_start": 992, "char_end": 1045, "line": " VALUES ({}, 'alex.roy616@gmail.com', {})\n" ...
{ "deleted": [ { "char_start": 843, "char_end": 845, "chars": "{}" }, { "char_start": 872, "char_end": 874, "chars": "{}" }, { "char_start": 1012, "char_end": 1014, "chars": "{}" }, { "char_start": 1041, "char_end": 1043, ...
github.com/confirmationbias616/certificate_checker/commit/9e890b9613b627e3a5995d0e4a594c8e0831e2ce
tests.py
cwe-089
render_page_name
@app.route('/<page_name>') def 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 = quer...
@app.route('/<page_name>') def 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.n...
{ "deleted": [ { "line_no": 3, "char_start": 60, "char_end": 300, "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 d...
{ "deleted": [ { "char_start": 243, "char_end": 247, "chars": "'%s'" }, { "char_start": 286, "char_end": 288, "chars": " %" } ], "added": [ { "char_start": 243, "char_end": 245, "chars": "$1" }, { "char_start": 284, "cha...
github.com/Pumala/python_wiki_app_redo/commit/65d60747cd8efb05970304234d3bd949d2088e8b
server.py
cwe-089
tid_to_tid_num
def tid_to_tid_num(self, tid): ''' Returns tid_num, given tid. ''' q = "SELECT rowid FROM tids WHERE tid = '" + tid + "'" self.query(q) return self.c.fetchone()[0]
def tid_to_tid_num(self, tid): ''' Returns tid_num, given tid. ''' q = "SELECT rowid FROM tids WHERE tid = ?" self.query(q, tid) return self.c.fetchone()[0]
{ "deleted": [ { "line_no": 4, "char_start": 80, "char_end": 143, "line": " q = \"SELECT rowid FROM tids WHERE tid = '\" + tid + \"'\"\n" }, { "line_no": 5, "char_start": 143, "char_end": 165, "line": " self.query(q)\n" } ], "added": [ ...
{ "deleted": [ { "char_start": 128, "char_end": 141, "chars": "'\" + tid + \"'" } ], "added": [ { "char_start": 128, "char_end": 129, "chars": "?" }, { "char_start": 151, "char_end": 156, "chars": ", tid" } ] }
github.com/pukkapies/urop2019/commit/3ca2e2c291d2d5fe262d20a8e0520bdfb622432b
modules/query_lastfm.py
cwe-089
get_old_sourcebyinstitution_number
def get_old_sourcebyinstitution_number(conn, sqlite, sourcebyinstitution): """ Get all the old sourcebyinstitution number from the SQLite database. """ query = """ SELECT titles FROM history WHERE sourcebyinstitution = "%s" ORDER BY ...
def get_old_sourcebyinstitution_number(conn, sqlite, sourcebyinstitution): """ Get all the old sourcebyinstitution number from the SQLite database. """ query = """ SELECT titles FROM history WHERE sourcebyinstitution = ? ORDER BY ...
{ "deleted": [ { "line_no": 11, "char_start": 261, "char_end": 300, "line": " sourcebyinstitution = \"%s\"\n" }, { "line_no": 15, "char_start": 357, "char_end": 387, "line": " \"\"\" % sourcebyinstitution\n" }, { "line_no": 17, ...
{ "deleted": [ { "char_start": 295, "char_end": 299, "chars": "\"%s\"" }, { "char_start": 364, "char_end": 386, "chars": " % sourcebyinstitution" } ], "added": [ { "char_start": 295, "char_end": 296, "chars": "?" }, { "char_st...
github.com/miku/siskin/commit/7fa398d2fea72bf2e8b4808f75df4b3d35ae959a
bin/solrcheckup.py
cwe-089
top_karma
def top_karma(bot, trigger): """ Show karma status for the top n number of IRC users. """ try: top_limit = int(trigger.group(2).strip()) except ValueError: top_limit = 5 query = "SELECT slug, value FROM nick_values NATURAL JOIN nicknames \ WHERE key = 'karma' ORDER BY va...
def top_karma(bot, trigger): """ Show karma status for the top n number of IRC users. """ try: top_limit = int(trigger.group(2).strip()) except ValueError: top_limit = 5 query = "SELECT slug, value FROM nick_values NATURAL JOIN nicknames \ WHERE key = 'karma' ORDER BY va...
{ "deleted": [ { "line_no": 11, "char_start": 281, "char_end": 339, "line": " WHERE key = 'karma' ORDER BY value DESC LIMIT %d\"\n" }, { "line_no": 12, "char_start": 339, "char_end": 400, "line": " karmalist = bot.db.execute(query % top_limit).fetc...
{ "deleted": [ { "char_start": 335, "char_end": 337, "chars": "%d" }, { "char_start": 376, "char_end": 378, "chars": "% " } ], "added": [ { "char_start": 335, "char_end": 336, "chars": "?" }, { "char_start": 374, "char_e...
github.com/OpCode1300/sopel-karma/commit/e4d49f7b3d88f8874c7862392f3f4c2065a25695
sopel_modules/karma/karma.py
cwe-089
retrieve_playlist_by_id
def retrieve_playlist_by_id(id, db): db.execute( "SELECT id, name, video_position from playlist WHERE id={id};".format(id=id)) row = db.fetchone() return row
def retrieve_playlist_by_id(id, db): db.execute( "SELECT id, name, video_position from playlist WHERE id=%s;", (id,)) row = db.fetchone() return row
{ "deleted": [ { "line_no": 3, "char_start": 53, "char_end": 139, "line": " \"SELECT id, name, video_position from playlist WHERE id={id};\".format(id=id))\n" } ], "added": [ { "line_no": 3, "char_start": 53, "char_end": 130, "line": " \"SE...
{ "deleted": [ { "char_start": 117, "char_end": 121, "chars": "{id}" }, { "char_start": 123, "char_end": 130, "chars": ".format" }, { "char_start": 133, "char_end": 136, "chars": "=id" } ], "added": [ { "char_start": 117, ...
github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6
playlist/playlist_repository.py
cwe-089
get_task
@bot.message_handler(func = lambda message: get_current_state(message.chat.id) == config.States.S_GET_TASK.value) def get_task(message): settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + "\\bases\\settings.db") conn = settings.cursor() conn.execute("select * from users where chat_id = ...
@bot.message_handler(func = lambda message: get_current_state(message.chat.id) == config.States.S_GET_TASK.value) def get_task(message): settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + "\\bases\\settings.db") conn = settings.cursor() conn.execute("select * from users where chat_id = ...
{ "deleted": [ { "line_no": 5, "char_start": 266, "char_end": 353, "line": " conn.execute(\"select * from users where chat_id = '\" + str(message.chat.id) + \"'\")\n" } ], "added": [ { "line_no": 5, "char_start": 266, "char_end": 349, "line": " con...
{ "deleted": [ { "char_start": 320, "char_end": 321, "chars": "'" }, { "char_start": 322, "char_end": 324, "chars": " +" }, { "char_start": 345, "char_end": 351, "chars": " + \"'\"" } ], "added": [ { "char_start": 320, "...
github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90
bot.py
cwe-089
stats
@bot.message_handler(commands=['stats']) def stats(message): settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + "\\bases\\settings.db") conn = settings.cursor() conn.execute("select * from users where chat_id = '" + str(message.chat.id) + "'") name = conn.fetchone() settings.clo...
@bot.message_handler(commands=['stats']) def stats(message): settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + "\\bases\\settings.db") conn = settings.cursor() conn.execute("select * from users where chat_id = ?", (str(message.chat.id),)) name = conn.fetchone() settings.close()...
{ "deleted": [ { "line_no": 5, "char_start": 190, "char_end": 277, "line": " conn.execute(\"select * from users where chat_id = '\" + str(message.chat.id) + \"'\")\n" } ], "added": [ { "line_no": 5, "char_start": 190, "char_end": 273, "line": " con...
{ "deleted": [ { "char_start": 244, "char_end": 245, "chars": "'" }, { "char_start": 246, "char_end": 248, "chars": " +" }, { "char_start": 269, "char_end": 275, "chars": " + \"'\"" } ], "added": [ { "char_start": 244, "...
github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90
bot.py
cwe-089
delete
@jwt_required def delete(self, user_id): """ Deletes user with the corresponding user_id """ return database_utilities.execute_query(f"""delete from users where user_id = '{user_id}'""")
@jwt_required def delete(self, user_id): """ Deletes user with the corresponding user_id """ return database_utilities.execute_query(f"""delete from users where user_id = %s""", (user_id, ))
{ "deleted": [ { "line_no": 4, "char_start": 109, "char_end": 210, "line": " return database_utilities.execute_query(f\"\"\"delete from users where user_id = '{user_id}'\"\"\")\n" } ], "added": [ { "line_no": 4, "char_start": 109, "char_end": 214, ...
{ "deleted": [ { "char_start": 195, "char_end": 197, "chars": "'{" }, { "char_start": 204, "char_end": 209, "chars": "}'\"\"\"" } ], "added": [ { "char_start": 195, "char_end": 203, "chars": "%s\"\"\", (" }, { "char_start": 21...
github.com/sgosal2/tiger-boards-backend/commit/4670109dd613df2f2fe7e8403ebd149df2b55485
apis/users.py
cwe-089
verify_rno
def verify_rno(self, rno): query = "SELECT COUNT(rno) FROM rides WHERE rno = {rno}".format(rno = rno) self.cursor.execute(query) result = self.cursor.fetchone() if (int(result[0]) > 0): return True else: return False
def verify_rno(self, rno): self.cursor.execute("SELECT COUNT(rno) FROM rides WHERE rno = :rno", {'rno': rno}) result = self.cursor.fetchone() if (int(result[0]) > 0): return True else: return False
{ "deleted": [ { "line_no": 2, "char_start": 31, "char_end": 114, "line": " query = \"SELECT COUNT(rno) FROM rides WHERE rno = {rno}\".format(rno = rno)\n" }, { "line_no": 3, "char_start": 114, "char_end": 149, "line": " self.cursor.execute(que...
{ "deleted": [ { "char_start": 39, "char_end": 41, "chars": "qu" }, { "char_start": 43, "char_end": 47, "chars": "y = " }, { "char_start": 89, "char_end": 90, "chars": "{" }, { "char_start": 93, "char_end": 94, "chars"...
github.com/kenboo98/291-Mini-Project-I/commit/3080ccb687c79c83954ce703faee8fcceec8c9eb
book_rides/book_rides.py
cwe-089
get_requested_day
def get_requested_day(self, date): data = dict() day_start, day_end = self.get_epoch_day(date) 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 = ''' SELECT...
def get_requested_day(self, date): data = dict() day_start, day_end = self.get_epoch_day(date) 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 = ''' SELECT...
{ "deleted": [ { "line_no": 11, "char_start": 379, "char_end": 426, "line": " WHERE TimeStamp BETWEEN %s AND %s \n" }, { "line_no": 16, "char_start": 501, "char_end": 566, "line": " for row in self.c.execute(query % (day_start, day_end)):\n...
{ "deleted": [ { "char_start": 415, "char_end": 417, "chars": "%s" }, { "char_start": 422, "char_end": 425, "chars": "%s " }, { "char_start": 540, "char_end": 542, "chars": " %" }, { "char_start": 985, "char_end": 987, ...
github.com/philipptrenz/sunportal/commit/7eef493a168ed4e6731ff800713bfb8aee99a506
util/database.py
cwe-089
add_language
def add_language(lang): try: cur.execute(f"INSERT INTO language (name) VALUES ('{lang}')") except Exception as e: pass cur.execute(f"SELECT language_id FROM language where name='{lang}'") lang_id = cur.fetchone()[0] if conn.commit(): return lang_id return lang_id
def add_language(lang): try: cur.execute("INSERT INTO language (name) VALUES (%s)", (lang, )) except Exception as e: pass cur.execute("SELECT language_id FROM language where name=%s", (lang, )) lang_id = cur.fetchone()[0] if conn.commit(): return lang_id return lang_id
{ "deleted": [ { "line_no": 3, "char_start": 33, "char_end": 103, "line": " cur.execute(f\"INSERT INTO language (name) VALUES ('{lang}')\")\n" }, { "line_no": 6, "char_start": 143, "char_end": 216, "line": " cur.execute(f\"SELECT language_id FROM l...
{ "deleted": [ { "char_start": 53, "char_end": 54, "chars": "f" }, { "char_start": 91, "char_end": 93, "chars": "'{" }, { "char_start": 97, "char_end": 99, "chars": "}'" }, { "char_start": 100, "char_end": 101, "chars"...
github.com/Elbertbiggs360/dvdrental/commit/ad144ae2a08a332498d0831bc255170d57ba754b
app.py
cwe-089
makeJudge
def makeJudge(judge): db.execute("UPDATE players SET Judge = 1 WHERE Name = '%s' COLLATE NOCASE" % (judge)) database.commit()
def makeJudge(judge): db.execute("UPDATE players SET Judge = 1 WHERE Name = ? COLLATE NOCASE", judge) database.commit()
{ "deleted": [ { "line_no": 2, "char_start": 22, "char_end": 110, "line": "\tdb.execute(\"UPDATE players SET Judge = 1 WHERE Name = '%s' COLLATE NOCASE\" % (judge)) \n" } ], "added": [ { "line_no": 2, "char_start": 22, "char_end": 104, "line": "\tdb.exec...
{ "deleted": [ { "char_start": 77, "char_end": 81, "chars": "'%s'" }, { "char_start": 97, "char_end": 99, "chars": " %" }, { "char_start": 100, "char_end": 101, "chars": "(" }, { "char_start": 106, "char_end": 107, "ch...
github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2
plugins/database.py
cwe-089
isValidAdmToken
def isValidAdmToken(adm_token): conn, c = connectDB() req = "SELECT * from {} where adm_token='{}'".format(CFG("admintoken_table_name"), adm_token) answer = bool(queryOne(c, req)) closeDB(conn) return answer
def isValidAdmToken(adm_token): conn, c = connectDB() req = "SELECT * from {} where adm_token=?".format(CFG("admintoken_table_name")) answer = bool(queryOne(c, req, (adm_token,))) closeDB(conn) return answer
{ "deleted": [ { "line_no": 3, "char_start": 58, "char_end": 157, "line": " req = \"SELECT * from {} where adm_token='{}'\".format(CFG(\"admintoken_table_name\"), adm_token)\n" }, { "line_no": 4, "char_start": 157, "char_end": 193, "line": " answer = ...
{ "deleted": [ { "char_start": 103, "char_end": 107, "chars": "'{}'" }, { "char_start": 144, "char_end": 155, "chars": ", adm_token" } ], "added": [ { "char_start": 103, "char_end": 104, "chars": "?" }, { "char_start": 176, ...
github.com/FAUSheppy/simple-python-poll/commit/186c5ff5cdf58272e253a1bb432419ee50d93109
database.py
cwe-089
get_mapped_projects
@staticmethod def get_mapped_projects(user_id: int, preferred_locale: str) -> UserMappedProjectsDTO: """ 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 # counts of all mapped tasks and the ...
@staticmethod def get_mapped_projects(user_id: int, preferred_locale: str) -> UserMappedProjectsDTO: """ 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 # counts of all mapped tasks and the ...
{ "deleted": [ { "line_no": 21, "char_start": 1137, "char_end": 1251, "line": " WHERE t.project_id IN (SELECT unnest(projects_mapped) FROM users WHERE id = {0})\n" }, { "line_no": 22, "char_start": 1251, "char_end": 1311, "lin...
{ "deleted": [ { "char_start": 1246, "char_end": 1249, "chars": "{0}" }, { "char_start": 1307, "char_end": 1310, "chars": "{0}" }, { "char_start": 1672, "char_end": 1675, "chars": "{0}" }, { "char_start": 1723, "char_end": 1...
github.com/hotosm/tasking-manager/commit/dee040a2d22b3c4d5e38e2dbf8c6b651ad4c241a
server/models/postgis/user.py
cwe-089
delete_data
def delete_data(self, session, id): self._openContainer(session) sid = str(id) if (self.idNormalizer is not None): sid = self.idNormalizer.process_string(session, str(id)) query = "DELETE FROM %s WHERE identifier = '%s';" % (self.table, sid) self._query(query) ...
def delete_data(self, session, id): self._openContainer(session) sid = str(id) if (self.idNormalizer is not None): sid = self.idNormalizer.process_string(session, str(id)) query = "DELETE FROM %s WHERE identifier = $1;" % (self.table) self._query(query, sid) ...
{ "deleted": [ { "line_no": 6, "char_start": 212, "char_end": 290, "line": " query = \"DELETE FROM %s WHERE identifier = '%s';\" % (self.table, sid)\n" }, { "line_no": 7, "char_start": 290, "char_end": 317, "line": " self._query(query)\n" }...
{ "deleted": [ { "char_start": 263, "char_end": 267, "chars": "'%s'" }, { "char_start": 283, "char_end": 288, "chars": ", sid" } ], "added": [ { "char_start": 263, "char_end": 265, "chars": "$1" }, { "char_start": 308, "...
github.com/cheshire3/cheshire3/commit/d350363b4ea10f102c24c8f26d7b76b006323e8e
cheshire3/sql/postgresStore.py
cwe-089
user_verify
def user_verify(self): eid = self.email code = self.password if eid.strip() == '': return if code.strip() == '': return query = '''select * from usr where email like\''''+eid+'\'' cursor = g.conn.execute(query) for row in cursor: ...
def user_verify(self): eid = self.email code = self.password if eid.strip() == '': return if code.strip() == '': return query = 'select * from usr where email like %s' cursor = g.conn.execute(query, (eid, )) for row in cursor: ...
{ "deleted": [ { "line_no": 8, "char_start": 180, "char_end": 248, "line": " query = '''select * from usr where email like\\''''+eid+'\\''\n" }, { "line_no": 9, "char_start": 248, "char_end": 287, "line": " cursor = g.conn.execute(query)\n" ...
{ "deleted": [ { "char_start": 197, "char_end": 199, "chars": "''" }, { "char_start": 233, "char_end": 246, "chars": "\\''''+eid+'\\'" } ], "added": [ { "char_start": 231, "char_end": 234, "chars": " %s" }, { "char_start": 273...
github.com/Daniel-Bu/w4111-project1/commit/fe04bedc72e62fd4c4ee046a9af29fd81e9b3340
Web-app/User.py
cwe-089
search_films
@app.route('/movies/search', methods=['GET', 'POST']) def search_films(): form = SearchForm() if not form.validate_on_submit(): return render_template('search.html', title='Search for films', form=form) search_terms = form.data['term'].split(' ') search_string = ' & '.join(search_terms) cur....
@app.route('/movies/search', methods=['GET', 'POST']) def search_films(): form = SearchForm() if not form.validate_on_submit(): return render_template('search.html', title='Search for films', form=form) search_terms = form.data['term'].split(' ') search_string = ' & '.join(search_terms) cur....
{ "deleted": [ { "line_no": 8, "char_start": 312, "char_end": 399, "line": " cur.execute(f\"SELECT * FROM film where fulltext @@ to_tsquery('{search_string}')\")\n" } ], "added": [ { "line_no": 8, "char_start": 312, "char_end": 402, "line": " cur.e...
{ "deleted": [ { "char_start": 328, "char_end": 329, "chars": "f" }, { "char_start": 378, "char_end": 380, "chars": "'{" }, { "char_start": 393, "char_end": 395, "chars": "}'" }, { "char_start": 396, "char_end": 397, "...
github.com/Elbertbiggs360/dvdrental/commit/ad144ae2a08a332498d0831bc255170d57ba754b
app.py
cwe-089
getGameCountInSeriesSoFar
def getGameCountInSeriesSoFar(submission): database = sqlite3.connect('database.db') cursor = database.cursor() return cursor.execute("SELECT COUNT(*) FROM ChallengeRankings WHERE SeriesTitle = '" + getTitle(submission) + "' AND Date <= '" + getSubmissionDateFromDatabase(submission) + "'").fetchone()[0] ...
def getGameCountInSeriesSoFar(submission): database = sqlite3.connect('database.db') cursor = database.cursor() return cursor.execute("SELECT COUNT(*) FROM ChallengeRankings WHERE SeriesTitle = ? AND Date <= ?", [getTitle(submission), getSubmissionDateFromDatabase(submission)]).fetchone()[0] database.cl...
{ "deleted": [ { "line_no": 4, "char_start": 120, "char_end": 317, "line": " return cursor.execute(\"SELECT COUNT(*) FROM ChallengeRankings WHERE SeriesTitle = '\" + getTitle(submission) + \"' AND Date <= '\" + getSubmissionDateFromDatabase(submission) + \"'\").fetchone()[0]\n" } ...
{ "deleted": [ { "char_start": 206, "char_end": 208, "chars": "'\"" }, { "char_start": 209, "char_end": 210, "chars": "+" }, { "char_start": 231, "char_end": 253, "chars": " + \"' AND Date <= '\" +" }, { "char_start": 295, "...
github.com/LiquidFun/Reddit-GeoGuessr-Tracking-Bot/commit/0cad2d52e24b05da32789fbc8face7a9999a71f9
CheckAndPostForSeriesSubmissions.py
cwe-089
add
@mod.route('/add', methods=['GET', 'POST']) def add(): if request.method == 'POST': msg_id = int(request.form['msg_id']) user_id = session['logged_id'] content = request.form['content'] c_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') sql = "INSERT INTO comment(msg_id,us...
@mod.route('/add', methods=['GET', 'POST']) def add(): if request.method == 'POST': msg_id = int(request.form['msg_id']) user_id = session['logged_id'] content = request.form['content'] c_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') cursor.execute("INSERT INTO comment(...
{ "deleted": [ { "line_no": 8, "char_start": 276, "char_end": 348, "line": " sql = \"INSERT INTO comment(msg_id,user_id,content,c_time) \" + \\\n" }, { "line_no": 9, "char_start": 348, "char_end": 428, "line": " \"VALUES(%d,%d,'%s','%s'...
{ "deleted": [ { "char_start": 285, "char_end": 290, "chars": "ql = " }, { "char_start": 342, "char_end": 365, "chars": "\" + \\\n \"" }, { "char_start": 373, "char_end": 374, "chars": "d" }, { "char_start": 376, ...
github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9
flaskr/flaskr/views/comment.py
cwe-089
get_mod_taken_together_with
def get_mod_taken_together_with(code): ''' Retrieves the list of modules taken together with the specified module code in the same semester. Returns a table of lists (up to 10 top results). Each list contains (specified code, module code of mod taken together, aySem, number of stude...
def get_mod_taken_together_with(code): ''' Retrieves the list of modules taken together with the specified module code in the same semester. Returns a table of lists (up to 10 top results). Each list contains (specified code, module code of mod taken together, aySem, number of stude...
{ "deleted": [ { "line_no": 16, "char_start": 665, "char_end": 730, "line": " \"WHERE sp1.moduleCode = '\" + code + \"' AND \" + \\\n" }, { "line_no": 23, "char_start": 1035, "char_end": 1070, "line": " DB_CURSOR.execute(sql_command)\n" ...
{ "deleted": [ { "char_start": 705, "char_end": 719, "chars": "'\" + code + \"'" } ], "added": [ { "char_start": 705, "char_end": 707, "chars": "%s" }, { "char_start": 1056, "char_end": 1065, "chars": ", (code,)" } ] }
github.com/nus-mtp/cs-modify/commit/79b4b1dd7eba5445751808e4c50b49d2dd08366b
components/model.py
cwe-089
wins
@endpoints.route("/wins") def wins(): if db == None: init() player = request.args.get('tag', default="christmasmike") sql = "SELECT * FROM matches WHERE winner = '"+str(player)+"' ORDER BY date DESC;" result = db.exec(sql) result = [str(x) for x in result] result = '\n'.join(result) ...
@endpoints.route("/wins") def wins(): if db == None: init() player = request.args.get('tag', default="christmasmike") sql = "SELECT * FROM matches WHERE winner = '{player}' ORDER BY date DESC;" args = {'player': player} result = db.exec(sql, args) result = [str(x) for x in result] ...
{ "deleted": [ { "line_no": 7, "char_start": 135, "char_end": 222, "line": " sql = \"SELECT * FROM matches WHERE winner = '\"+str(player)+\"' ORDER BY date DESC;\"\n" }, { "line_no": 8, "char_start": 222, "char_end": 248, "line": " result = db.exec(sql...
{ "deleted": [ { "char_start": 184, "char_end": 190, "chars": "\"+str(" }, { "char_start": 196, "char_end": 199, "chars": ")+\"" } ], "added": [ { "char_start": 184, "char_end": 185, "chars": "{" }, { "char_start": 191, ...
github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63
endpoints.py
cwe-089
delete_event
def delete_event(self, event_id): sql = """DELETE FROM events WHERE event_id = {0} """.format(event_id) affected_count = self.cur.execute(sql) self.conn.commit() return affected_count
def delete_event(self, event_id): sql = """ DELETE FROM events WHERE event_id = %s """ affected_count = self.cur.execute(sql, (event_id,)) self.conn.commit() return affected_count
{ "deleted": [ { "line_no": 2, "char_start": 38, "char_end": 74, "line": " sql = \"\"\"DELETE FROM events\n" }, { "line_no": 3, "char_start": 74, "char_end": 112, "line": " WHERE event_id = {0}\n" }, { "line_no": 4, ...
{ "deleted": [ { "char_start": 88, "char_end": 91, "chars": " " }, { "char_start": 108, "char_end": 111, "chars": "{0}" }, { "char_start": 112, "char_end": 115, "chars": " " }, { "char_start": 132, "char_end": 149, ...
github.com/jgayfer/spirit/commit/01c846c534c8d3cf6763f8b7444a0efe2caa3799
db/dbase.py
cwe-089
add_item
def add_item(self, item): """"Add new item.""" if self.connection: self.cursor.execute('insert into item (name, shoppinglistid) values ("%s", "%s")' % (item[0], item[1])) self.connection.commit()
def add_item(self, item): """"Add new item.""" if self.connection: t = (item[0], item[1], ) self.cursor.execute('insert into item (name, shoppinglistid) values (?, ?)', t) self.connection.commit()
{ "deleted": [ { "line_no": 4, "char_start": 87, "char_end": 203, "line": " self.cursor.execute('insert into item (name, shoppinglistid) values (\"%s\", \"%s\")' % (item[0], item[1]))\n" } ], "added": [ { "line_no": 4, "char_start": 87, "char_end": ...
{ "deleted": [ { "char_start": 168, "char_end": 172, "chars": "\"%s\"" }, { "char_start": 174, "char_end": 178, "chars": "\"%s\"" }, { "char_start": 180, "char_end": 191, "chars": " % (item[0]" }, { "char_start": 193, "char_...
github.com/ecosl-developers/ecosl/commit/8af050a513338bf68ff2a243e4a2482d24e9aa3a
ecosldb/ecosldb.py
cwe-089
fetch_issue
def fetch_issue(cursor, id): """ Fetch an issue by id along with its tags. Returns None if no issue with the specified id exists in the database. """ cursor.execute(f""" SELECT issue.id, issue.title, issue.description, tag.namespace, ...
def fetch_issue(cursor, id): """ Fetch an issue by id along with its tags. Returns None if no issue with the specified id exists in the database. """ cursor.execute(""" SELECT issue.id, issue.title, issue.description, tag.namespace, ...
{ "deleted": [ { "line_no": 6, "char_start": 166, "char_end": 190, "line": " cursor.execute(f\"\"\"\n" }, { "line_no": 18, "char_start": 457, "char_end": 485, "line": " issue.id = {id}\n" }, { "line_no": 19, "char_start": 48...
{ "deleted": [ { "char_start": 185, "char_end": 186, "chars": "f" }, { "char_start": 480, "char_end": 484, "chars": "{id}" } ], "added": [ { "char_start": 479, "char_end": 480, "chars": "?" }, { "char_start": 488, "char_...
github.com/nutty7t/tissue/commit/306dd094749bb39cbd5c74a6ded3d3b191033061
server/server.py
cwe-089
also_add
def also_add(name, also): db = db_connect() cursor = db.cursor() try: cursor.execute(''' INSERT INTO isalso(name,also) VALUES('{}','{}') '''.format(name, also)) db.commit() logger.debug('added to isalso name {} with value {}'.format( name, also)) ...
def also_add(name, also): db = db_connect() cursor = db.cursor() try: cursor.execute(''' INSERT INTO isalso(name,also) VALUES(%(name)s,%(also)s) ''', ( name, also, )) db.commit() logger.debug('added to isalso name {} with value ...
{ "deleted": [ { "line_no": 6, "char_start": 109, "char_end": 169, "line": " INSERT INTO isalso(name,also) VALUES('{}','{}')\n" }, { "line_no": 7, "char_start": 169, "char_end": 205, "line": " '''.format(name, also))\n" } ], "ad...
{ "deleted": [ { "char_start": 158, "char_end": 162, "chars": "'{}'" }, { "char_start": 163, "char_end": 167, "chars": "'{}'" }, { "char_start": 184, "char_end": 191, "chars": ".format" } ], "added": [ { "char_start": 158, ...
github.com/tylarb/KarmaBoi-PCF/commit/c1d00a27d7f6b7eb6f15a3dacd4269654a32c10a
KarmaBoi/dbopts.py
cwe-089
getCommentsLike
def getCommentsLike(self,commentid): sqlText="select userid from comment_like where commentid=%d"%(commentid) result=sql.queryDB(self.conn,sqlText) return result;
def getCommentsLike(self,commentid): sqlText="select userid from comment_like where commentid=%s" params=[commentid] result=sql.queryDB(self.conn,sqlText,params) return result;
{ "deleted": [ { "line_no": 2, "char_start": 41, "char_end": 122, "line": " sqlText=\"select userid from comment_like where commentid=%d\"%(commentid)\n" }, { "line_no": 3, "char_start": 122, "char_end": 168, "line": " result=sql.queryDB(self.c...
{ "deleted": [ { "char_start": 107, "char_end": 108, "chars": "d" }, { "char_start": 109, "char_end": 111, "chars": "%(" }, { "char_start": 120, "char_end": 121, "chars": ")" } ], "added": [ { "char_start": 107, "char_en...
github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9
modules/comment.py
cwe-089
update_theory_base
def update_theory_base(tag, link): theory = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + "\\theory.db") conn = theory.cursor() conn.execute("insert into " + str(tag) + " values (?)", (str(link), )) theory.commit() theory.close()
def update_theory_base(tag, link): theory = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + "\\theory.db") conn = theory.cursor() conn.execute("insert into ? values (?)", (tag, str(link))) theory.commit() theory.close()
{ "deleted": [ { "line_no": 4, "char_start": 151, "char_end": 226, "line": " conn.execute(\"insert into \" + str(tag) + \" values (?)\", (str(link), ))\n" } ], "added": [ { "line_no": 4, "char_start": 151, "char_end": 214, "line": " conn.execute(\"...
{ "deleted": [ { "char_start": 181, "char_end": 197, "chars": "\" + str(tag) + \"" }, { "char_start": 221, "char_end": 223, "chars": ", " } ], "added": [ { "char_start": 181, "char_end": 182, "chars": "?" }, { "char_start": 19...
github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90
bases/update.py
cwe-089
get_asset_and_volume
@app.route('/get_asset_and_volume') def get_asset_and_volume(): asset_id = request.args.get('asset_id') if not isObject(asset_id): ws.send('{"id":1, "method":"call", "params":[0,"lookup_asset_symbols",[["' + asset_id + '"], 0]]}') result_l = ws.recv() j_l = json.loads(result_l) ...
@app.route('/get_asset_and_volume') def get_asset_and_volume(): asset_id = request.args.get('asset_id') if not isObject(asset_id): ws.send('{"id":1, "method":"call", "params":[0,"lookup_asset_symbols",[["' + asset_id + '"], 0]]}') result_l = ws.recv() j_l = json.loads(result_l) ...
{ "deleted": [ { "line_no": 40, "char_start": 1428, "char_end": 1499, "line": " query = \"SELECT volume, mcap FROM assets WHERE aid='\"+asset_id+\"'\"\n" }, { "line_no": 41, "char_start": 1499, "char_end": 1522, "line": " cur.execute(query)\n" } ...
{ "deleted": [ { "char_start": 1483, "char_end": 1487, "chars": "'\"+a" }, { "char_start": 1488, "char_end": 1497, "chars": "set_id+\"'" } ], "added": [ { "char_start": 1483, "char_end": 1484, "chars": "%" }, { "char_start": 1...
github.com/VinChain/vinchain-python-api-backend/commit/b78088a551fbb712121269c6eb7f43ede120ff60
api.py
cwe-089
reportMatch
def reportMatch(winner, loser): """Records the outcome of a single match between two players. Args: winner: the id number of the player who won loser: the id number of the player who lost """ try: int(winner) int(loser) except ValueError: raise ValueError( ...
def reportMatch(winner, loser): """Records the outcome of a single match between two players. Args: winner: the id number of the player who won loser: the id number of the player who lost """ try: int(winner) int(loser) except ValueError: raise ValueError( ...
{ "deleted": [ { "line_no": 20, "char_start": 551, "char_end": 624, "line": " statement = \"INSERT INTO matches values ({w}, {l})\".format(w=w, l=l)\n" }, { "line_no": 21, "char_start": 624, "char_end": 649, "line": " c.execute(statement)\n" } ],...
{ "deleted": [ { "char_start": 555, "char_end": 559, "chars": "stat" }, { "char_start": 560, "char_end": 561, "chars": "m" }, { "char_start": 562, "char_end": 563, "chars": "n" }, { "char_start": 564, "char_end": 567, ...
github.com/tdnelson2/tournament-db/commit/00f3caeed0e12e806c2808d100908698777d9e98
tournament.py
cwe-089
getPlayer
def getPlayer(player): db.execute("SELECT * FROM players WHERE Name = '%s' COLLATE NOCASE" % player) playerstats = dict(db.fetchone()) return playerstats
def getPlayer(player): db.execute("SELECT * FROM players WHERE Name = ? COLLATE NOCASE", player) playerstats = dict(db.fetchone()) return playerstats
{ "deleted": [ { "line_no": 2, "char_start": 23, "char_end": 102, "line": "\tdb.execute(\"SELECT * FROM players WHERE Name = '%s' COLLATE NOCASE\" % player)\n" } ], "added": [ { "line_no": 2, "char_start": 23, "char_end": 98, "line": "\tdb.execute(\"SELE...
{ "deleted": [ { "char_start": 71, "char_end": 75, "chars": "'%s'" }, { "char_start": 91, "char_end": 93, "chars": " %" } ], "added": [ { "char_start": 71, "char_end": 72, "chars": "?" }, { "char_start": 88, "char_end": ...
github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2
plugins/database.py
cwe-089
karma_sub
def karma_sub(name): karma = karma_ask(name) db = db_connect() cursor = db.cursor() if karma is None: try: cursor.execute(''' INSERT INTO people(name,karma,shame) VALUES('{}',-1,0) '''.format(name)) db.commit() logger.debug('Ins...
def karma_sub(name): karma = karma_ask(name) db = db_connect() cursor = db.cursor() if karma is None: try: cursor.execute(''' INSERT INTO people(name,karma,shame) VALUES(%(name)s,-1,0) ''', (name, )) db.commit() logger.debug('In...
{ "deleted": [ { "line_no": 8, "char_start": 162, "char_end": 233, "line": " INSERT INTO people(name,karma,shame) VALUES('{}',-1,0)\n" }, { "line_no": 9, "char_start": 233, "char_end": 267, "line": " '''.format(name))\n" }, ...
{ "deleted": [ { "char_start": 222, "char_end": 226, "chars": "'{}'" }, { "char_start": 252, "char_end": 259, "chars": ".format" }, { "char_start": 657, "char_end": 660, "chars": "{0}" }, { "char_start": 674, "char_end": 679...
github.com/tylarb/KarmaBoi-PCF/commit/c1d00a27d7f6b7eb6f15a3dacd4269654a32c10a
KarmaBoi/dbopts.py
cwe-089
login
@app.route('/', methods=['POST']) def login(): print('login') user = str(request.form['username']) password = str(request.form['password']) cur.execute('SELECT * FROM users WHERE name = \'{}\' AND password = \'{}\';'.format(user, password)) response = cur.fetchone() if response != None: ...
@app.route('/', methods=['POST']) def login(): print('login') user = str(request.form['username']) password = str(request.form['password']) cur.execute("SELECT * FROM users WHERE name = ? AND password = ?;", [user, password]) response = cur.fetchone() if response != None: print(response,...
{ "deleted": [ { "line_no": 6, "char_start": 152, "char_end": 257, "line": " cur.execute('SELECT * FROM users WHERE name = \\'{}\\' AND password = \\'{}\\';'.format(user, password))\n" } ], "added": [ { "line_no": 6, "char_start": 152, "char_end": 242, ...
{ "deleted": [ { "char_start": 168, "char_end": 169, "chars": "'" }, { "char_start": 202, "char_end": 208, "chars": "\\'{}\\'" }, { "char_start": 224, "char_end": 230, "chars": "\\'{}\\'" }, { "char_start": 231, "char_end": ...
github.com/ChemiKyle/Waterspots/commit/3f9d5099496336f3f34c48abf0cf55acaaa29011
app.py
cwe-089
fetch_data
def fetch_data(self, session, id): self._openContainer(session) sid = str(id) if (self.idNormalizer is not None): sid = self.idNormalizer.process_string(session, sid) query = ("SELECT data FROM %s WHERE identifier = '%s';" % (self.table, sid) ...
def fetch_data(self, session, id): self._openContainer(session) sid = str(id) if (self.idNormalizer is not None): sid = self.idNormalizer.process_string(session, sid) query = ("SELECT data FROM %s WHERE identifier = $1;" % (self.table) ) ...
{ "deleted": [ { "line_no": 6, "char_start": 207, "char_end": 273, "line": " query = (\"SELECT data FROM %s WHERE identifier = '%s';\" %\n" }, { "line_no": 7, "char_start": 273, "char_end": 308, "line": " (self.table, sid)\n" }, ...
{ "deleted": [ { "char_start": 264, "char_end": 268, "chars": "'%s'" }, { "char_start": 301, "char_end": 306, "chars": ", sid" } ], "added": [ { "char_start": 264, "char_end": 266, "chars": "$1" }, { "char_start": 351, "...
github.com/cheshire3/cheshire3/commit/d350363b4ea10f102c24c8f26d7b76b006323e8e
cheshire3/sql/postgresStore.py
cwe-089
registerPlayer
def registerPlayer(name): """Adds a player to the tournament database. The database assigns a unique serial id number for the player. (This should be handled by your SQL database schema, not in your Python code.) Args: name: the player's full name (need not be unique). """ conn = connec...
def registerPlayer(name): """Adds a player to the tournament database. The database assigns a unique serial id number for the player. (This should be handled by your SQL database schema, not in your Python code.) Args: name: the player's full name (need not be unique). """ conn = connec...
{ "deleted": [ { "line_no": 12, "char_start": 351, "char_end": 425, "line": " cursor.execute(\"INSERT INTO players (name) VALUES ('%s')\" % (name,));\n" } ], "added": [ { "line_no": 12, "char_start": 351, "char_end": 405, "line": " query = \"INSERT...
{ "deleted": [ { "char_start": 355, "char_end": 356, "chars": "c" }, { "char_start": 357, "char_end": 360, "chars": "rso" }, { "char_start": 361, "char_end": 370, "chars": ".execute(" }, { "char_start": 406, "char_end": 407,...
github.com/sarahkcaplan/tournament/commit/40aba5686059f5f398f6323b1483412c56140cc0
tournament.py
cwe-089
register
@mod.route('/register', methods=['GET', 'POST']) def register(): if request.method == 'POST': error = None email = request.form['email'].strip() nickname = request.form['nickname'].strip() password = request.form['password'].strip() password2 = request.form['password2'].strip...
@mod.route('/register', methods=['GET', 'POST']) def register(): if request.method == 'POST': error = None email = request.form['email'].strip() nickname = request.form['nickname'].strip() password = request.form['password'].strip() password2 = request.form['password2'].strip...
{ "deleted": [ { "line_no": 22, "char_start": 852, "char_end": 918, "line": " sql = \"SELECT * FROM users where email = '%s';\" % (email)\n" }, { "line_no": 23, "char_start": 918, "char_end": 946, "line": " cursor.execute(sql)\n" } ], "...
{ "deleted": [ { "char_start": 861, "char_end": 866, "chars": "ql = " }, { "char_start": 901, "char_end": 902, "chars": "'" }, { "char_start": 904, "char_end": 905, "chars": "'" }, { "char_start": 907, "char_end": 909, ...
github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9
flaskr/flaskr/views/users.py
cwe-089
process_form
def process_form(): # see https://docs.python.org/3.4/library/cgi.html for the basic usage # here. form = cgi.FieldStorage() # connect to the database conn = MySQLdb.connect(host = pnsdp.SQL_HOST, user = pnsdp.SQL_USER, passwd = pnsdp.SQL_P...
def process_form(): # see https://docs.python.org/3.4/library/cgi.html for the basic usage # here. form = cgi.FieldStorage() # connect to the database conn = MySQLdb.connect(host = pnsdp.SQL_HOST, user = pnsdp.SQL_USER, passwd = pnsdp.SQL_P...
{ "deleted": [ { "line_no": 50, "char_start": 1369, "char_end": 1479, "line": " cursor.execute(\"\"\"UPDATE games SET state=\"%s:resignation\" WHERE id=%d;\"\"\" % (other_player_name,game))\n" }, { "line_no": 63, "char_start": 1806, "char_end": 1927, ...
{ "deleted": [ { "char_start": 1450, "char_end": 1452, "chars": " %" }, { "char_start": 1905, "char_end": 1907, "chars": " %" }, { "char_start": 2310, "char_end": 2312, "chars": " %" } ], "added": [ { "char_start": 1450, ...
github.com/russ-lewis/ttt_-_python_cgi/commit/6096f43fd4b2d91211eec4614b7960c0816900da
cgi/move.py
cwe-089
load_user
@login_manager.user_loader def load_user(s_id): email = str(s_id) query = '''select * from usr where email like\'''' + email + '\'' cursor = g.conn.execute(query) user = User() for row in cursor: user.name = str(row.name) user.email = str(row.email) break return user
@login_manager.user_loader def load_user(s_id): email = str(s_id) query = 'select * from usr where email like %s' cursor = g.conn.execute(query, (email, )) user = User() for row in cursor: user.name = str(row.name) user.email = str(row.email) break return user
{ "deleted": [ { "line_no": 4, "char_start": 70, "char_end": 140, "line": " query = '''select * from usr where email like\\'''' + email + '\\''\n" }, { "line_no": 5, "char_start": 140, "char_end": 175, "line": " cursor = g.conn.execute(query)\n" } ...
{ "deleted": [ { "char_start": 83, "char_end": 85, "chars": "''" }, { "char_start": 119, "char_end": 124, "chars": "\\''''" }, { "char_start": 125, "char_end": 138, "chars": "+ email + '\\'" } ], "added": [ { "char_start": 118...
github.com/Daniel-Bu/w4111-project1/commit/fe04bedc72e62fd4c4ee046a9af29fd81e9b3340
Web-app/Server.py
cwe-089
delete
@mod.route('/delete/<int:cmt_id>', methods=['GET', 'POST']) def delete(cmt_id): if request.method == 'GET': sql = "SELECT msg_id FROM comment where cmt_id = %d;" % (cmt_id) cursor.execute(sql) m = cursor.fetchone() sql = "DELETE FROM comment where cmt_id = '%d';" % (cmt_id) c...
@mod.route('/delete/<int:cmt_id>', methods=['GET', 'POST']) def delete(cmt_id): if request.method == 'GET': cursor.execute("SELECT msg_id FROM comment where cmt_id = %s;", (cmt_id,)) m = cursor.fetchone() cursor.execute("DELETE FROM comment where cmt_id = %s;", (cmt_id,)) conn.commit...
{ "deleted": [ { "line_no": 4, "char_start": 112, "char_end": 185, "line": " sql = \"SELECT msg_id FROM comment where cmt_id = %d;\" % (cmt_id)\n" }, { "line_no": 5, "char_start": 185, "char_end": 213, "line": " cursor.execute(sql)\n" }, ...
{ "deleted": [ { "char_start": 121, "char_end": 126, "chars": "ql = " }, { "char_start": 170, "char_end": 171, "chars": "d" }, { "char_start": 173, "char_end": 175, "chars": " %" }, { "char_start": 184, "char_end": 211, ...
github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9
flaskr/flaskr/views/comment.py
cwe-089
get_markets
@app.route('/get_markets') def get_markets(): asset_id = request.args.get('asset_id') if not isObject(asset_id): ws.send('{"id":1, "method":"call", "params":[0,"lookup_asset_symbols",[["' + asset_id + '"], 0]]}') result_l = ws.recv() j_l = json.loads(result_l) asset_id = j_l["re...
@app.route('/get_markets') def get_markets(): asset_id = request.args.get('asset_id') if not isObject(asset_id): ws.send('{"id":1, "method":"call", "params":[0,"lookup_asset_symbols",[["' + asset_id + '"], 0]]}') result_l = ws.recv() j_l = json.loads(result_l) asset_id = j_l["re...
{ "deleted": [ { "line_no": 15, "char_start": 408, "char_end": 469, "line": " query = \"SELECT * FROM markets WHERE aid='\"+asset_id+\"'\"\n" }, { "line_no": 16, "char_start": 469, "char_end": 492, "line": " cur.execute(query)\n" } ], "added": ...
{ "deleted": [ { "char_start": 453, "char_end": 457, "chars": "'\"+a" }, { "char_start": 458, "char_end": 467, "chars": "set_id+\"'" } ], "added": [ { "char_start": 453, "char_end": 454, "chars": "%" }, { "char_start": 478, ...
github.com/VinChain/vinchain-python-api-backend/commit/b78088a551fbb712121269c6eb7f43ede120ff60
api.py
cwe-089
get_secrets
def get_secrets(self, from_date_added=0): secrets = [] for row in self.cursor.execute('SELECT encrypted, json_id, date_added FROM secret WHERE date_added > %s ORDER BY date_added DESC' % from_date_added): aes_key, json_id, date_added = cryptlib.eciesDecrypt(row[0], self.privkey), row[1], row[2] if aes_key !=...
def get_secrets(self, from_date_added=0): secrets = [] for row in self.cursor.execute('SELECT encrypted, json_id, date_added FROM secret WHERE date_added > ? ORDER BY date_added DESC', (from_date_added,)): aes_key, json_id, date_added = cryptlib.eciesDecrypt(row[0], self.privkey), row[1], row[2] if aes_key !...
{ "deleted": [ { "line_no": 3, "char_start": 58, "char_end": 210, "line": "\t\tfor row in self.cursor.execute('SELECT encrypted, json_id, date_added FROM secret WHERE date_added > %s ORDER BY date_added DESC' % from_date_added):\n" } ], "added": [ { "line_no": 3, "c...
{ "deleted": [ { "char_start": 161, "char_end": 163, "chars": "%s" }, { "char_start": 189, "char_end": 191, "chars": " %" } ], "added": [ { "char_start": 161, "char_end": 162, "chars": "?" }, { "char_start": 188, "char_e...
github.com/imachug/ZeroMailProxy/commit/8f62d024c6c4c957079d147e59f26d15c07dc888
zeromail.py
cwe-089
add_consumption_data_row
def add_consumption_data_row(self, ts, energy_used, power_used): if power_used > 0: query = ''' INSERT OR IGNORE INTO Consumption ( TimeStamp, EnergyUsed, PowerUsed ) VAL...
def add_consumption_data_row(self, ts, energy_used, power_used): if power_used > 0: query = ''' INSERT OR IGNORE INTO Consumption ( TimeStamp, EnergyUsed, PowerUsed ) VAL...
{ "deleted": [ { "line_no": 11, "char_start": 326, "char_end": 350, "line": " %s,\n" }, { "line_no": 12, "char_start": 350, "char_end": 374, "line": " %s,\n" }, { "line_no": 13, "char_start": 374, ...
{ "deleted": [ { "char_start": 346, "char_end": 348, "chars": "%s" }, { "char_start": 370, "char_end": 372, "chars": "%s" }, { "char_start": 394, "char_end": 396, "chars": "%s" }, { "char_start": 431, "char_end": 444, ...
github.com/philipptrenz/s0-bridge/commit/269b48caa05377b7c58c3e6d1622a4429cb5ba65
util/database.py
cwe-089
lookup_assets
@app.route('/lookup_assets') def lookup_assets(): start = request.args.get('start') con = psycopg2.connect(**config.POSTGRES) cur = con.cursor() query = "SELECT aname FROM assets WHERE aname LIKE '"+start+"%'" cur.execute(query) results = cur.fetchall() con.close() return jsonify(resul...
@app.route('/lookup_assets') def lookup_assets(): start = request.args.get('start') con = psycopg2.connect(**config.POSTGRES) cur = con.cursor() query = "SELECT aname FROM assets WHERE aname LIKE %s" cur.execute(query, (start+'%',)) results = cur.fetchall() con.close() return jsonify(r...
{ "deleted": [ { "line_no": 8, "char_start": 159, "char_end": 228, "line": " query = \"SELECT aname FROM assets WHERE aname LIKE '\"+start+\"%'\"\n" }, { "line_no": 9, "char_start": 228, "char_end": 251, "line": " cur.execute(query)\n" } ], "ad...
{ "deleted": [ { "char_start": 214, "char_end": 224, "chars": "'\"+start+\"" }, { "char_start": 225, "char_end": 226, "chars": "'" } ], "added": [ { "char_start": 214, "char_end": 215, "chars": "%" }, { "char_start": 239, ...
github.com/VinChain/vinchain-python-api-backend/commit/b78088a551fbb712121269c6eb7f43ede120ff60
api.py
cwe-089
set_state
def set_state(chat_id, value): settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + "\\bases\\settings.db") conn = settings.cursor() conn.execute("update users set state ='" + str(value) + "' where chat_id = '" + str(chat_id) + "'") settings.commit() settings.close()
def set_state(chat_id, value): settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + "\\bases\\settings.db") conn = settings.cursor() conn.execute("update users set state = ? where chat_id = ?", (str(value), str(chat_id))) settings.commit() settings.close()
{ "deleted": [ { "line_no": 4, "char_start": 160, "char_end": 264, "line": " conn.execute(\"update users set state ='\" + str(value) + \"' where chat_id = '\" + str(chat_id) + \"'\")\n" } ], "added": [ { "line_no": 4, "char_start": 160, "char_end": 253, ...
{ "deleted": [ { "char_start": 202, "char_end": 204, "chars": "'\"" }, { "char_start": 205, "char_end": 222, "chars": "+ str(value) + \"'" }, { "char_start": 239, "char_end": 240, "chars": "'" }, { "char_start": 242, "char_e...
github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90
bot.py
cwe-089
_get_degree_2
def _get_degree_2(user_id, cnx): """Get all users of degree 2 follow that are not currently followed. Example: this user (follows) user B (follows) user B AND user (does NOT follow) user B means that user B will be in the list Args: user_id (int): id of user cnx: DB c...
def _get_degree_2(user_id, cnx): """Get all users of degree 2 follow that are not currently followed. Example: this user (follows) user B (follows) user B AND user (does NOT follow) user B means that user B will be in the list Args: user_id (int): id of user cnx: DB c...
{ "deleted": [ { "line_no": 26, "char_start": 912, "char_end": 973, "line": " 'ORDER BY num_mutual DESC' % (user_id, user_id, user_id)\n" }, { "line_no": 28, "char_start": 1006, "char_end": 1034, "line": " cursor.execute(sql)\n" } ], "added...
{ "deleted": [ { "char_start": 942, "char_end": 972, "chars": " % (user_id, user_id, user_id)" } ], "added": [ { "char_start": 1002, "char_end": 1031, "chars": ", (user_id, user_id, user_id)" } ] }
github.com/young-goons/rifflo-server/commit/fb311df76713b638c9486250f9badb288ffb2189
server/ygoons/modules/user/follow_suggest.py
cwe-089
get_tournaments_during_month
def get_tournaments_during_month(db, scene, date): y, m, d = date.split('-') ym_date = '{}-{}'.format(y, m) sql = "select url, date from matches where scene='{}' and date like '%{}%' group by url, date order by date".format(scene, ym_date) res = db.exec(sql) urls = [r[0] for r in res] return url...
def get_tournaments_during_month(db, scene, date): y, m, d = date.split('-') ym_date = '{}-{}'.format(y, m) sql = "select url, date from matches where scene='{scene}' and date like '%{date}%' group by url, date order by date" args = {'scene': scene, 'date': ym_date} res = db.exec(sql, args) urls...
{ "deleted": [ { "line_no": 4, "char_start": 116, "char_end": 252, "line": " sql = \"select url, date from matches where scene='{}' and date like '%{}%' group by url, date order by date\".format(scene, ym_date)\n" }, { "line_no": 5, "char_start": 252, "char_end...
{ "deleted": [ { "char_start": 228, "char_end": 231, "chars": ".fo" }, { "char_start": 232, "char_end": 236, "chars": "mat(" }, { "char_start": 250, "char_end": 251, "chars": ")" } ], "added": [ { "char_start": 171, "cha...
github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63
bracket_utils.py
cwe-089
add_input
def add_input(self,data): connection = self.connect() try: # The following is a flaw query = "INSERT INTO crimes(description) VALUES ('{}');".format(data) with connection.cursor() as cursor: cursor.execute(query) connection.commit()...
def add_input(self,data): connection = self.connect() try: # The following is a flaw query = "INSERT INTO crimes(description) VALUES (%s);" with connection.cursor() as cursor: cursor.execute(query, data) connection.commit() ...
{ "deleted": [ { "line_no": 5, "char_start": 117, "char_end": 199, "line": " query = \"INSERT INTO crimes(description) VALUES ('{}');\".format(data)\n" }, { "line_no": 7, "char_start": 247, "char_end": 285, "line": " cursor.execute(...
{ "deleted": [ { "char_start": 178, "char_end": 182, "chars": "'{}'" }, { "char_start": 185, "char_end": 198, "chars": ".format(data)" } ], "added": [ { "char_start": 178, "char_end": 180, "chars": "%s" }, { "char_start": 268,...
github.com/amrishc/crimemap/commit/51b3d51aa031d7c285295de36f5464d43debf6de
dbhelper.py
cwe-089
get_error_days
def get_error_days(cur, error_percent): """Fetches the days in which requests led to errors. Fetches the days in which the specified percentage of requests led to errors. Args: cur(obj): The cursor to execute the query. error_percent(int): The percentage of requests that led to errors....
def get_error_days(cur, error_percent): """Fetches the days in which requests led to errors. Fetches the days in which the specified percentage of requests led to errors. Args: cur(obj): The cursor to execute the query. error_percent(int): The percentage of requests that led to errors....
{ "deleted": [ { "line_no": 20, "char_start": 684, "char_end": 731, "line": " / log_requests.total::numeric > {}\n" }, { "line_no": 21, "char_start": 731, "char_end": 793, "line": " ORDER BY log_errors.date'''.format(error_percent)\n" ...
{ "deleted": [ { "char_start": 728, "char_end": 730, "chars": "{}" }, { "char_start": 770, "char_end": 792, "chars": ".format(error_percent)" } ], "added": [ { "char_start": 388, "char_end": 417, "chars": "data = (error_percent, )\n " ...
github.com/rrbiz662/log-analysis/commit/20fefbde3738088586a3c5679f743493d0a504f6
news_data_analysis.py
cwe-089
all_deposits
def all_deposits(self,coin): sql = "SELECT * FROM deposits WHERE coin='%s'" % coin self.cursor.execute(sql) return self.cursor.fetchall()
def all_deposits(self,coin): sql = "SELECT * FROM deposits WHERE coin='%s'" self.cursor.execute(sql, (coin,)) return self.cursor.fetchall()
{ "deleted": [ { "line_no": 2, "char_start": 33, "char_end": 95, "line": " sql = \"SELECT * FROM deposits WHERE coin='%s'\" % coin\n" }, { "line_no": 3, "char_start": 95, "char_end": 128, "line": " self.cursor.execute(sql)\n" } ], "adde...
{ "deleted": [ { "char_start": 87, "char_end": 94, "chars": " % coin" } ], "added": [ { "char_start": 119, "char_end": 128, "chars": ", (coin,)" } ] }
github.com/ktechmidas/garlictipsbot/commit/7c262255f933cb721109ac4be752b5b7599275aa
deposit.py
cwe-089
get_user
def get_user(self): if not hasattr(self, '_user'): qs = "select * from account_access where access_token = '%s'" % self.access_token result = self.db.get(qs) if result: self._user = result else: self._user = None ...
def get_user(self): if not hasattr(self, '_user'): qs = "select * from account_access where access_token = %s" result = self.db.get(qs, self.access_token) if result: self._user = result else: self._user = None r...
{ "deleted": [ { "line_no": 3, "char_start": 63, "char_end": 157, "line": " qs = \"select * from account_access where access_token = '%s'\" % self.access_token\n" }, { "line_no": 4, "char_start": 157, "char_end": 194, "line": " result =...
{ "deleted": [ { "char_start": 131, "char_end": 132, "chars": "'" }, { "char_start": 134, "char_end": 135, "chars": "'" }, { "char_start": 136, "char_end": 156, "chars": " % self.access_token" } ], "added": [ { "char_start": 1...
github.com/bonbondirac/tsunami/commit/396cc394bd6daaf0ee9c16b1b55a4082eeaac208
src/auth.py
cwe-089
compare_and_update
@staticmethod def compare_and_update(user, message): """ This method compare a user object from the bot and his info from the Telegram message to check whether a user has changed his bio or not. If yes, the user object that represents him in the bot will be updated accord...
@staticmethod def compare_and_update(user, message): """ This method compare a user object from the bot and his info from the Telegram message to check whether a user has changed his bio or not. If yes, the user object that represents him in the bot will be updated accord...
{ "deleted": [ { "line_no": 41, "char_start": 1578, "char_end": 1635, "line": " f\"SET first_name='{user.first_name}', \"\n" }, { "line_no": 42, "char_start": 1635, "char_end": 1684, "line": " f\"nickname='{user.nickname}', \"...
{ "deleted": [ { "char_start": 1612, "char_end": 1615, "chars": "'{u" }, { "char_start": 1616, "char_end": 1631, "chars": "er.first_name}'" }, { "char_start": 1663, "char_end": 1666, "chars": "'{u" }, { "char_start": 1667, "...
github.com/RandyRomero/photoGPSbot/commit/0e9f57f13e61863b3672f5730e27f149da00786a
photogpsbot/users.py
cwe-089
GameNewPlayed
def GameNewPlayed(Played, ID): db.execute("UPDATE games set GamesPlayed = %i WHERE ID = %i" % (Played, ID)) database.commit()
def GameNewPlayed(Played, ID): db.execute("UPDATE games set GamesPlayed = ? WHERE ID = ?", Played, ID) database.commit()
{ "deleted": [ { "line_no": 2, "char_start": 31, "char_end": 109, "line": "\tdb.execute(\"UPDATE games set GamesPlayed = %i WHERE ID = %i\" % (Played, ID))\n" } ], "added": [ { "line_no": 2, "char_start": 31, "char_end": 104, "line": "\tdb.execute(\"UPDA...
{ "deleted": [ { "char_start": 75, "char_end": 77, "chars": "%i" }, { "char_start": 89, "char_end": 91, "chars": "%i" }, { "char_start": 92, "char_end": 94, "chars": " %" }, { "char_start": 95, "char_end": 96, "chars":...
github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2
plugins/database.py
cwe-089
insertNPC
def insertNPC(name, race,classe,sex,level,image,legit): c, conn = getConnection() date = now() c.execute("INSERT INTO npc VALUES ('"+date+"','"+str(name)+"','"+race+"','"+classe+"','"+sex+"','"+str(level)+"','"+image+"','"+str(legit)+"')") conn.commit() conn.close()
def insertNPC(name, race,classe,sex,level,image,legit): c, conn = getConnection() date = now() c.execute("INSERT INTO npc VALUES (?,?,?,?,?,?,?,?)",(date,str(name),race,classe,sex,str(level),image,str(legit))) conn.commit() conn.close()
{ "deleted": [ { "line_no": 4, "char_start": 97, "char_end": 243, "line": "\tc.execute(\"INSERT INTO npc VALUES ('\"+date+\"','\"+str(name)+\"','\"+race+\"','\"+classe+\"','\"+sex+\"','\"+str(level)+\"','\"+image+\"','\"+str(legit)+\"')\")\n" } ], "added": [ { "line_no": ...
{ "deleted": [ { "char_start": 133, "char_end": 134, "chars": "'" }, { "char_start": 135, "char_end": 136, "chars": "+" }, { "char_start": 140, "char_end": 143, "chars": "+\"'" }, { "char_start": 144, "char_end": 147, ...
github.com/DangerBlack/DungeonsAndDragonsMasterBot/commit/63f980c6dff746f5fcf3005d0646b6c24f81cdc0
database.py
cwe-089
get
def get(self, user_id): """ Fetch data for user with corresponding user_id """ return database_utilities.execute_query(f"""select * from users where user_id = '{user_id}'""")
def get(self, user_id): """ Fetch data for user with corresponding user_id """ return database_utilities.execute_query(f"""select * from users where user_id = %s""", (user_id, ))
{ "deleted": [ { "line_no": 3, "char_start": 91, "char_end": 194, "line": " return database_utilities.execute_query(f\"\"\"select * from users where user_id = '{user_id}'\"\"\")\n" } ], "added": [ { "line_no": 3, "char_start": 91, "char_end": 198, ...
{ "deleted": [ { "char_start": 179, "char_end": 181, "chars": "'{" }, { "char_start": 188, "char_end": 193, "chars": "}'\"\"\"" } ], "added": [ { "char_start": 179, "char_end": 187, "chars": "%s\"\"\", (" }, { "char_start": 19...
github.com/sgosal2/tiger-boards-backend/commit/4670109dd613df2f2fe7e8403ebd149df2b55485
apis/users.py
cwe-089
h2h
@endpoints.route("/h2h") def h2h(): if db == None: init() player1 = request.args.get('tag1', default="christmasmike") player2 = request.args.get('tag2', default="christmasmike") sql = "SELECT * FROM matches WHERE (player1 = '"+str(player1)+"' OR "\ +"player2 = '"+str(player1)+"') AN...
@endpoints.route("/h2h") def h2h(): if db == None: init() player1 = request.args.get('tag1', default="christmasmike") player2 = request.args.get('tag2', default="christmasmike") sql = "SELECT * FROM matches WHERE (player1 = '{player1}' OR "\ +"player2 = '{player1}') AND (player1 = '...
{ "deleted": [ { "line_no": 8, "char_start": 199, "char_end": 274, "line": " sql = \"SELECT * FROM matches WHERE (player1 = '\"+str(player1)+\"' OR \"\\\n" }, { "line_no": 9, "char_start": 274, "char_end": 358, "line": " +\"player2 = '\"+str(pl...
{ "deleted": [ { "char_start": 250, "char_end": 256, "chars": "\"+str(" }, { "char_start": 263, "char_end": 266, "chars": ")+\"" }, { "char_start": 299, "char_end": 305, "chars": "\"+str(" }, { "char_start": 312, "char_end":...
github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63
endpoints.py
cwe-089
insertData
def insertData(self,userid,post): sqlText="insert into post(userid,date,comment) \ values(%d,current_timestamp(0),'%s');"%(userid,post); result=sql.insertDB(self.conn,sqlText) return result;
def insertData(self,userid,post): sqlText="insert into post(userid,date,comment) \ values(%s,current_timestamp(0),%s);" params=[userid,post]; result=sql.insertDB(self.conn,sqlText,params) return result;
{ "deleted": [ { "line_no": 3, "char_start": 95, "char_end": 165, "line": " values(%d,current_timestamp(0),'%s');\"%(userid,post);\n" }, { "line_no": 4, "char_start": 165, "char_end": 212, "line": " result=sql.insertDB(self.conn,sqlText...
{ "deleted": [ { "char_start": 119, "char_end": 120, "chars": "d" }, { "char_start": 142, "char_end": 143, "chars": "'" }, { "char_start": 145, "char_end": 146, "chars": "'" }, { "char_start": 149, "char_end": 151, "ch...
github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9
modules/post.py
cwe-089
get_requested_month_for_inverter
def get_requested_month_for_inverter(self, inverter_serial, date): data = dict() month_start, month_end = self.get_epoch_month(date) data['interval'] = {'from': self.convert_local_ts_to_utc(month_start, self.local_timezone), 'to': self.convert_local_ts_to_utc(month_end, self.local_timezone)...
def get_requested_month_for_inverter(self, inverter_serial, date): data = dict() month_start, month_end = self.get_epoch_month(date) data['interval'] = {'from': self.convert_local_ts_to_utc(month_start, self.local_timezone), 'to': self.convert_local_ts_to_utc(month_end, self.local_timezone)...
{ "deleted": [ { "line_no": 11, "char_start": 444, "char_end": 506, "line": " WHERE TimeStamp BETWEEN %s AND %s AND Serial = %s\n" }, { "line_no": 15, "char_start": 553, "char_end": 639, "line": " for row in self.c.execute(query % (month_st...
{ "deleted": [ { "char_start": 480, "char_end": 482, "chars": "%s" }, { "char_start": 487, "char_end": 489, "chars": "%s" }, { "char_start": 500, "char_end": 501, "chars": " " }, { "char_start": 502, "char_end": 505, "...
github.com/philipptrenz/sunportal/commit/7eef493a168ed4e6731ff800713bfb8aee99a506
util/database.py
cwe-089
delete_resultSet
def delete_resultSet(self, session, id): self._openContainer(session) sid = str(id) if (self.idNormalizer is not None): sid = self.idNormalizer.process_string(session, sid) query = "DELETE FROM %s WHERE identifier = '%s';" % (self.table, sid) self._query(query)
def delete_resultSet(self, session, id): self._openContainer(session) sid = str(id) if (self.idNormalizer is not None): sid = self.idNormalizer.process_string(session, sid) query = "DELETE FROM %s WHERE identifier = $1;" % (self.table) self._query(query, sid)
{ "deleted": [ { "line_no": 6, "char_start": 213, "char_end": 291, "line": " query = \"DELETE FROM %s WHERE identifier = '%s';\" % (self.table, sid)\n" }, { "line_no": 7, "char_start": 291, "char_end": 317, "line": " self._query(query)\n" }...
{ "deleted": [ { "char_start": 264, "char_end": 268, "chars": "'%s'" }, { "char_start": 284, "char_end": 289, "chars": ", sid" } ], "added": [ { "char_start": 264, "char_end": 266, "chars": "$1" }, { "char_start": 309, "...
github.com/cheshire3/cheshire3/commit/d350363b4ea10f102c24c8f26d7b76b006323e8e
cheshire3/sql/resultSetStore.py
cwe-089
getSeriesDateFromDatabase
def getSeriesDateFromDatabase(submission): database = sqlite3.connect('database.db') cursor = database.cursor() return cursor.execute("SELECT StartDate FROM SeriesTracking WHERE SeriesTitle = '" + str(getTitle(submission)) + "'").fetchone()[0] database.close()
def getSeriesDateFromDatabase(submission): database = sqlite3.connect('database.db') cursor = database.cursor() return cursor.execute("SELECT StartDate FROM SeriesTracking WHERE SeriesTitle = ?", [getTitle(submission)]).fetchone()[0] database.close()
{ "deleted": [ { "line_no": 4, "char_start": 120, "char_end": 256, "line": " return cursor.execute(\"SELECT StartDate FROM SeriesTracking WHERE SeriesTitle = '\" + str(getTitle(submission)) + \"'\").fetchone()[0]\n" } ], "added": [ { "line_no": 4, "char_start": 1...
{ "deleted": [ { "char_start": 204, "char_end": 205, "chars": "'" }, { "char_start": 206, "char_end": 208, "chars": " +" }, { "char_start": 209, "char_end": 213, "chars": "str(" }, { "char_start": 233, "char_end": 240, ...
github.com/LiquidFun/Reddit-GeoGuessr-Tracking-Bot/commit/0cad2d52e24b05da32789fbc8face7a9999a71f9
CheckAndPostForSeriesSubmissions.py
cwe-089
karma_add
def karma_add(name): karma = karma_ask(name) db = db_connect() cursor = db.cursor() if karma is None: try: cursor.execute(''' INSERT INTO people(name,karma,shame) VALUES('{}',1,0) '''.format(name)) db.commit() logger.debug('Inse...
def karma_add(name): karma = karma_ask(name) db = db_connect() cursor = db.cursor() if karma is None: try: cursor.execute(''' INSERT INTO people(name,karma,shame) VALUES(%(name)s,1,0) ''', name) db.commit() logger.debug('Inserte...
{ "deleted": [ { "line_no": 8, "char_start": 162, "char_end": 232, "line": " INSERT INTO people(name,karma,shame) VALUES('{}',1,0)\n" }, { "line_no": 9, "char_start": 232, "char_end": 266, "line": " '''.format(name))\n" }, ...
{ "deleted": [ { "char_start": 222, "char_end": 226, "chars": "'{}'" }, { "char_start": 251, "char_end": 259, "chars": ".format(" }, { "char_start": 263, "char_end": 264, "chars": ")" }, { "char_start": 630, "char_end": 633,...
github.com/tylarb/KarmaBoi-PCF/commit/c1d00a27d7f6b7eb6f15a3dacd4269654a32c10a
KarmaBoi/dbopts.py
cwe-089
update_date_modified
def update_date_modified(self): sql = "UPDATE jdk_entries " + \ "SET date_last_modified = " + CURRENT_DATESTAMP + " " + \ "WHERE jdk_entries.id = '" + self.entry_id + "';" db_execute(sql) return None
def update_date_modified(self): quote_tuple = CURRENT_DATESTAMP, self.entry_id sql = "UPDATE jdk_entries " + \ "SET date_last_modified = ? " + \ "WHERE jdk_entries.id = ?;" db_execute(sql, quote_tuple) return None
{ "deleted": [ { "line_no": 3, "char_start": 70, "char_end": 134, "line": " \"SET date_last_modified = \" + CURRENT_DATESTAMP + \" \" + \\\n" }, { "line_no": 4, "char_start": 134, "char_end": 190, "line": " \"WHERE jdk_entries.id = '\" + self.entry...
{ "deleted": [ { "char_start": 102, "char_end": 127, "chars": "\" + CURRENT_DATESTAMP + \"" }, { "char_start": 164, "char_end": 187, "chars": "'\" + self.entry_id + \"'" } ], "added": [ { "char_start": 38, "char_end": 90, "chars": "quote_tu...
github.com/peterlebrun/jdk/commit/000238566fbe55ba09676c3d57af04ae207235ae
entry.py
cwe-089
system_search
def system_search(self, search): search = search.lower() conn = sqlite3.connect('data/ed.db').cursor() table = conn.execute(f"select * from populated where lower(name) = '{search}'") results = table.fetchone() if not results: table = conn.execute(f"select * ...
def system_search(self, search): search = search.lower() conn = sqlite3.connect('data/ed.db').cursor() table = conn.execute('select * from populated where lower(name) = ?', (search,)) results = table.fetchone() if not results: table = conn.execute('select * ...
{ "deleted": [ { "line_no": 4, "char_start": 126, "char_end": 215, "line": " table = conn.execute(f\"select * from populated where lower(name) = '{search}'\")\r\n" }, { "line_no": 7, "char_start": 276, "char_end": 367, "line": " table = con...
{ "deleted": [ { "char_start": 155, "char_end": 157, "chars": "f\"" }, { "char_start": 202, "char_end": 203, "chars": "{" }, { "char_start": 209, "char_end": 212, "chars": "}'\"" }, { "char_start": 309, "char_end": 311, ...
github.com/BeatButton/beattie/commit/ab36b2053ee09faf4cc9a279cf7a4c010864cb29
eddb.py
cwe-089
add_input
def add_input(self, data): connection = self.connect() try: # The following introduces a deliberate security flaw - SQL Injection query = "INSERT INTO crimes (description) VALUES ('{}');".format(data) with connection.cursor() as cursor: cursor.exec...
def add_input(self, data): connection = self.connect() try: # The following introduces a deliberate security flaw - SQL Injection query = "INSERT INTO crimes (description) VALUES (%s);" with connection.cursor() as cursor: cursor.execute(query, data...
{ "deleted": [ { "line_no": 5, "char_start": 162, "char_end": 245, "line": " query = \"INSERT INTO crimes (description) VALUES ('{}');\".format(data)\n" }, { "line_no": 7, "char_start": 293, "char_end": 331, "line": " cursor.execute...
{ "deleted": [ { "char_start": 224, "char_end": 228, "chars": "'{}'" }, { "char_start": 231, "char_end": 244, "chars": ".format(data)" } ], "added": [ { "char_start": 224, "char_end": 226, "chars": "%s" }, { "char_start": 314,...
github.com/rwolf527/crimemap/commit/50b0695e0b4c46165e6146f6fac4cd6871d9fdf6
dbhelper.py
cwe-089
get_login
@bot.message_handler(commands =['login']) def get_login(message): settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + "\\bases\\settings.db") conn = settings.cursor() conn.execute("select * from users where chat_id = '" + str(message.chat.id) + "'") name = conn.fetchone() if name...
@bot.message_handler(commands =['login']) def get_login(message): settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + "\\bases\\settings.db") conn = settings.cursor() conn.execute("select * from users where chat_id = ?", (str(message.chat.id),)) name = conn.fetchone() if name != ...
{ "deleted": [ { "line_no": 5, "char_start": 195, "char_end": 282, "line": " conn.execute(\"select * from users where chat_id = '\" + str(message.chat.id) + \"'\")\n" } ], "added": [ { "line_no": 5, "char_start": 195, "char_end": 278, "line": " con...
{ "deleted": [ { "char_start": 249, "char_end": 250, "chars": "'" }, { "char_start": 251, "char_end": 253, "chars": " +" }, { "char_start": 274, "char_end": 280, "chars": " + \"'\"" } ], "added": [ { "char_start": 249, "...
github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90
bot.py
cwe-089
login
def login(self, username, password): select_query = """ SELECT client_id, username, balance, message FROM Clients WHERE username = '{}' AND password = '{}' LIMIT 1 """.format(username, password) cursor = self.__conn.cursor() cursor.ex...
def login(self, username, password): select_query = """ SELECT client_id, username, balance, message FROM Clients WHERE username = ? AND password = ? LIMIT 1 """ cursor = self.__conn.cursor() cursor.execute(select_query, (username, pa...
{ "deleted": [ { "line_no": 5, "char_start": 150, "char_end": 204, "line": " WHERE username = '{}' AND password = '{}'\n" }, { "line_no": 7, "char_start": 224, "char_end": 263, "line": " \"\"\".format(username, password)\n" }, { ...
{ "deleted": [ { "char_start": 179, "char_end": 183, "chars": "'{}'" }, { "char_start": 199, "char_end": 203, "chars": "'{}'" }, { "char_start": 235, "char_end": 262, "chars": ".format(username, password)" } ], "added": [ { "c...
github.com/AnetaStoycheva/Programming101_HackBulgaria/commit/c0d6f4b8fe83a375832845a45952b5153e4c34f3
Week_9/sql_manager.py
cwe-089
get_current_state
def get_current_state(chat_id): settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__))+"\\bases\\settings.db") conn = settings.cursor() conn.execute("select * from users where chat_id = '" + str(chat_id) + "'") name = conn.fetchone() if name != None: return name[4] else: ...
def get_current_state(chat_id): settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__))+"\\bases\\settings.db") conn = settings.cursor() conn.execute("select * from users where chat_id = ?", (str(chat_id),)) name = conn.fetchone() if name != None: return name[4] else: ...
{ "deleted": [ { "line_no": 4, "char_start": 159, "char_end": 238, "line": " conn.execute(\"select * from users where chat_id = '\" + str(chat_id) + \"'\")\n" } ], "added": [ { "line_no": 4, "char_start": 159, "char_end": 234, "line": " conn.execut...
{ "deleted": [ { "char_start": 213, "char_end": 214, "chars": "'" }, { "char_start": 215, "char_end": 217, "chars": " +" }, { "char_start": 230, "char_end": 236, "chars": " + \"'\"" } ], "added": [ { "char_start": 213, "...
github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90
bot.py
cwe-089
fetch_page_name
def fetch_page_name(self, page_id): ''' Returns the page name corresponding to the provided page ID. Args: page_id: The page ID whose ID to fetch. Returns: str: The page name corresponding to the provided page ID. Raises: ValueError: If the provided page ID is invalid or does ...
def fetch_page_name(self, page_id): ''' Returns the page name corresponding to the provided page ID. Args: page_id: The page ID whose ID to fetch. Returns: str: The page name corresponding to the provided page ID. Raises: ValueError: If the provided page ID is invalid or does ...
{ "deleted": [ { "line_no": 16, "char_start": 378, "char_end": 446, "line": " query = 'SELECT name FROM pages WHERE id=\"{0}\"'.format(page_id)\n" }, { "line_no": 17, "char_start": 446, "char_end": 477, "line": " self.cursor.execute(query)\n" } ]...
{ "deleted": [ { "char_start": 423, "char_end": 428, "chars": "\"{0}\"" }, { "char_start": 429, "char_end": 432, "chars": ".fo" }, { "char_start": 433, "char_end": 436, "chars": "mat" } ], "added": [ { "char_start": 422, ...
github.com/jwngr/sdow/commit/4db98f3521592f17550d2b723336f33fec5e112a
sdow/database.py
cwe-089
save_page_edit
@app.route('/<page_name>/save', methods=['POST']) def save_page_edit(page_name): # grab the new content from the user content = request.form.get('content') # check if 'page_name' exists in the database query = db.query("select page_content.content, page.id as page_id, page_content.id as content_id from ...
@app.route('/<page_name>/save', methods=['POST']) def save_page_edit(page_name): # grab the new content from the user content = request.form.get('content') # check if 'page_name' exists in the database query = db.query("select page_content.content, page.id as page_id, page_content.id as content_id from ...
{ "deleted": [ { "line_no": 6, "char_start": 214, "char_end": 454, "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 ...
{ "deleted": [ { "char_start": 397, "char_end": 401, "chars": "'%s'" }, { "char_start": 440, "char_end": 442, "chars": " %" } ], "added": [ { "char_start": 397, "char_end": 399, "chars": "$1" }, { "char_start": 438, "cha...
github.com/Pumala/python_wiki_app_redo/commit/65d60747cd8efb05970304234d3bd949d2088e8b
server.py
cwe-089
get_top_popular
def get_top_popular(top_num): """ query the top(top_num) popular articles top_num => list of [title, count] """ cmd = """SELECT title, views FROM articles INNER JOIN ( SELECT path, count(path) AS views FROM log GROUP BY log.path ) AS log ...
def get_top_popular(top_num): """ query the top(top_num) popular articles top_num => list of [title, count] """ cmd = """SELECT title, views FROM articles INNER JOIN ( SELECT path, count(path) AS views FROM log GROUP BY log.path ) AS log ...
{ "deleted": [ { "line_no": 12, "char_start": 410, "char_end": 452, "line": " LIMIT {}\"\"\".format(top_num)\r\n" }, { "line_no": 13, "char_start": 452, "char_end": 481, "line": " return execute_query(cmd)\r\n" } ], "added": [ { ...
{ "deleted": [ { "char_start": 429, "char_end": 431, "chars": "{}" }, { "char_start": 434, "char_end": 439, "chars": ".form" }, { "char_start": 441, "char_end": 442, "chars": "(" }, { "char_start": 449, "char_end": 450, ...
github.com/thugasin/udacity-homework-logAnalyzer/commit/506f25f9a1caee7f17034adf7c75e0efbc88082b
logAnalyzerDb.py
cwe-089
render_page_edit
@app.route('/<page_name>/edit') def render_page_edit(page_name): query = db.query("select page_content.content 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() if len(wiki_page) > 0: ...
@app.route('/<page_name>/edit') def render_page_edit(page_name): query = db.query("select page_content.content 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() if len(wiki_page) > 0: ...
{ "deleted": [ { "line_no": 3, "char_start": 65, "char_end": 254, "line": " query = db.query(\"select page_content.content 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" } ], "added":...
{ "deleted": [ { "char_start": 197, "char_end": 201, "chars": "'%s'" }, { "char_start": 240, "char_end": 242, "chars": " %" } ], "added": [ { "char_start": 197, "char_end": 199, "chars": "$1" }, { "char_start": 238, "cha...
github.com/Pumala/python_wiki_app_redo/commit/65d60747cd8efb05970304234d3bd949d2088e8b
server.py
cwe-089
get_monthly_ranks_for_scene
def get_monthly_ranks_for_scene(db, scene, tag): sql = "SELECT date, rank FROM ranks WHERE scene='{}' AND player='{}'".format(scene, tag) res = db.exec(sql) res = [r for r in res if played_during_month(db, scene, tag, get_previous_month(r[0]))] # Build up a dict of {date: rank} ranks = {} for...
def get_monthly_ranks_for_scene(db, scene, tag): sql = "SELECT date, rank FROM ranks WHERE scene='{scene}' AND player='{tag}'" args = {'scene': scene, 'tag': tag} res = db.exec(sql, args) res = [r for r in res if played_during_month(db, scene, tag, get_previous_month(r[0]))] # Build up a dict of ...
{ "deleted": [ { "line_no": 3, "char_start": 50, "char_end": 143, "line": " sql = \"SELECT date, rank FROM ranks WHERE scene='{}' AND player='{}'\".format(scene, tag)\n" }, { "line_no": 4, "char_start": 143, "char_end": 166, "line": " res = db.exec(sql...
{ "deleted": [ { "char_start": 123, "char_end": 126, "chars": ".fo" }, { "char_start": 127, "char_end": 131, "chars": "mat(" }, { "char_start": 141, "char_end": 142, "chars": ")" } ], "added": [ { "char_start": 104, "cha...
github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63
bracket_utils.py
cwe-089
auto_unlock_tasks
@staticmethod def auto_unlock_tasks(project_id: int): """Unlock all tasks locked for longer than the auto-unlock delta""" expiry_delta = Task.auto_unlock_delta() lock_duration = (datetime.datetime.min + expiry_delta).time().isoformat() expiry_date = datetime.datetime.utcnow() - e...
@staticmethod def auto_unlock_tasks(project_id: int): """Unlock all tasks locked for longer than the auto-unlock delta""" expiry_delta = Task.auto_unlock_delta() lock_duration = (datetime.datetime.min + expiry_delta).time().isoformat() expiry_date = datetime.datetime.utcnow() - e...
{ "deleted": [ { "line_no": 14, "char_start": 652, "char_end": 687, "line": " AND t.project_id = {0}\n" }, { "line_no": 15, "char_start": 687, "char_end": 727, "line": " AND th.action_date <= '{1}'\n" }, { "line_no": 16, ...
{ "deleted": [ { "char_start": 683, "char_end": 686, "chars": "{0}" }, { "char_start": 721, "char_end": 726, "chars": "'{1}'" }, { "char_start": 742, "char_end": 779, "chars": ".format(project_id, str(expiry_date))" } ], "added": [ ...
github.com/hotosm/tasking-manager/commit/dee040a2d22b3c4d5e38e2dbf8c6b651ad4c241a
server/models/postgis/task.py
cwe-089
add_input
def add_input(self, data): connection = self.connect() try: # The following introduces a deliberate security flaw. # See section on SQL injection below query = "INSERT INTO crimes (description) VALUES('{}');".format(data) with connection.cursor() as c...
def add_input(self, data): connection = self.connect() try: # The following introduces a deliberate security flaw. # See section on SQL injection below query = "INSERT INTO crimes (description) VALUES(%s);" with connection.cursor() as cursor: ...
{ "deleted": [ { "line_no": 6, "char_start": 197, "char_end": 279, "line": " query = \"INSERT INTO crimes (description) VALUES('{}');\".format(data)\n" }, { "line_no": 8, "char_start": 327, "char_end": 365, "line": " cursor.execute(...
{ "deleted": [ { "char_start": 258, "char_end": 262, "chars": "'{}'" }, { "char_start": 265, "char_end": 278, "chars": ".format(data)" } ], "added": [ { "char_start": 258, "char_end": 260, "chars": "%s" }, { "char_start": 348,...
github.com/mudspringhiker/crimemap/commit/35e78962e7288c643cdde0f886ff7aa5ac77cb8c
dbhelper.py
cwe-089
getAllComments
def getAllComments(self): sqlText="select comment from comments where userid=%d order by date;" allposts=sql.queryDB(self.conn,sqlText) return allposts;
def getAllComments(self): sqlText="select comment from comments where userid=%s order by date;" params = [self.userid] allposts=sql.queryDB(self.conn,sqlText,params) return allposts;
{ "deleted": [ { "line_no": 2, "char_start": 30, "char_end": 108, "line": " sqlText=\"select comment from comments where userid=%d order by date;\"\n" }, { "line_no": 3, "char_start": 108, "char_end": 156, "line": " allposts=sql.queryDB(self.co...
{ "deleted": [ { "char_start": 90, "char_end": 91, "chars": "d" } ], "added": [ { "char_start": 90, "char_end": 91, "chars": "s" }, { "char_start": 116, "char_end": 147, "chars": "params = [self.userid]\n " }, { "char_s...
github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9
modules/users.py
cwe-089
update_user
def update_user(username, chat_id, last_update): conn = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + "\\users\\" + username + '.db') conn2 = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + '\\cf.db') settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + "\\sett...
def update_user(username, chat_id, last_update): conn = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + "\\users\\" + username + '.db') conn2 = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + '\\cf.db') settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + "\\sett...
{ "deleted": [ { "line_no": 8, "char_start": 426, "char_end": 527, "line": " cursor_settings.execute(\"select last_problem from users where chat_id = '\" + str(chat_id) + \"'\")\n" }, { "line_no": 17, "char_start": 862, "char_end": 980, "line": " ...
{ "deleted": [ { "char_start": 502, "char_end": 503, "chars": "'" }, { "char_start": 504, "char_end": 506, "chars": " +" }, { "char_start": 519, "char_end": 521, "chars": " +" }, { "char_start": 522, "char_end": 525, "...
github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90
bases/update.py
cwe-089
save_accepted_transaction
def save_accepted_transaction(self, user_id, project_id, money): self.cursor.execute("update users set money = money - %s where id = %s"%(money, user_id)) self.cursor.execute("update projects set money = money + %s where id = %s" % (money, project_id)) self.cursor.execute("insert into transa...
def save_accepted_transaction(self, user_id, project_id, money): self.cursor.execute("update users set money = money - %s where id = %s", (money, user_id)) self.cursor.execute("update projects set money = money + %s where id = %s", (money, project_id)) self.cursor.execute("insert into transa...
{ "deleted": [ { "line_no": 2, "char_start": 69, "char_end": 167, "line": " self.cursor.execute(\"update users set money = money - %s where id = %s\"%(money, user_id))\n" }, { "line_no": 3, "char_start": 167, "char_end": 273, "line": " self.cur...
{ "deleted": [ { "char_start": 148, "char_end": 149, "chars": "%" }, { "char_start": 249, "char_end": 251, "chars": " %" }, { "char_start": 414, "char_end": 416, "chars": " %" } ], "added": [ { "char_start": 148, "char_e...
github.com/JLucka/kickstarter-dev/commit/e2ffa062697e060fdfbd2eccbb89a8c53a569e0b
backend/transactions/TransactionConnector.py
cwe-089
shame_ask
def shame_ask(name): db = db_connect() cursor = db.cursor() try: cursor.execute(''' SELECT shame FROM people WHERE name='{}' '''.format(name)) shame = cursor.fetchone() db.close() if shame is None: logger.debug('No shame found for name {}'....
def shame_ask(name): db = db_connect() cursor = db.cursor() try: cursor.execute(''' SELECT shame FROM people WHERE name=%(name)s ''', (name, )) shame = cursor.fetchone() db.close() if shame is None: logger.debug('No shame found for name {}'...
{ "deleted": [ { "line_no": 6, "char_start": 104, "char_end": 157, "line": " SELECT shame FROM people WHERE name='{}'\n" }, { "line_no": 7, "char_start": 157, "char_end": 187, "line": " '''.format(name))\n" } ], "added": [ {...
{ "deleted": [ { "char_start": 152, "char_end": 156, "chars": "'{}'" }, { "char_start": 172, "char_end": 179, "chars": ".format" } ], "added": [ { "char_start": 152, "char_end": 160, "chars": "%(name)s" }, { "char_start": 176,...
github.com/tylarb/KarmaBoi-PCF/commit/c1d00a27d7f6b7eb6f15a3dacd4269654a32c10a
KarmaBoi/dbopts.py
cwe-089
incrementOption
def incrementOption(cursor, poll_name, option): key = poll_name+"-"+option req = "UPDATE {} SET count=count+1 WHERE name_option = '{}';".format(CFG("options_table_name"), key) cursor.execute(req)
def incrementOption(cursor, poll_name, option): key = poll_name+"-"+option req = "UPDATE {} SET count=count+1 WHERE name_option=?".format(CFG("options_table_name")) cursor.execute(req, (key,))
{ "deleted": [ { "line_no": 3, "char_start": 79, "char_end": 184, "line": " req = \"UPDATE {} SET count=count+1 WHERE name_option = '{}';\".format(CFG(\"options_table_name\"), key)\n" }, { "line_no": 4, "char_start": 184, "char_end": 207, "line": " cur...
{ "deleted": [ { "char_start": 135, "char_end": 136, "chars": " " }, { "char_start": 137, "char_end": 143, "chars": " '{}';" }, { "char_start": 177, "char_end": 182, "chars": ", key" } ], "added": [ { "char_start": 136, ...
github.com/FAUSheppy/simple-python-poll/commit/186c5ff5cdf58272e253a1bb432419ee50d93109
database.py
cwe-089
overview
@app.route('/overview/<classNum>') def overview(classNum): if 'username' in session: classNoSpace = classNum.split(' ')[0]+classNum.split(' ')[1] #Save the current course as a session variable. session['currentCourse'] = classNoSpace conn = mysql.connect() cursor = conn.cursor() cursor.execute("SELECT c...
@app.route('/overview/<classNum>') def overview(classNum): if 'username' in session: classNoSpace = classNum.split(' ')[0]+classNum.split(' ')[1] #Save the current course as a session variable. session['currentCourse'] = classNoSpace conn = mysql.connect() cursor = conn.cursor() cursor.execute("SELECT c...
{ "deleted": [ { "line_no": 12, "char_start": 294, "char_end": 408, "line": "\t\tcursor.execute(\"SELECT courseName,courseOverview from courses where courseAbbreviation='\" + classNoSpace + \"'\")\n" } ], "added": [ { "line_no": 12, "char_start": 294, "char_en...
{ "deleted": [ { "char_start": 383, "char_end": 384, "chars": "'" }, { "char_start": 386, "char_end": 388, "chars": "+ " }, { "char_start": 400, "char_end": 406, "chars": " + \"'\"" } ], "added": [ { "char_start": 383, "...
github.com/CaitlinKennedy/Tech-Track/commit/20ef2d4010f9497b8221524edd0c706e2c6a4147
src/tech_track.py
cwe-089
addTags
def addTags(tag_list, listing_id): """ Adds a list of tags tag_list for a given listing with listing_id to the database """ cur = conn.cursor() for x in tag_list: sql = "INSERT INTO {} VALUES {}".format(listing_tags_table_name, str((listing_id, x))) cur.execute(sql)
def addTags(tag_list, listing_id): """ Adds a list of tags tag_list for a given listing with listing_id to the database """ cur = conn.cursor() for x in tag_list: sql = "INSERT INTO %s VALUES (%s %s)" cur.execute(sql, (listing_tags_table_name, listing_id, x))
{ "deleted": [ { "line_no": 7, "char_start": 183, "char_end": 278, "line": " sql = \"INSERT INTO {} VALUES {}\".format(listing_tags_table_name, str((listing_id, x)))\n" }, { "line_no": 8, "char_start": 278, "char_end": 302, "line": " cur.execut...
{ "deleted": [ { "char_start": 210, "char_end": 212, "chars": "{}" }, { "char_start": 220, "char_end": 222, "chars": "{}" }, { "char_start": 223, "char_end": 226, "chars": ".fo" }, { "char_start": 227, "char_end": 229, ...
github.com/tasbir49/BreadWinner/commit/332a9f2c619be399ae94244bb8bd0977fc62bc16
backend-api/backend-api.py
cwe-089
edit
@mod.route('/edit/<int:cmt_id>', methods=['GET', 'POST']) def edit(cmt_id): m = None if request.method == 'GET': sql = "SELECT * FROM comment where cmt_id = %d;" % (cmt_id) cursor.execute(sql) m = cursor.fetchone() return render_template('comment/edit.html', m=m, cmt_id=cmt_id) ...
@mod.route('/edit/<int:cmt_id>', methods=['GET', 'POST']) def edit(cmt_id): m = None if request.method == 'GET': cursor.execute("SELECT * FROM comment where cmt_id = %s;", (cmt_id,)) m = cursor.fetchone() return render_template('comment/edit.html', m=m, cmt_id=cmt_id) if request.met...
{ "deleted": [ { "line_no": 5, "char_start": 121, "char_end": 189, "line": " sql = \"SELECT * FROM comment where cmt_id = %d;\" % (cmt_id)\n" }, { "line_no": 6, "char_start": 189, "char_end": 217, "line": " cursor.execute(sql)\n" }, { ...
{ "deleted": [ { "char_start": 130, "char_end": 135, "chars": "ql = " }, { "char_start": 174, "char_end": 175, "chars": "d" }, { "char_start": 177, "char_end": 179, "chars": " %" }, { "char_start": 188, "char_end": 215, ...
github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9
flaskr/flaskr/views/comment.py
cwe-089
process_form
def process_form(): # see https://docs.python.org/3.4/library/cgi.html for the basic usage # here. form = cgi.FieldStorage() if "player1" not in form or "player2" not in form or "size" not in form: raise FormError("Invalid parameters.") player1 = form["player1"].value player2 = form["...
def process_form(): # see https://docs.python.org/3.4/library/cgi.html for the basic usage # here. form = cgi.FieldStorage() if "player1" not in form or "player2" not in form or "size" not in form: raise FormError("Invalid parameters.") player1 = form["player1"].value player2 = form["...
{ "deleted": [ { "line_no": 35, "char_start": 1148, "char_end": 1261, "line": " cursor.execute(\"\"\"INSERT INTO games(player1,player2,size) VALUES(\"%s\",\"%s\",%d);\"\"\" % (player1,player2,size))\n" } ], "added": [ { "line_no": 35, "char_start": 1148, "c...
{ "deleted": [ { "char_start": 1234, "char_end": 1236, "chars": " %" } ], "added": [ { "char_start": 1234, "char_end": 1235, "chars": "," } ] }
github.com/russ-lewis/ttt_-_python_cgi/commit/6096f43fd4b2d91211eec4614b7960c0816900da
cgi/create_game.py
cwe-089
clean_cache
def clean_cache(self, limit): """ Method that remove several User objects from cache - the least active users :param limit: number of the users that the method should remove from cache :return: None """ log.info('Figuring out the least active users.....
def clean_cache(self, limit): """ Method that remove several User objects from cache - the least active users :param limit: number of the users that the method should remove from cache :return: None """ log.info('Figuring out the least active users.....
{ "deleted": [ { "line_no": 18, "char_start": 628, "char_end": 663, "line": " f'LIMIT {limit}')\n" }, { "line_no": 21, "char_start": 677, "char_end": 722, "line": " cursor = db.execute_query(query)\n" } ], "added": [ { ...
{ "deleted": [ { "char_start": 653, "char_end": 654, "chars": "{" }, { "char_start": 659, "char_end": 662, "chars": "}')" } ], "added": [ { "char_start": 653, "char_end": 680, "chars": "%s')\n\n parameters = " }, { "cha...
github.com/RandyRomero/photoGPSbot/commit/0e9f57f13e61863b3672f5730e27f149da00786a
photogpsbot/users.py
cwe-089