File size: 195,242 Bytes
133fe23 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | {"problem_id":"cwe-089#2-bf3adb08a70e","input":" def tag_num_to_tag(self, tag_num):\n ''' Returns tag given tag_num. '''\n\n q = \"SELECT tag FROM tags WHERE rowid = '\" + str(tag_num) + \"'\"\n self.query(q)\n return self.c.fetchone()[0]","target":" def tag_num_to_tag(self, tag_num):\n ''' Returns tag given tag_num. '''\n\n q = \"SELECT tag FROM tags WHERE rowid = ?\"\n self.query(q, tag_num)\n return self.c.fetchone()[0]","lang":"python","vul_type":"cwe-089","target_token_count":50,"sven_meta":{"func_name":"tag_num_to_tag","file_name":"modules/query_lastfm.py","commit_link":"github.com/pukkapies/urop2019/commit/3ca2e2c291d2d5fe262d20a8e0520bdfb622432b","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#4-dd9b47234757","input":" def getPostsByPostid(self,postid):\n sqlText=\"select users.name,post.comment from users,post where \\\n users.userid=post.userid and post.postid=%d\"%(postid)\n result=sql.queryDB(self.conn,sqlText)\n return result;","target":" def getPostsByPostid(self,postid):\n sqlText=\"select users.name,post.comment from users,post where \\\n users.userid=post.userid and post.postid=%s\"\n params=[postid]\n result=sql.queryDB(self.conn,sqlText,params)\n return result;","lang":"python","vul_type":"cwe-089","target_token_count":63,"sven_meta":{"func_name":"getPostsByPostid","file_name":"modules/post.py","commit_link":"github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#5-8a3b06cb12b7","input":"\tdef getFileCacheID(self, pth):\n\t\t\"\"\"\n\t\tReturns ID of a cached file on Telegram from DB. None if file doesn't exist or has no cached ID.\n\t\t:param pth:\n\t\t:return:\n\t\t\"\"\"\n\t\tcommand = \"SELECT file_id FROM {0} WHERE path='{1}'\".format(TABLE_NAME, pth)\n\t\tdata = self._run_command(command)\n\n\t\ttry:\n\t\t\tdata = data[0][0]\n\t\texcept IndexError:\n\t\t\tdata = None\n\n\t\treturn data","target":"\tdef getFileCacheID(self, pth):\n\t\t\"\"\"\n\t\tReturns ID of a cached file on Telegram from DB. None if file doesn't exist or has no cached ID.\n\t\t:param pth:\n\t\t:return:\n\t\t\"\"\"\n\t\tcommand = \"SELECT file_id FROM {0} WHERE path=?;\".format(TABLE_NAME)\n\t\tparams = (pth,)\n\t\tdata = self._run_command(command, params)\n\n\t\ttry:\n\t\t\tdata = data[0][0]\n\t\texcept IndexError:\n\t\t\tdata = None\n\n\t\treturn data","lang":"python","vul_type":"cwe-089","target_token_count":110,"sven_meta":{"func_name":"getFileCacheID","file_name":"file_db.py","commit_link":"github.com/Highstaker/Picture-sender-telegram-bot/commit/db4bc6adb41e086418761426ff4958a81c30adca","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#6-bd4ef60952d1","input":"def add_post(content):\n \"\"\"Add a post to the 'database' with the current timestamp.\"\"\"\n db = psycopg2.connect(database=DBNAME)\n c = db.cursor()\n c.execute(\"insert into posts values('%s')\" % content)\n db.commit()\n db.close()","target":"def add_post(content):\n \"\"\"Add a post to the 'database' with the current timestamp.\"\"\"\n db = psycopg2.connect(database=DBNAME)\n c = db.cursor()\n c.execute(\"insert into posts values(%s)\",(content,))\n db.commit()\n db.close()","lang":"python","vul_type":"cwe-089","target_token_count":58,"sven_meta":{"func_name":"add_post","file_name":"vagrant/forum/forumdb.py","commit_link":"github.com/tfalbo/SuzyMakeup/commit/1a5d6ccf02bec303d454f87a6bb39baed30c205f","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#7-2d74566801df","input":"def getSubmissionDateFromDatabase(submission):\n database = sqlite3.connect('database.db')\n cursor = database.cursor()\n return cursor.execute(\"SELECT Date FROM ChallengeRankings WHERE SubmissionID = '\" + str(submission.id) + \"'\").fetchone()[0]\n database.close()","target":"def getSubmissionDateFromDatabase(submission):\n database = sqlite3.connect('database.db')\n cursor = database.cursor()\n return cursor.execute(\"SELECT Date FROM ChallengeRankings WHERE SubmissionID = ?\", [str(submission.id)]).fetchone()[0]\n database.close()","lang":"python","vul_type":"cwe-089","target_token_count":57,"sven_meta":{"func_name":"getSubmissionDateFromDatabase","file_name":"CheckAndPostForSeriesSubmissions.py","commit_link":"github.com/LiquidFun/Reddit-GeoGuessr-Tracking-Bot/commit/0cad2d52e24b05da32789fbc8face7a9999a71f9","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#10-382d839e2a90","input":" def tid_num_to_tag_nums(self, tid_num):\n ''' Returns list of the associated tag_nums to the given tid_num. '''\n\n q = \"SELECT tag FROM tid_tag WHERE tid = '\" + str(tid_num) + \"'\"\n self.query(q)\n return [i[0] for i in self.c.fetchall()]","target":" def tid_num_to_tag_nums(self, tid_num):\n ''' Returns list of the associated tag_nums to the given tid_num. '''\n\n q = \"SELECT tag FROM tid_tag WHERE tid = ?\"\n self.query(q, tid_num)\n return [i[0] for i in self.c.fetchall()]","lang":"python","vul_type":"cwe-089","target_token_count":64,"sven_meta":{"func_name":"tid_num_to_tag_nums","file_name":"modules/query_lastfm.py","commit_link":"github.com/pukkapies/urop2019/commit/3ca2e2c291d2d5fe262d20a8e0520bdfb622432b","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#11-7d944f03d5a9","input":"@app.route('/summary', methods=['GET'])\ndef summary():\n\tif 'username' in session:\n\n\t\tconn = mysql.connect()\n\t\tcursor = conn.cursor()\n\n\t\t#select the maximum score from the results table\n\t\tcursor.execute(\"SELECT courseConcentration FROM results WHERE total = (SELECT MAX(total) FROM (SELECT * FROM results WHERE courseId > 4) Temp) and courseId > 4 and emailAccount='\" + session['username'] + \"'\");\n\t\tcourseConcentration = cursor.fetchone()\n\n\t\treturn render_template('summary.html', courseConcentration = courseConcentration[0])\n\treturn redirect(url_for('login'))","target":"@app.route('/summary', methods=['GET'])\ndef summary():\n\tif 'username' in session:\n\n\t\tconn = mysql.connect()\n\t\tcursor = conn.cursor()\n\n\t\t#select the maximum score from the results table\n\t\tcursor.execute(\"SELECT courseConcentration FROM results WHERE total = (SELECT MAX(total) FROM (SELECT * FROM results WHERE courseId > 4) Temp) and courseId > 4 and emailAccount=%s\", (session['username']));\n\t\tcourseConcentration = cursor.fetchone()\n\n\t\treturn render_template('summary.html', courseConcentration = courseConcentration[0])\n\treturn redirect(url_for('login'))","lang":"python","vul_type":"cwe-089","target_token_count":125,"sven_meta":{"func_name":"summary","file_name":"src/tech_track.py","commit_link":"github.com/CaitlinKennedy/Tech-Track/commit/20ef2d4010f9497b8221524edd0c706e2c6a4147","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#12-20344b74d979","input":"def add_post(content):\n \"\"\"Add a post to the 'database' with the current timestamp.\"\"\"\n conn = psycopg2.connect(\"dbname=forum\")\n cursor = conn.cursor()\n cursor.execute(\"insert into posts values ('%s')\" % content)\n conn.commit()\n conn.close()","target":"def add_post(content):\n \"\"\"Add a post to the 'database' with the current timestamp.\"\"\"\n conn = psycopg2.connect(\"dbname=forum\")\n cursor = conn.cursor()\n one_post = content\n cursor.execute(\"insert into posts values (%s)\", (one_post,))\n conn.commit()\n conn.close()","lang":"python","vul_type":"cwe-089","target_token_count":66,"sven_meta":{"func_name":"add_post","file_name":"forumdb.py","commit_link":"github.com/paulc1600/DB-API-Forum/commit/069700fb4beec79182fff3c556e9cccce3230d6f","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#13-43256aa0c7d5","input":"def delete_playlist(id, db):\n db.execute(\"DELETE FROM playlist where id={id};\".format(id=id))","target":"def delete_playlist(id, db):\n db.execute(\"DELETE FROM playlist where id=%s;\", (id,))","lang":"python","vul_type":"cwe-089","target_token_count":23,"sven_meta":{"func_name":"delete_playlist","file_name":"playlist/playlist_repository.py","commit_link":"github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#14-a8b633af74d5","input":" def writeToDb(self, url):\n try:\n self.cursor.execute(\"INSERT INTO queue (url, visited) VALUES ('{}', '0');\".format(url))\n self.db.commit()\n except Exception as e:\n print(e)","target":" def writeToDb(self, url):\n try:\n self.cursor.execute(\"INSERT INTO queue (url, visited) VALUES (?, '0');\", url)\n self.db.commit()\n except Exception as e:\n print(e)","lang":"python","vul_type":"cwe-089","target_token_count":47,"sven_meta":{"func_name":"writeToDb","file_name":"beta/database.py","commit_link":"github.com/jappe999/WebScraper/commit/46a4e0843aa44d903293637afad53dfcbc37b480","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#16-352a199e5538","input":" @jwt_required\n def delete(self, email):\n \"\"\" Deletes admin with the corresponding email \"\"\"\n return database_utilities.execute_query(f\"\"\"delete from admins where email = '{email}'\"\"\")","target":" @jwt_required\n def delete(self, email):\n \"\"\" Deletes admin with the corresponding email \"\"\"\n return database_utilities.execute_query(f\"\"\"delete from admins where email = %s\"\"\", (email, ))","lang":"python","vul_type":"cwe-089","target_token_count":43,"sven_meta":{"func_name":"delete","file_name":"apis/admins.py","commit_link":"github.com/sgosal2/tiger-boards-backend/commit/4670109dd613df2f2fe7e8403ebd149df2b55485","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#17-8a229c971b24","input":"def delete_playlists_videos(playlist_id, db):\n db.execute(\"DELETE FROM video where playlist_id={playlist_id};\".format(\n playlist_id=playlist_id))","target":"def delete_playlists_videos(playlist_id, db):\n db.execute(\"DELETE FROM video where playlist_id=%s;\", (playlist_id,))","lang":"python","vul_type":"cwe-089","target_token_count":29,"sven_meta":{"func_name":"delete_playlists_videos","file_name":"video/video_repository.py","commit_link":"github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#19-bfbb381c2ad4","input":"def get_first_ranked_month(db, scene, player):\n sql = \"select date from ranks where scene='{}' and player='{}' order by date limit 1;\".format(scene, player)\n res = db.exec(sql)\n date = res[0][0]\n return date","target":"def get_first_ranked_month(db, scene, player):\n sql = \"select date from ranks where scene='{scene}' and player='{player}' order by date limit 1;\"\n args = {'scene': scene, 'player': player}\n res = db.exec(sql, args)\n date = res[0][0]\n return date","lang":"python","vul_type":"cwe-089","target_token_count":71,"sven_meta":{"func_name":"get_first_ranked_month","file_name":"bracket_utils.py","commit_link":"github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#20-3f7708bf024c","input":"@hook.command(adminonly=True)\ndef openPoll(question, reply=None, db=None):\n \"\"\"Creates a new poll.\"\"\"\n if not db_ready: db_init(db)\n try:\n active = db.execute(\"SELECT pollID FROM polls WHERE active = 1\").fetchone()[0]\n if active: \n reply(\"There already is an open poll.\")\n return\n except:\n db.execute(\"INSERT INTO polls (question, active) VALUES ('{}', 1)\".format(question))\n reply(\"Opened new poll: {}\".format(question))\n #reply(\"Poll opened!\")\n return","target":"@hook.command(adminonly=True)\ndef openPoll(question, reply=None, db=None):\n \"\"\"Creates a new poll.\"\"\"\n if not db_ready: db_init(db)\n try:\n active = db.execute(\"SELECT pollID FROM polls WHERE active = 1\").fetchone()[0]\n if active: \n reply(\"There already is an open poll.\")\n return\n except:\n db.execute(\"INSERT INTO polls (question, active) VALUES (?, 1)\", (question,))\n reply(\"Opened new poll: {}\".format(question))\n #reply(\"Poll opened!\")\n return","lang":"python","vul_type":"cwe-089","target_token_count":121,"sven_meta":{"func_name":"openPoll","file_name":"plugins/poll.py","commit_link":"github.com/FrozenPigs/Taigabot/commit/ea9b83a66ae1f0f38a1895f3e8dfa2833d77e3a6","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#22-30cbac8f5530","input":"@app.route('/<page_name>/history/record')\ndef view_page_record(page_name):\n content_id = request.args.get('id')\n 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 page_record = query.namedresult()[0]\n\n return render_template(\n 'page_record.html',\n page_name = page_name,\n page_record = page_record\n )","target":"@app.route('/<page_name>/history/record')\ndef view_page_record(page_name):\n content_id = request.args.get('id')\n query = db.query(\"select page_content.content, page_content.timestamp from page, page_content where page.id = page_content.page_id and page_content.id = $1\", content_id)\n page_record = query.namedresult()[0]\n\n return render_template(\n 'page_record.html',\n page_name = page_name,\n page_record = page_record\n )","lang":"python","vul_type":"cwe-089","target_token_count":103,"sven_meta":{"func_name":"view_page_record","file_name":"server.py","commit_link":"github.com/Pumala/python_wiki_app_redo/commit/65d60747cd8efb05970304234d3bd949d2088e8b","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#23-9d36ff5295e1","input":" def update_inverter(self, inverter_serial, ts, status, etoday, etotal):\n query = '''\n UPDATE Inverters\n SET \n TimeStamp='%s', \n Status='%s', \n eToday='%s',\n eTotal='%s'\n WHERE Serial='%s';\n ''' % (ts, status, etoday, etotal, inverter_serial)\n self.c.execute(query)","target":" def update_inverter(self, inverter_serial, ts, status, etoday, etotal):\n query = '''\n UPDATE Inverters\n SET \n TimeStamp=?, \n Status=?, \n eToday=?,\n eTotal=?\n WHERE Serial=?;\n '''\n self.c.execute(query, (ts, status, etoday, etotal, inverter_serial))","lang":"python","vul_type":"cwe-089","target_token_count":81,"sven_meta":{"func_name":"update_inverter","file_name":"util/database.py","commit_link":"github.com/philipptrenz/s0-bridge/commit/269b48caa05377b7c58c3e6d1622a4429cb5ba65","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#24-71acb5a8ca96","input":"def insert(key, value):\n connection = psycopg2.connect(host=config['HOST'], port=config['PORT'], database=config['NAME'], user=config['USER'], password=config['PASSWORD'])\n cur = connection.cursor()\n try:\n cur.execute(\"insert into reply_map values('{}', '{}')\".format(key, value))\n connection.commit()\n except:\n pass","target":"def insert(key, value):\n connection = psycopg2.connect(host=config['HOST'], port=config['PORT'], database=config['NAME'], user=config['USER'], password=config['PASSWORD'])\n cur = connection.cursor()\n try:\n cur.execute(\"insert into reply_map values(?, ?)\", (key, value))\n connection.commit()\n except:\n pass","lang":"python","vul_type":"cwe-089","target_token_count":73,"sven_meta":{"func_name":"insert","file_name":"db.py","commit_link":"github.com/tadaren/reply_bot/commit/5aeafa7e9597a766992af9ff8189e1f050b6579b","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#25-918235b7b09f","input":" def save_failure_transaction(self, user_id, project_id, money):\n 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 self.db.commit()","target":" def save_failure_transaction(self, user_id, project_id, money):\n self.cursor.execute(\"insert into transactions (project_id,user_id, money, timestamp, state) values (%s, %s, \"\n \"%s, now(), 'failed' )\", (project_id, user_id, money))\n self.db.commit()","lang":"python","vul_type":"cwe-089","target_token_count":68,"sven_meta":{"func_name":"save_failure_transaction","file_name":"backend/transactions/TransactionConnector.py","commit_link":"github.com/JLucka/kickstarter-dev/commit/e2ffa062697e060fdfbd2eccbb89a8c53a569e0b","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#28-8b7246efe51a","input":" def tid_to_tid_num(self, tid):\n ''' Returns tid_num, given tid. '''\n\n q = \"SELECT rowid FROM tids WHERE tid = '\" + tid + \"'\"\n self.query(q)\n return self.c.fetchone()[0]","target":" def tid_to_tid_num(self, tid):\n ''' Returns tid_num, given tid. '''\n\n q = \"SELECT rowid FROM tids WHERE tid = ?\"\n self.query(q, tid)\n return self.c.fetchone()[0]","lang":"python","vul_type":"cwe-089","target_token_count":50,"sven_meta":{"func_name":"tid_to_tid_num","file_name":"modules/query_lastfm.py","commit_link":"github.com/pukkapies/urop2019/commit/3ca2e2c291d2d5fe262d20a8e0520bdfb622432b","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#29-c3bd562d4f46","input":"def get_old_sourcebyinstitution_number(conn, sqlite, sourcebyinstitution):\n \"\"\"\n Get all the old sourcebyinstitution number from the SQLite database.\n \"\"\"\n query = \"\"\"\n SELECT\n titles\n FROM\n history\n WHERE\n sourcebyinstitution = \"%s\"\n ORDER BY\n titles DESC\n LIMIT 1\n \"\"\" % sourcebyinstitution\n\n sqlite.execute(query)\n for record in sqlite:\n old_sourcebyinstitution_number = record[0]\n return old_sourcebyinstitution_number","target":"def get_old_sourcebyinstitution_number(conn, sqlite, sourcebyinstitution):\n \"\"\"\n Get all the old sourcebyinstitution number from the SQLite database.\n \"\"\"\n query = \"\"\"\n SELECT\n titles\n FROM\n history\n WHERE\n sourcebyinstitution = ?\n ORDER BY\n titles DESC\n LIMIT 1\n \"\"\"\n\n sqlite.execute(query, (sourcebyinstitution,))\n for record in sqlite:\n old_sourcebyinstitution_number = record[0]\n return old_sourcebyinstitution_number","lang":"python","vul_type":"cwe-089","target_token_count":107,"sven_meta":{"func_name":"get_old_sourcebyinstitution_number","file_name":"bin/solrcheckup.py","commit_link":"github.com/miku/siskin/commit/7fa398d2fea72bf2e8b4808f75df4b3d35ae959a","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#30-c6c7452a048b","input":"def top_karma(bot, trigger):\n \"\"\"\n Show karma status for the top n number of IRC users.\n \"\"\"\n try:\n top_limit = int(trigger.group(2).strip())\n except ValueError:\n top_limit = 5\n\n query = \"SELECT slug, value FROM nick_values NATURAL JOIN nicknames \\\n WHERE key = 'karma' ORDER BY value DESC LIMIT %d\"\n karmalist = bot.db.execute(query % top_limit).fetchall()\n for user in karmalist:\n bot.say(\"%s == %s\" % (user[0], user[1]))","target":"def top_karma(bot, trigger):\n \"\"\"\n Show karma status for the top n number of IRC users.\n \"\"\"\n try:\n top_limit = int(trigger.group(2).strip())\n except ValueError:\n top_limit = 5\n\n query = \"SELECT slug, value FROM nick_values NATURAL JOIN nicknames \\\n WHERE key = 'karma' ORDER BY value DESC LIMIT ?\"\n karmalist = bot.db.execute(query, str(top_limit)).fetchall()\n for user in karmalist:\n bot.say(\"%s == %s\" % (user[0], user[1]))","lang":"python","vul_type":"cwe-089","target_token_count":127,"sven_meta":{"func_name":"top_karma","file_name":"sopel_modules/karma/karma.py","commit_link":"github.com/OpCode1300/sopel-karma/commit/e4d49f7b3d88f8874c7862392f3f4c2065a25695","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#31-bc6bbc952e37","input":"def retrieve_playlist_by_id(id, db):\n db.execute(\n \"SELECT id, name, video_position from playlist WHERE id={id};\".format(id=id))\n row = db.fetchone()\n return row","target":"def retrieve_playlist_by_id(id, db):\n db.execute(\n \"SELECT id, name, video_position from playlist WHERE id=%s;\", (id,))\n row = db.fetchone()\n return row","lang":"python","vul_type":"cwe-089","target_token_count":41,"sven_meta":{"func_name":"retrieve_playlist_by_id","file_name":"playlist/playlist_repository.py","commit_link":"github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#34-e03b891fa46b","input":" @jwt_required\n def delete(self, user_id):\n \"\"\" Deletes user with the corresponding user_id \"\"\"\n return database_utilities.execute_query(f\"\"\"delete from users where user_id = '{user_id}'\"\"\")","target":" @jwt_required\n def delete(self, user_id):\n \"\"\" Deletes user with the corresponding user_id \"\"\"\n return database_utilities.execute_query(f\"\"\"delete from users where user_id = %s\"\"\", (user_id, ))","lang":"python","vul_type":"cwe-089","target_token_count":47,"sven_meta":{"func_name":"delete","file_name":"apis/users.py","commit_link":"github.com/sgosal2/tiger-boards-backend/commit/4670109dd613df2f2fe7e8403ebd149df2b55485","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#35-77207dc1cf69","input":" def verify_rno(self, rno):\n query = \"SELECT COUNT(rno) FROM rides WHERE rno = {rno}\".format(rno = rno)\n self.cursor.execute(query)\n result = self.cursor.fetchone()\n if (int(result[0]) > 0):\n return True \n else:\n return False","target":" def verify_rno(self, rno):\n self.cursor.execute(\"SELECT COUNT(rno) FROM rides WHERE rno = :rno\", {'rno': rno})\n result = self.cursor.fetchone()\n if (int(result[0]) > 0):\n return True \n else:\n return False","lang":"python","vul_type":"cwe-089","target_token_count":66,"sven_meta":{"func_name":"verify_rno","file_name":"book_rides/book_rides.py","commit_link":"github.com/kenboo98/291-Mini-Project-I/commit/3080ccb687c79c83954ce703faee8fcceec8c9eb","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#37-57f0cdccbac8","input":"def add_language(lang):\n try:\n cur.execute(f\"INSERT INTO language (name) VALUES ('{lang}')\")\n except Exception as e:\n pass\n cur.execute(f\"SELECT language_id FROM language where name='{lang}'\")\n lang_id = cur.fetchone()[0]\n if conn.commit():\n return lang_id\n return lang_id","target":"def add_language(lang):\n try:\n cur.execute(\"INSERT INTO language (name) VALUES (%s)\", (lang, ))\n except Exception as e:\n pass\n cur.execute(\"SELECT language_id FROM language where name=%s\", (lang, ))\n lang_id = cur.fetchone()[0]\n if conn.commit():\n return lang_id\n return lang_id","lang":"python","vul_type":"cwe-089","target_token_count":76,"sven_meta":{"func_name":"add_language","file_name":"app.py","commit_link":"github.com/Elbertbiggs360/dvdrental/commit/ad144ae2a08a332498d0831bc255170d57ba754b","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#38-4e141ada1ca1","input":"def makeJudge(judge):\n\tdb.execute(\"UPDATE players SET Judge = 1 WHERE Name = '%s' COLLATE NOCASE\" % (judge)) \n\tdatabase.commit()","target":"def makeJudge(judge):\n\tdb.execute(\"UPDATE players SET Judge = 1 WHERE Name = ? COLLATE NOCASE\", judge) \n\tdatabase.commit()","lang":"python","vul_type":"cwe-089","target_token_count":32,"sven_meta":{"func_name":"makeJudge","file_name":"plugins/database.py","commit_link":"github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#39-50ee2962ef57","input":"def isValidAdmToken(adm_token):\n conn, c = connectDB()\n req = \"SELECT * from {} where adm_token='{}'\".format(CFG(\"admintoken_table_name\"), adm_token)\n answer = bool(queryOne(c, req))\n closeDB(conn)\n return answer","target":"def isValidAdmToken(adm_token):\n conn, c = connectDB()\n req = \"SELECT * from {} where adm_token=?\".format(CFG(\"admintoken_table_name\"))\n answer = bool(queryOne(c, req, (adm_token,)))\n closeDB(conn)\n return answer","lang":"python","vul_type":"cwe-089","target_token_count":64,"sven_meta":{"func_name":"isValidAdmToken","file_name":"database.py","commit_link":"github.com/FAUSheppy/simple-python-poll/commit/186c5ff5cdf58272e253a1bb432419ee50d93109","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#41-e3f18712cf87","input":" def delete_data(self, session, id):\n self._openContainer(session)\n sid = str(id)\n if (self.idNormalizer is not None):\n sid = self.idNormalizer.process_string(session, str(id))\n query = \"DELETE FROM %s WHERE identifier = '%s';\" % (self.table, sid)\n self._query(query)\n return None","target":" def delete_data(self, session, id):\n self._openContainer(session)\n sid = str(id)\n if (self.idNormalizer is not None):\n sid = self.idNormalizer.process_string(session, str(id))\n query = \"DELETE FROM %s WHERE identifier = $1;\" % (self.table)\n self._query(query, sid)\n return None","lang":"python","vul_type":"cwe-089","target_token_count":78,"sven_meta":{"func_name":"delete_data","file_name":"cheshire3/sql/postgresStore.py","commit_link":"github.com/cheshire3/cheshire3/commit/d350363b4ea10f102c24c8f26d7b76b006323e8e","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#42-8a74bbc6cd76","input":" def user_verify(self):\n eid = self.email\n code = self.password\n if eid.strip() == '':\n return\n if code.strip() == '':\n return\n query = '''select * from usr where email like\\''''+eid+'\\''\n cursor = g.conn.execute(query)\n for row in cursor:\n key = str(row.password)\n if key.strip() == code.strip():\n self.name = str(row.name)\n self.email = eid\n self.id = eid\n self.valid = True\n break","target":" def user_verify(self):\n eid = self.email\n code = self.password\n if eid.strip() == '':\n return\n if code.strip() == '':\n return\n query = 'select * from usr where email like %s'\n cursor = g.conn.execute(query, (eid, ))\n for row in cursor:\n key = str(row.password)\n if key.strip() == code.strip():\n self.name = str(row.name)\n self.email = eid\n self.id = eid\n self.valid = True\n break","lang":"python","vul_type":"cwe-089","target_token_count":114,"sven_meta":{"func_name":"user_verify","file_name":"Web-app/User.py","commit_link":"github.com/Daniel-Bu/w4111-project1/commit/fe04bedc72e62fd4c4ee046a9af29fd81e9b3340","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#43-5b68d6d2ded2","input":"@app.route('/movies/search', methods=['GET', 'POST'])\ndef search_films():\n form = SearchForm()\n if not form.validate_on_submit():\n return render_template('search.html', title='Search for films', form=form)\n search_terms = form.data['term'].split(' ')\n search_string = ' & '.join(search_terms)\n cur.execute(f\"SELECT * FROM film where fulltext @@ to_tsquery('{search_string}')\")\n res = cur.fetchall()\n return render_template('search_results.html', title='Home', res=len(res))","target":"@app.route('/movies/search', methods=['GET', 'POST'])\ndef search_films():\n form = SearchForm()\n if not form.validate_on_submit():\n return render_template('search.html', title='Search for films', form=form)\n search_terms = form.data['term'].split(' ')\n search_string = ' & '.join(search_terms)\n cur.execute(\"SELECT * FROM film where fulltext @@ to_tsquery(%s)\", (search_string, ))\n res = cur.fetchall()\n return render_template('search_results.html', title='Home', res=len(res))","lang":"python","vul_type":"cwe-089","target_token_count":118,"sven_meta":{"func_name":"search_films","file_name":"app.py","commit_link":"github.com/Elbertbiggs360/dvdrental/commit/ad144ae2a08a332498d0831bc255170d57ba754b","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#44-941cab34e61e","input":"def getGameCountInSeriesSoFar(submission):\n database = sqlite3.connect('database.db')\n cursor = database.cursor()\n return cursor.execute(\"SELECT COUNT(*) FROM ChallengeRankings WHERE SeriesTitle = '\" + getTitle(submission) + \"' AND Date <= '\" + getSubmissionDateFromDatabase(submission) + \"'\").fetchone()[0]\n database.close()","target":"def getGameCountInSeriesSoFar(submission):\n database = sqlite3.connect('database.db')\n cursor = database.cursor()\n return cursor.execute(\"SELECT COUNT(*) FROM ChallengeRankings WHERE SeriesTitle = ? AND Date <= ?\", [getTitle(submission), getSubmissionDateFromDatabase(submission)]).fetchone()[0]\n database.close()","lang":"python","vul_type":"cwe-089","target_token_count":71,"sven_meta":{"func_name":"getGameCountInSeriesSoFar","file_name":"CheckAndPostForSeriesSubmissions.py","commit_link":"github.com/LiquidFun/Reddit-GeoGuessr-Tracking-Bot/commit/0cad2d52e24b05da32789fbc8face7a9999a71f9","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#47-712aa7e20399","input":"@endpoints.route(\"/wins\")\ndef wins():\n if db == None:\n init()\n\n player = request.args.get('tag', default=\"christmasmike\")\n sql = \"SELECT * FROM matches WHERE winner = '\"+str(player)+\"' ORDER BY date DESC;\"\n result = db.exec(sql)\n\n result = [str(x) for x in result]\n result = '\\n'.join(result)\n return json.dumps(result)","target":"@endpoints.route(\"/wins\")\ndef wins():\n if db == None:\n init()\n\n player = request.args.get('tag', default=\"christmasmike\")\n sql = \"SELECT * FROM matches WHERE winner = '{player}' ORDER BY date DESC;\"\n args = {'player': player}\n result = db.exec(sql, args)\n\n result = [str(x) for x in result]\n result = '\\n'.join(result)\n return json.dumps(result)","lang":"python","vul_type":"cwe-089","target_token_count":97,"sven_meta":{"func_name":"wins","file_name":"endpoints.py","commit_link":"github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#48-f6eba8e75930","input":" def delete_event(self, event_id):\n sql = \"\"\"DELETE FROM events\n WHERE event_id = {0}\n \"\"\".format(event_id)\n affected_count = self.cur.execute(sql)\n self.conn.commit()\n return affected_count","target":" def delete_event(self, event_id):\n sql = \"\"\"\n DELETE FROM events\n WHERE event_id = %s\n \"\"\"\n affected_count = self.cur.execute(sql, (event_id,))\n self.conn.commit()\n return affected_count","lang":"python","vul_type":"cwe-089","target_token_count":50,"sven_meta":{"func_name":"delete_event","file_name":"db/dbase.py","commit_link":"github.com/jgayfer/spirit/commit/01c846c534c8d3cf6763f8b7444a0efe2caa3799","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#49-5d136fd1fa9b","input":" def add_item(self, item):\n \"\"\"\"Add new item.\"\"\"\n if self.connection:\n self.cursor.execute('insert into item (name, shoppinglistid) values (\"%s\", \"%s\")' % (item[0], item[1]))\n self.connection.commit()","target":" def add_item(self, item):\n \"\"\"\"Add new item.\"\"\"\n if self.connection:\n t = (item[0], item[1], )\n self.cursor.execute('insert into item (name, shoppinglistid) values (?, ?)', t)\n self.connection.commit()","lang":"python","vul_type":"cwe-089","target_token_count":59,"sven_meta":{"func_name":"add_item","file_name":"ecosldb/ecosldb.py","commit_link":"github.com/ecosl-developers/ecosl/commit/8af050a513338bf68ff2a243e4a2482d24e9aa3a","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#51-8af1fe009045","input":"def also_add(name, also):\n db = db_connect()\n cursor = db.cursor()\n try:\n cursor.execute('''\n INSERT INTO isalso(name,also) VALUES('{}','{}')\n '''.format(name, also))\n db.commit()\n logger.debug('added to isalso name {} with value {}'.format(\n name, also))\n db.close()\n except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise","target":"def also_add(name, also):\n db = db_connect()\n cursor = db.cursor()\n try:\n cursor.execute('''\n INSERT INTO isalso(name,also) VALUES(%(name)s,%(also)s)\n ''', (\n name,\n also,\n ))\n db.commit()\n logger.debug('added to isalso name {} with value {}'.format(\n name, also))\n db.close()\n except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise","lang":"python","vul_type":"cwe-089","target_token_count":107,"sven_meta":{"func_name":"also_add","file_name":"KarmaBoi/dbopts.py","commit_link":"github.com/tylarb/KarmaBoi-PCF/commit/c1d00a27d7f6b7eb6f15a3dacd4269654a32c10a","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#52-41de02f62abf","input":" def getCommentsLike(self,commentid):\n sqlText=\"select userid from comment_like where commentid=%d\"%(commentid)\n result=sql.queryDB(self.conn,sqlText)\n return result;","target":" def getCommentsLike(self,commentid):\n sqlText=\"select userid from comment_like where commentid=%s\"\n params=[commentid]\n result=sql.queryDB(self.conn,sqlText,params)\n return result;","lang":"python","vul_type":"cwe-089","target_token_count":48,"sven_meta":{"func_name":"getCommentsLike","file_name":"modules/comment.py","commit_link":"github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#53-31d5e84156ca","input":"def update_theory_base(tag, link):\n theory = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\theory.db\")\n conn = theory.cursor()\n conn.execute(\"insert into \" + str(tag) + \" values (?)\", (str(link), ))\n theory.commit()\n theory.close()","target":"def update_theory_base(tag, link):\n theory = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\theory.db\")\n conn = theory.cursor()\n conn.execute(\"insert into ? values (?)\", (tag, str(link)))\n theory.commit()\n theory.close()","lang":"python","vul_type":"cwe-089","target_token_count":59,"sven_meta":{"func_name":"update_theory_base","file_name":"bases/update.py","commit_link":"github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#56-35db3764183b","input":"def getPlayer(player):\n\tdb.execute(\"SELECT * FROM players WHERE Name = '%s' COLLATE NOCASE\" % player)\n\tplayerstats = dict(db.fetchone())\n\treturn playerstats","target":"def getPlayer(player):\n\tdb.execute(\"SELECT * FROM players WHERE Name = ? COLLATE NOCASE\", player)\n\tplayerstats = dict(db.fetchone())\n\treturn playerstats","lang":"python","vul_type":"cwe-089","target_token_count":32,"sven_meta":{"func_name":"getPlayer","file_name":"plugins/database.py","commit_link":"github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#58-3c746f6afdb9","input":"@app.route('/', methods=['POST'])\ndef login():\n print('login')\n user = str(request.form['username'])\n password = str(request.form['password'])\n cur.execute('SELECT * FROM users WHERE name = \\'{}\\' AND password = \\'{}\\';'.format(user, password))\n response = cur.fetchone()\n if response != None:\n print(response, 'OK')\n return redirect(url_for('enter_test_point'))\n else:\n print(response, 'not OK')\n flash('Invalid login or password')\n return render_template('login.html')","target":"@app.route('/', methods=['POST'])\ndef login():\n print('login')\n user = str(request.form['username'])\n password = str(request.form['password'])\n cur.execute(\"SELECT * FROM users WHERE name = ? AND password = ?;\", [user, password])\n response = cur.fetchone()\n if response != None:\n print(response, 'OK')\n return redirect(url_for('enter_test_point'))\n else:\n print(response, 'not OK')\n flash('Invalid login or password')\n return render_template('login.html')","lang":"python","vul_type":"cwe-089","target_token_count":111,"sven_meta":{"func_name":"login","file_name":"app.py","commit_link":"github.com/ChemiKyle/Waterspots/commit/3f9d5099496336f3f34c48abf0cf55acaaa29011","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#60-22fafc0b298f","input":"def registerPlayer(name):\n \"\"\"Adds a player to the tournament database.\n\n The database assigns a unique serial id number for the player. (This\n should be handled by your SQL database schema, not in your Python code.)\n\n Args:\n name: the player's full name (need not be unique).\n \"\"\"\n conn = connect()\n cursor = conn.cursor()\n cursor.execute(\"INSERT INTO players (name) VALUES ('%s')\" % (name,));\n conn.commit()\n conn.close()","target":"def registerPlayer(name):\n \"\"\"Adds a player to the tournament database.\n\n The database assigns a unique serial id number for the player. (This\n should be handled by your SQL database schema, not in your Python code.)\n\n Args:\n name: the player's full name (need not be unique).\n \"\"\"\n conn = connect()\n cursor = conn.cursor()\n query = \"INSERT INTO players (name) VALUES (%s);\"\n cursor.execute(query, (name,))\n conn.commit()\n conn.close()","lang":"python","vul_type":"cwe-089","target_token_count":109,"sven_meta":{"func_name":"registerPlayer","file_name":"tournament.py","commit_link":"github.com/sarahkcaplan/tournament/commit/40aba5686059f5f398f6323b1483412c56140cc0","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#63-66613e01583d","input":"@login_manager.user_loader\ndef load_user(s_id):\n email = str(s_id)\n query = '''select * from usr where email like\\'''' + email + '\\''\n cursor = g.conn.execute(query)\n user = User()\n for row in cursor:\n user.name = str(row.name)\n user.email = str(row.email)\n break\n return user","target":"@login_manager.user_loader\ndef load_user(s_id):\n email = str(s_id)\n query = 'select * from usr where email like %s'\n cursor = g.conn.execute(query, (email, ))\n user = User()\n for row in cursor:\n user.name = str(row.name)\n user.email = str(row.email)\n break\n return user","lang":"python","vul_type":"cwe-089","target_token_count":77,"sven_meta":{"func_name":"load_user","file_name":"Web-app/Server.py","commit_link":"github.com/Daniel-Bu/w4111-project1/commit/fe04bedc72e62fd4c4ee046a9af29fd81e9b3340","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#64-38b24c4ed282","input":"@mod.route('/delete/<int:cmt_id>', methods=['GET', 'POST'])\ndef delete(cmt_id):\n if request.method == 'GET':\n sql = \"SELECT msg_id FROM comment where cmt_id = %d;\" % (cmt_id)\n cursor.execute(sql)\n m = cursor.fetchone()\n sql = \"DELETE FROM comment where cmt_id = '%d';\" % (cmt_id)\n cursor.execute(sql)\n conn.commit()\n flash('Delete Success!')\n return redirect(url_for('comment.show', msg_id=m[0]))","target":"@mod.route('/delete/<int:cmt_id>', methods=['GET', 'POST'])\ndef delete(cmt_id):\n if request.method == 'GET':\n cursor.execute(\"SELECT msg_id FROM comment where cmt_id = %s;\", (cmt_id,))\n m = cursor.fetchone()\n cursor.execute(\"DELETE FROM comment where cmt_id = %s;\", (cmt_id,))\n conn.commit()\n flash('Delete Success!')\n return redirect(url_for('comment.show', msg_id=m[0]))","lang":"python","vul_type":"cwe-089","target_token_count":105,"sven_meta":{"func_name":"delete","file_name":"flaskr/flaskr/views/comment.py","commit_link":"github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#66-9ad9b65d6bca","input":"\tdef get_secrets(self, from_date_added=0):\n\t\tsecrets = []\n\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\t\t\taes_key, json_id, date_added = cryptlib.eciesDecrypt(row[0], self.privkey), row[1], row[2]\n\t\t\tif aes_key != None:\n\t\t\t\tsecrets.append([aes_key, json_id])\n\t\t\tfrom_date_added = max(from_date_added, date_added)\n\t\treturn (secrets, from_date_added)","target":"\tdef get_secrets(self, from_date_added=0):\n\t\tsecrets = []\n\t\tfor row in self.cursor.execute('SELECT encrypted, json_id, date_added FROM secret WHERE date_added > ? ORDER BY date_added DESC', (from_date_added,)):\n\t\t\taes_key, json_id, date_added = cryptlib.eciesDecrypt(row[0], self.privkey), row[1], row[2]\n\t\t\tif aes_key != None:\n\t\t\t\tsecrets.append([aes_key, json_id])\n\t\t\tfrom_date_added = max(from_date_added, date_added)\n\t\treturn (secrets, from_date_added)","lang":"python","vul_type":"cwe-089","target_token_count":125,"sven_meta":{"func_name":"get_secrets","file_name":"zeromail.py","commit_link":"github.com/imachug/ZeroMailProxy/commit/8f62d024c6c4c957079d147e59f26d15c07dc888","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#68-f422e9c3c8da","input":"@app.route('/lookup_assets')\ndef lookup_assets():\n start = request.args.get('start')\n\n con = psycopg2.connect(**config.POSTGRES)\n cur = con.cursor()\n\n query = \"SELECT aname FROM assets WHERE aname LIKE '\"+start+\"%'\"\n cur.execute(query)\n results = cur.fetchall()\n con.close()\n return jsonify(results)","target":"@app.route('/lookup_assets')\ndef lookup_assets():\n start = request.args.get('start')\n\n con = psycopg2.connect(**config.POSTGRES)\n cur = con.cursor()\n\n query = \"SELECT aname FROM assets WHERE aname LIKE %s\"\n cur.execute(query, (start+'%',))\n results = cur.fetchall()\n con.close()\n return jsonify(results)","lang":"python","vul_type":"cwe-089","target_token_count":77,"sven_meta":{"func_name":"lookup_assets","file_name":"api.py","commit_link":"github.com/VinChain/vinchain-python-api-backend/commit/b78088a551fbb712121269c6eb7f43ede120ff60","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#69-4c36459c11d6","input":"def set_state(chat_id, value):\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\bases\\\\settings.db\")\n conn = settings.cursor()\n conn.execute(\"update users set state ='\" + str(value) + \"' where chat_id = '\" + str(chat_id) + \"'\")\n settings.commit()\n settings.close()","target":"def set_state(chat_id, value):\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\bases\\\\settings.db\")\n conn = settings.cursor()\n conn.execute(\"update users set state = ? where chat_id = ?\", (str(value), str(chat_id)))\n settings.commit()\n settings.close()","lang":"python","vul_type":"cwe-089","target_token_count":67,"sven_meta":{"func_name":"set_state","file_name":"bot.py","commit_link":"github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#71-7a26034d4fa0","input":"def get_tournaments_during_month(db, scene, date):\n y, m, d = date.split('-')\n ym_date = '{}-{}'.format(y, m)\n sql = \"select url, date from matches where scene='{}' and date like '%{}%' group by url, date order by date\".format(scene, ym_date)\n res = db.exec(sql)\n urls = [r[0] for r in res]\n return urls","target":"def get_tournaments_during_month(db, scene, date):\n y, m, d = date.split('-')\n ym_date = '{}-{}'.format(y, m)\n sql = \"select url, date from matches where scene='{scene}' and date like '%{date}%' group by url, date order by date\"\n args = {'scene': scene, 'date': ym_date}\n res = db.exec(sql, args)\n urls = [r[0] for r in res]\n return urls","lang":"python","vul_type":"cwe-089","target_token_count":109,"sven_meta":{"func_name":"get_tournaments_during_month","file_name":"bracket_utils.py","commit_link":"github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#72-aa8db41d95cf","input":" def add_input(self,data):\n connection = self.connect()\n try:\n # The following is a flaw\n query = \"INSERT INTO crimes(description) VALUES ('{}');\".format(data)\n with connection.cursor() as cursor:\n cursor.execute(query)\n connection.commit()\n finally:\n connection.close()","target":" def add_input(self,data):\n connection = self.connect()\n try:\n # The following is a flaw\n query = \"INSERT INTO crimes(description) VALUES (%s);\"\n with connection.cursor() as cursor:\n cursor.execute(query, data)\n connection.commit()\n finally:\n connection.close()","lang":"python","vul_type":"cwe-089","target_token_count":64,"sven_meta":{"func_name":"add_input","file_name":"dbhelper.py","commit_link":"github.com/amrishc/crimemap/commit/51b3d51aa031d7c285295de36f5464d43debf6de","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#74-eaac2f082613","input":" def all_deposits(self,coin):\n sql = \"SELECT * FROM deposits WHERE coin='%s'\" % coin\n self.cursor.execute(sql)\n return self.cursor.fetchall()","target":" def all_deposits(self,coin):\n sql = \"SELECT * FROM deposits WHERE coin='%s'\"\n self.cursor.execute(sql, (coin,))\n return self.cursor.fetchall()","lang":"python","vul_type":"cwe-089","target_token_count":38,"sven_meta":{"func_name":"all_deposits","file_name":"deposit.py","commit_link":"github.com/ktechmidas/garlictipsbot/commit/7c262255f933cb721109ac4be752b5b7599275aa","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#75-4f88d68c214d","input":" def get_user(self):\n if not hasattr(self, '_user'):\n qs = \"select * from account_access where access_token = '%s'\" % self.access_token\n result = self.db.get(qs)\n if result:\n self._user = result\n else:\n self._user = None\n \n return self._user","target":" def get_user(self):\n if not hasattr(self, '_user'):\n qs = \"select * from account_access where access_token = %s\"\n result = self.db.get(qs, self.access_token)\n if result:\n self._user = result\n else:\n self._user = None\n \n return self._user","lang":"python","vul_type":"cwe-089","target_token_count":70,"sven_meta":{"func_name":"get_user","file_name":"src/auth.py","commit_link":"github.com/bonbondirac/tsunami/commit/396cc394bd6daaf0ee9c16b1b55a4082eeaac208","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#77-409860aa86cc","input":"def GameNewPlayed(Played, ID):\n\tdb.execute(\"UPDATE games set GamesPlayed = %i WHERE ID = %i\" % (Played, ID))\n\tdatabase.commit()","target":"def GameNewPlayed(Played, ID):\n\tdb.execute(\"UPDATE games set GamesPlayed = ? WHERE ID = ?\", Played, ID)\n\tdatabase.commit()","lang":"python","vul_type":"cwe-089","target_token_count":31,"sven_meta":{"func_name":"GameNewPlayed","file_name":"plugins/database.py","commit_link":"github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#78-db2fbd13cafe","input":"def insertNPC(name, race,classe,sex,level,image,legit):\n\tc, conn = getConnection()\n\tdate = now()\n\tc.execute(\"INSERT INTO npc VALUES ('\"+date+\"','\"+str(name)+\"','\"+race+\"','\"+classe+\"','\"+sex+\"','\"+str(level)+\"','\"+image+\"','\"+str(legit)+\"')\")\n\tconn.commit()\n\tconn.close()","target":"def insertNPC(name, race,classe,sex,level,image,legit):\n\tc, conn = getConnection()\n\tdate = now()\n\tc.execute(\"INSERT INTO npc VALUES (?,?,?,?,?,?,?,?)\",(date,str(name),race,classe,sex,str(level),image,str(legit)))\n\tconn.commit()\n\tconn.close()","lang":"python","vul_type":"cwe-089","target_token_count":66,"sven_meta":{"func_name":"insertNPC","file_name":"database.py","commit_link":"github.com/DangerBlack/DungeonsAndDragonsMasterBot/commit/63f980c6dff746f5fcf3005d0646b6c24f81cdc0","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#79-27845e1fbbae","input":" def get(self, user_id):\n \"\"\" Fetch data for user with corresponding user_id \"\"\"\n return database_utilities.execute_query(f\"\"\"select * from users where user_id = '{user_id}'\"\"\")","target":" def get(self, user_id):\n \"\"\" Fetch data for user with corresponding user_id \"\"\"\n return database_utilities.execute_query(f\"\"\"select * from users where user_id = %s\"\"\", (user_id, ))","lang":"python","vul_type":"cwe-089","target_token_count":44,"sven_meta":{"func_name":"get","file_name":"apis/users.py","commit_link":"github.com/sgosal2/tiger-boards-backend/commit/4670109dd613df2f2fe7e8403ebd149df2b55485","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#81-e21153be51c6","input":" def insertData(self,userid,post):\n sqlText=\"insert into post(userid,date,comment) \\\n values(%d,current_timestamp(0),'%s');\"%(userid,post);\n result=sql.insertDB(self.conn,sqlText)\n return result;","target":" def insertData(self,userid,post):\n sqlText=\"insert into post(userid,date,comment) \\\n values(%s,current_timestamp(0),%s);\"\n params=[userid,post];\n result=sql.insertDB(self.conn,sqlText,params)\n return result;","lang":"python","vul_type":"cwe-089","target_token_count":60,"sven_meta":{"func_name":"insertData","file_name":"modules/post.py","commit_link":"github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#83-d01a5be2d975","input":" def delete_resultSet(self, session, id):\n self._openContainer(session)\n sid = str(id)\n if (self.idNormalizer is not None):\n sid = self.idNormalizer.process_string(session, sid)\n query = \"DELETE FROM %s WHERE identifier = '%s';\" % (self.table, sid)\n self._query(query)","target":" def delete_resultSet(self, session, id):\n self._openContainer(session)\n sid = str(id)\n if (self.idNormalizer is not None):\n sid = self.idNormalizer.process_string(session, sid)\n query = \"DELETE FROM %s WHERE identifier = $1;\" % (self.table)\n self._query(query, sid)","lang":"python","vul_type":"cwe-089","target_token_count":75,"sven_meta":{"func_name":"delete_resultSet","file_name":"cheshire3/sql/resultSetStore.py","commit_link":"github.com/cheshire3/cheshire3/commit/d350363b4ea10f102c24c8f26d7b76b006323e8e","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#84-8f1fe0bb7e43","input":"def getSeriesDateFromDatabase(submission):\n database = sqlite3.connect('database.db')\n cursor = database.cursor()\n return cursor.execute(\"SELECT StartDate FROM SeriesTracking WHERE SeriesTitle = '\" + str(getTitle(submission)) + \"'\").fetchone()[0]\n database.close()","target":"def getSeriesDateFromDatabase(submission):\n database = sqlite3.connect('database.db')\n cursor = database.cursor()\n return cursor.execute(\"SELECT StartDate FROM SeriesTracking WHERE SeriesTitle = ?\", [getTitle(submission)]).fetchone()[0]\n database.close()","lang":"python","vul_type":"cwe-089","target_token_count":56,"sven_meta":{"func_name":"getSeriesDateFromDatabase","file_name":"CheckAndPostForSeriesSubmissions.py","commit_link":"github.com/LiquidFun/Reddit-GeoGuessr-Tracking-Bot/commit/0cad2d52e24b05da32789fbc8face7a9999a71f9","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#86-1ee430ed7307","input":" def update_date_modified(self):\n sql = \"UPDATE jdk_entries \" + \\\n \"SET date_last_modified = \" + CURRENT_DATESTAMP + \" \" + \\\n \"WHERE jdk_entries.id = '\" + self.entry_id + \"';\"\n \n db_execute(sql)\n\n return None","target":" def update_date_modified(self):\n quote_tuple = CURRENT_DATESTAMP, self.entry_id\n\n sql = \"UPDATE jdk_entries \" + \\\n \"SET date_last_modified = ? \" + \\\n \"WHERE jdk_entries.id = ?;\"\n \n db_execute(sql, quote_tuple)\n\n return None","lang":"python","vul_type":"cwe-089","target_token_count":64,"sven_meta":{"func_name":"update_date_modified","file_name":"entry.py","commit_link":"github.com/peterlebrun/jdk/commit/000238566fbe55ba09676c3d57af04ae207235ae","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#88-91be3fa5617d","input":" def add_input(self, data):\n connection = self.connect()\n try:\n # The following introduces a deliberate security flaw - SQL Injection\n query = \"INSERT INTO crimes (description) VALUES ('{}');\".format(data)\n with connection.cursor() as cursor:\n cursor.execute(query)\n connection.commit()\n finally:\n connection.close()","target":" def add_input(self, data):\n connection = self.connect()\n try:\n # The following introduces a deliberate security flaw - SQL Injection\n query = \"INSERT INTO crimes (description) VALUES (%s);\"\n with connection.cursor() as cursor:\n cursor.execute(query, data)\n connection.commit()\n finally:\n connection.close()","lang":"python","vul_type":"cwe-089","target_token_count":71,"sven_meta":{"func_name":"add_input","file_name":"dbhelper.py","commit_link":"github.com/rwolf527/crimemap/commit/50b0695e0b4c46165e6146f6fac4cd6871d9fdf6","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#90-d10236943389","input":" def login(self, username, password):\n select_query = \"\"\"\n SELECT client_id, username, balance, message\n FROM Clients\n WHERE username = '{}' AND password = '{}'\n LIMIT 1\n \"\"\".format(username, password)\n\n cursor = self.__conn.cursor()\n\n cursor.execute(select_query)\n user = cursor.fetchone()\n\n if(user):\n return Client(user[0], user[1], user[2], user[3])\n else:\n return False","target":" def login(self, username, password):\n select_query = \"\"\"\n SELECT client_id, username, balance, message\n FROM Clients\n WHERE username = ? AND password = ?\n LIMIT 1\n \"\"\"\n\n cursor = self.__conn.cursor()\n\n cursor.execute(select_query, (username, password))\n user = cursor.fetchone()\n\n if(user):\n return Client(user[0], user[1], user[2], user[3])\n else:\n return False","lang":"python","vul_type":"cwe-089","target_token_count":99,"sven_meta":{"func_name":"login","file_name":"Week_9/sql_manager.py","commit_link":"github.com/AnetaStoycheva/Programming101_HackBulgaria/commit/c0d6f4b8fe83a375832845a45952b5153e4c34f3","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#91-75a0e0828b56","input":"def get_current_state(chat_id):\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__))+\"\\\\bases\\\\settings.db\")\n conn = settings.cursor()\n conn.execute(\"select * from users where chat_id = '\" + str(chat_id) + \"'\")\n name = conn.fetchone()\n if name != None:\n return name[4]\n else:\n return False\n settings.close()","target":"def get_current_state(chat_id):\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__))+\"\\\\bases\\\\settings.db\")\n conn = settings.cursor()\n conn.execute(\"select * from users where chat_id = ?\", (str(chat_id),))\n name = conn.fetchone()\n if name != None:\n return name[4]\n else:\n return False\n settings.close()","lang":"python","vul_type":"cwe-089","target_token_count":83,"sven_meta":{"func_name":"get_current_state","file_name":"bot.py","commit_link":"github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#94-1d5a1c85e651","input":"def get_top_popular(top_num):\r\n \"\"\" query the top(top_num) popular articles\r\n top_num => list of [title, count]\r\n \"\"\"\r\n cmd = \"\"\"SELECT title, views FROM articles\r\n INNER JOIN (\r\n SELECT path, count(path) AS views\r\n FROM log GROUP BY log.path\r\n ) AS log\r\n ON log.path = '/article/' || articles.slug\r\n ORDER BY views DESC\r\n LIMIT {}\"\"\".format(top_num)\r\n return execute_query(cmd)","target":"def get_top_popular(top_num):\r\n \"\"\" query the top(top_num) popular articles\r\n top_num => list of [title, count]\r\n \"\"\"\r\n cmd = \"\"\"SELECT title, views FROM articles\r\n INNER JOIN (\r\n SELECT path, count(path) AS views\r\n FROM log GROUP BY log.path\r\n ) AS log\r\n ON log.path = '/article/' || articles.slug\r\n ORDER BY views DESC\r\n LIMIT %s\"\"\"\r\n data = [top_num, ]\r\n return execute_query(cmd, data)","lang":"python","vul_type":"cwe-089","target_token_count":109,"sven_meta":{"func_name":"get_top_popular","file_name":"logAnalyzerDb.py","commit_link":"github.com/thugasin/udacity-homework-logAnalyzer/commit/506f25f9a1caee7f17034adf7c75e0efbc88082b","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#95-93f2b216df9f","input":"@app.route('/<page_name>/edit')\ndef render_page_edit(page_name):\n 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 wiki_page = query.namedresult()\n if len(wiki_page) > 0:\n content = wiki_page[0].content\n else:\n content = \"\"\n return render_template(\n 'edit_page.html',\n page_name = page_name,\n content = content\n )","target":"@app.route('/<page_name>/edit')\ndef render_page_edit(page_name):\n 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)\n wiki_page = query.namedresult()\n if len(wiki_page) > 0:\n content = wiki_page[0].content\n else:\n content = \"\"\n return render_template(\n 'edit_page.html',\n page_name = page_name,\n content = content\n )","lang":"python","vul_type":"cwe-089","target_token_count":120,"sven_meta":{"func_name":"render_page_edit","file_name":"server.py","commit_link":"github.com/Pumala/python_wiki_app_redo/commit/65d60747cd8efb05970304234d3bd949d2088e8b","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#96-6488b69da8a8","input":"def get_monthly_ranks_for_scene(db, scene, tag):\n\n sql = \"SELECT date, rank FROM ranks WHERE scene='{}' AND player='{}'\".format(scene, tag)\n res = db.exec(sql)\n\n res = [r for r in res if played_during_month(db, scene, tag, get_previous_month(r[0]))]\n\n # Build up a dict of {date: rank}\n ranks = {}\n for r in res:\n ranks[r[0]] = r[1]\n\n return ranks","target":"def get_monthly_ranks_for_scene(db, scene, tag):\n\n sql = \"SELECT date, rank FROM ranks WHERE scene='{scene}' AND player='{tag}'\"\n args = {'scene': scene, 'tag': tag}\n res = db.exec(sql, args)\n\n res = [r for r in res if played_during_month(db, scene, tag, get_previous_month(r[0]))]\n\n # Build up a dict of {date: rank}\n ranks = {}\n for r in res:\n ranks[r[0]] = r[1]\n\n return ranks","lang":"python","vul_type":"cwe-089","target_token_count":121,"sven_meta":{"func_name":"get_monthly_ranks_for_scene","file_name":"bracket_utils.py","commit_link":"github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#98-f23974412261","input":" def add_input(self, data):\n connection = self.connect()\n try:\n # The following introduces a deliberate security flaw. \n # See section on SQL injection below\n query = \"INSERT INTO crimes (description) VALUES('{}');\".format(data)\n with connection.cursor() as cursor:\n cursor.execute(query)\n connection.commit()\n finally:\n connection.close()","target":" def add_input(self, data):\n connection = self.connect()\n try:\n # The following introduces a deliberate security flaw. \n # See section on SQL injection below\n query = \"INSERT INTO crimes (description) VALUES(%s);\"\n with connection.cursor() as cursor:\n cursor.execute(query, data)\n connection.commit()\n finally:\n connection.close()","lang":"python","vul_type":"cwe-089","target_token_count":78,"sven_meta":{"func_name":"add_input","file_name":"dbhelper.py","commit_link":"github.com/mudspringhiker/crimemap/commit/35e78962e7288c643cdde0f886ff7aa5ac77cb8c","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#99-354e8983b4ef","input":" def getAllComments(self):\n sqlText=\"select comment from comments where userid=%d order by date;\"\n allposts=sql.queryDB(self.conn,sqlText)\n return allposts;","target":" def getAllComments(self):\n sqlText=\"select comment from comments where userid=%s order by date;\"\n params = [self.userid]\n allposts=sql.queryDB(self.conn,sqlText,params)\n return allposts;","lang":"python","vul_type":"cwe-089","target_token_count":48,"sven_meta":{"func_name":"getAllComments","file_name":"modules/users.py","commit_link":"github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#101-e53fadedf872","input":" def save_accepted_transaction(self, user_id, project_id, money):\n self.cursor.execute(\"update users set money = money - %s where id = %s\"%(money, user_id))\n self.cursor.execute(\"update projects set money = money + %s where id = %s\" % (money, project_id))\n self.cursor.execute(\"insert into transactions (project_id, user_id, money, timestamp, state) values (%s, %s, %s, now(), 'accepted' )\" % (project_id, user_id, money))\n self.db.commit()","target":" def save_accepted_transaction(self, user_id, project_id, money):\n self.cursor.execute(\"update users set money = money - %s where id = %s\", (money, user_id))\n self.cursor.execute(\"update projects set money = money + %s where id = %s\", (money, project_id))\n self.cursor.execute(\"insert into transactions (project_id, user_id, money, timestamp, state) values (%s, %s, \"\n \"%s, now(), 'accepted' )\", (project_id, user_id, money))\n self.db.commit()","lang":"python","vul_type":"cwe-089","target_token_count":121,"sven_meta":{"func_name":"save_accepted_transaction","file_name":"backend/transactions/TransactionConnector.py","commit_link":"github.com/JLucka/kickstarter-dev/commit/e2ffa062697e060fdfbd2eccbb89a8c53a569e0b","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#103-4517a2624d92","input":"def incrementOption(cursor, poll_name, option):\n key = poll_name+\"-\"+option\n req = \"UPDATE {} SET count=count+1 WHERE name_option = '{}';\".format(CFG(\"options_table_name\"), key)\n cursor.execute(req)","target":"def incrementOption(cursor, poll_name, option):\n key = poll_name+\"-\"+option\n req = \"UPDATE {} SET count=count+1 WHERE name_option=?\".format(CFG(\"options_table_name\"))\n cursor.execute(req, (key,))","lang":"python","vul_type":"cwe-089","target_token_count":52,"sven_meta":{"func_name":"incrementOption","file_name":"database.py","commit_link":"github.com/FAUSheppy/simple-python-poll/commit/186c5ff5cdf58272e253a1bb432419ee50d93109","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#105-9e629ea7791a","input":"def addTags(tag_list, listing_id):\n \"\"\"\n Adds a list of tags tag_list for a given listing with listing_id to the database\n \"\"\"\n cur = conn.cursor()\n for x in tag_list:\n sql = \"INSERT INTO {} VALUES {}\".format(listing_tags_table_name, str((listing_id, x)))\n cur.execute(sql)","target":"def addTags(tag_list, listing_id):\n \"\"\"\n Adds a list of tags tag_list for a given listing with listing_id to the database\n \"\"\"\n cur = conn.cursor()\n for x in tag_list:\n sql = \"INSERT INTO %s VALUES (%s %s)\"\n cur.execute(sql, (listing_tags_table_name, listing_id, x))","lang":"python","vul_type":"cwe-089","target_token_count":75,"sven_meta":{"func_name":"addTags","file_name":"backend-api/backend-api.py","commit_link":"github.com/tasbir49/BreadWinner/commit/332a9f2c619be399ae94244bb8bd0977fc62bc16","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#110-a92eab0caf4a","input":" def _checkPairing():\n if winner == loser:\n raise ValueError('Attempt to match player against self')\n\n q = '''\n SELECT COUNT(*) FROM matches\n WHERE (matches.winner_id = %s AND matches.loser_id = %s)\n OR (matches.winner_id = %s AND matches.loser_id = %s);\n ''' % (winner, loser, loser, winner)\n cur.execute(q)\n if cur.fetchone()[0] > 0:\n raise ValueError('Pairing %s, %s already played' % (winner, loser))","target":" def _checkPairing():\n if winner == loser:\n raise ValueError('Attempt to match player against self')\n\n q = '''\n SELECT COUNT(*) FROM matches\n WHERE (matches.winner_id = %s AND matches.loser_id = %s)\n OR (matches.winner_id = %s AND matches.loser_id = %s);\n '''\n cur.execute(q, (winner, loser, loser, winner))\n if cur.fetchone()[0] > 0:\n raise ValueError('Pairing %s, %s already played' % (winner, loser))","lang":"python","vul_type":"cwe-089","target_token_count":120,"sven_meta":{"func_name":"reportMatch._checkPairing","file_name":"vagrant/tournament/tournament.py","commit_link":"github.com/juanchopanza/Tournament/commit/5799aee52d2cabb685800b88977257bd0964d0da","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#112-d55e105d2d54","input":"def create_playlist(name, db):\n db.execute(\n \"INSERT INTO playlist (name, video_position) VALUES('{name}', 0);\".format(name=name))","target":"def create_playlist(name, db):\n db.execute(\n \"INSERT INTO playlist (name, video_position) VALUES(%s, 0);\", (name,))","lang":"python","vul_type":"cwe-089","target_token_count":34,"sven_meta":{"func_name":"create_playlist","file_name":"playlist/playlist_repository.py","commit_link":"github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#115-8264aa047d72","input":" def add_day_data_row(self, ts, data, prev_etotal):\n\n if data['power'] > 0:\n\n inv_serial = data['source']['serial_id']\n query = '''\n INSERT INTO DayData (\n TimeStamp,\n Serial,\n Power,\n TotalYield\n ) VALUES (\n %s,\n %s,\n %s,\n %s\n );\n ''' % (ts, inv_serial, data['power'], prev_etotal + data['energy'])\n self.c.execute(query)","target":" def add_day_data_row(self, ts, data, prev_etotal):\n\n if data['power'] > 0:\n\n inv_serial = data['source']['serial_id']\n query = '''\n INSERT INTO DayData (\n TimeStamp,\n Serial,\n Power,\n TotalYield\n ) VALUES (\n ?,\n ?,\n ?,\n ?\n );\n '''\n self.c.execute(query, (ts, inv_serial, data['power'], prev_etotal + data['energy']))","lang":"python","vul_type":"cwe-089","target_token_count":106,"sven_meta":{"func_name":"add_day_data_row","file_name":"util/database.py","commit_link":"github.com/philipptrenz/s0-bridge/commit/269b48caa05377b7c58c3e6d1622a4429cb5ba65","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#117-b9f77e0cbf51","input":" def get(self, space_id):\n \"\"\" Fetch data for space with the corresponding space_id \"\"\"\n return database_utilities.execute_query(\n f\"\"\"select * from spaces where space_id = '{space_id}'\"\"\")","target":" def get(self, space_id):\n \"\"\" Fetch data for space with the corresponding space_id \"\"\"\n return database_utilities.execute_query(\n f\"\"\"select * from spaces where space_id = %s\"\"\", (space_id, ))","lang":"python","vul_type":"cwe-089","target_token_count":47,"sven_meta":{"func_name":"get","file_name":"apis/spaces.py","commit_link":"github.com/sgosal2/tiger-boards-backend/commit/4670109dd613df2f2fe7e8403ebd149df2b55485","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#118-053bb38c1668","input":"def check(current_num):\n try:\n cursor.execute('SELECT * FROM comics WHERE num=\"%s\"' % current_num)\n except sqlite3.OperationalError:\n cursor.execute('CREATE TABLE comics (num text)')\n return False\n else:\n return False if cursor.fetchone() is None else True","target":"def check(current_num):\n try:\n cursor.execute('SELECT * FROM comics WHERE num=?', (current_num,))\n except sqlite3.OperationalError:\n cursor.execute('CREATE TABLE comics (num text)')\n return False\n else:\n return False if cursor.fetchone() is None else True","lang":"python","vul_type":"cwe-089","target_token_count":62,"sven_meta":{"func_name":"check","file_name":"comics/check_comics.py","commit_link":"github.com/lord63/a_bunch_of_code/commit/c0d67a1312306fd1257c354bfb5d6cac7643aa29","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#119-aa8cdf5aa697","input":"@app.route('/delete_crawl', methods=['POST'])\n@is_logged_in\ndef delete_crawl():\n\n # Get Form Fields\n cid = request.form['cid']\n\n # Create cursor\n cur = mysql.connection.cursor()\n\n # Get user by username\n result = cur.execute(\"DELETE FROM Crawls WHERE cid = %s\" % cid)\n\n # Commit to DB\n mysql.connection.commit()\n\n # Close connection\n cur.close()\n\n # FIXME check if successfull first, return message\n flash('Crawl successfully removed', 'success')\n\n return redirect(url_for('dashboard'))","target":"@app.route('/delete_crawl', methods=['POST'])\n@is_logged_in\ndef delete_crawl():\n\n # Get Form Fields\n cid = request.form['cid']\n\n # Create cursor\n cur = mysql.connection.cursor()\n\n # Get user by username\n result = cur.execute(\"\"\"DELETE FROM Crawls WHERE cid = %s\"\"\" (cid,))\n\n # Commit to DB\n mysql.connection.commit()\n\n # Close connection\n cur.close()\n\n # FIXME check if successfull first, return message\n flash('Crawl successfully removed', 'success')\n\n return redirect(url_for('dashboard'))","lang":"python","vul_type":"cwe-089","target_token_count":125,"sven_meta":{"func_name":"delete_crawl","file_name":"bar.py","commit_link":"github.com/yannvon/table-detection/commit/4bad3673debf0b9491b520f0e22e9186af78c375","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#121-c2f02883f26f","input":"def new_category(category_name):\n try:\n conn = check_heroku_db()\n cur = conn.cursor()\n cur.execute('''INSERT INTO categories (cat_name) VALUES (%s)''', (category_name,))\n conn.commit()\n conn.close()\n\n except psycopg2.DatabaseError as e:\n print('Error %s' % e)\n sys.exit(1)","target":"def new_category(category_name):\n try:\n conn = check_heroku_db()\n cur = conn.cursor()\n\n query = \"INSERT INTO categories (cat_name) VALUES (%s);\"\n data = (category_name,)\n cur.execute(query, data)\n\n conn.commit()\n conn.close()\n\n except psycopg2.DatabaseError as e:\n print('Error %s' % e)\n sys.exit(1)","lang":"python","vul_type":"cwe-089","target_token_count":87,"sven_meta":{"func_name":"new_category","file_name":"db.py","commit_link":"github.com/leeorb321/expenses/commit/f93c0fa4d30787ef16420bfefc52565b98bc7fcf","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#122-32e1ae81428f","input":"def get_first_month(db, scene):\n sql = \"select date from matches where scene='{}' order by date limit 1;\".format(scene)\n res = db.exec(sql)\n date = res[0][0]\n return date","target":"def get_first_month(db, scene):\n sql = \"select date from matches where scene='{scene}' order by date limit 1;\"\n args = {'scene': scene}\n res = db.exec(sql, args)\n date = res[0][0]\n return date","lang":"python","vul_type":"cwe-089","target_token_count":57,"sven_meta":{"func_name":"get_first_month","file_name":"bracket_utils.py","commit_link":"github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#123-d276815aa9c1","input":"def getOptions(poll_name):\n conn, c = connectDB()\n options_str = queryOne(c, \"SELECT options FROM {} WHERE name='{}'\".format(CFG(\"poll_table_name\"), poll_name))\n if options_str == None:\n return None\n options = options_str.split(\",\")\n closeDB(conn)\n return options","target":"def getOptions(poll_name):\n conn, c = connectDB()\n req = \"SELECT options FROM {} WHERE name=?\".format(CFG(\"poll_table_name\"))\n options_str = queryOne(c, req, (poll_name,))\n if options_str == None:\n return None\n options = options_str.split(\",\")\n closeDB(conn)\n return options","lang":"python","vul_type":"cwe-089","target_token_count":75,"sven_meta":{"func_name":"getOptions","file_name":"database.py","commit_link":"github.com/FAUSheppy/simple-python-poll/commit/186c5ff5cdf58272e253a1bb432419ee50d93109","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#124-7de1d7b024ab","input":"def retrieve_last_video_position(playlist_id, db):\n db.execute(\"SELECT max(position) as position from video WHERE playlist_id={playlist_id};\".format(\n playlist_id=playlist_id))\n row = db.fetchone()\n return row['position']","target":"def retrieve_last_video_position(playlist_id, db):\n db.execute(\n \"SELECT max(position) as position from video WHERE playlist_id=%s;\", (playlist_id,))\n row = db.fetchone()\n return row['position']","lang":"python","vul_type":"cwe-089","target_token_count":47,"sven_meta":{"func_name":"retrieve_last_video_position","file_name":"video/video_repository.py","commit_link":"github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#125-1c16c4541341","input":"@app.route('/<page_name>/history')\ndef view_page_history(page_name):\n query = db.query(\"select page_content.timestamp, page_content.id from page, page_content where page.id = page_content.page_id and page.page_name = '%s'\" % page_name)\n page_histories = query.namedresult()\n\n return render_template(\n 'page_history.html',\n page_name = page_name,\n page_histories = page_histories\n )","target":"@app.route('/<page_name>/history')\ndef view_page_history(page_name):\n query = db.query(\"select page_content.timestamp, page_content.id from page, page_content where page.id = page_content.page_id and page.page_name = $1\", page_name)\n page_histories = query.namedresult()\n\n return render_template(\n 'page_history.html',\n page_name = page_name,\n page_histories = page_histories\n )","lang":"python","vul_type":"cwe-089","target_token_count":92,"sven_meta":{"func_name":"view_page_history","file_name":"server.py","commit_link":"github.com/Pumala/python_wiki_app_redo/commit/65d60747cd8efb05970304234d3bd949d2088e8b","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#126-99077d1b890e","input":" def add_input(self, data):\n connection = self.connects()\n try:\n # The following introduces a deliberate security flaw. See section on SQL injecton below\n query = \"INSERT INTO crimes (description) VALUES ('{}');\".format(\n data)\n with connection.cursor() as cursor:\n cursor.execute(query)\n connection.commit()\n finally:\n connection.close()","target":" def add_input(self, data):\n connection = self.connects()\n try:\n # The following introduces a deliberate security flaw. See section on SQL injecton below\n query = \"INSERT INTO crimes (description) VALUES (%s);\"\n with connection.cursor() as cursor:\n cursor.execute(query, data)\n connection.commit()\n finally:\n connection.close()","lang":"python","vul_type":"cwe-089","target_token_count":77,"sven_meta":{"func_name":"add_input","file_name":"dbhelper.py","commit_link":"github.com/JeremiahO/crimemap/commit/c17537fcd7aa4e2a26f7ca5cefaeb356ff646858","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#129-978c8e802e19","input":" def add_translationname(self, trname):\n \"\"\"Add new translation by item name for an item.\"\"\"\n if self.connection:\n for item in self.find_item_name([trname[0], '0']):\n self.cursor.execute('insert into itemtranslation (itemid, itemlanguageid, translation) values (\"%s\", \"%s\", \"%s\")' % (item[0], trname[1], trname[2]))\n self.connection.commit()","target":" def add_translationname(self, trname):\n \"\"\"Add new translation by item name for an item.\"\"\"\n if self.connection:\n for item in self.find_item_name([trname[0], '0']):\n t = (item[0], trname[1], trname[2], )\n self.cursor.execute('insert into itemtranslation (itemid, itemlanguageid, translation) values (?, ?, ?)', t)\n self.connection.commit()","lang":"python","vul_type":"cwe-089","target_token_count":93,"sven_meta":{"func_name":"add_translationname","file_name":"ecosldb/ecosldb.py","commit_link":"github.com/ecosl-developers/ecosl/commit/8af050a513338bf68ff2a243e4a2482d24e9aa3a","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#130-5b17d184e032","input":" @staticmethod\n def get_max_task_id_for_project(project_id: int):\n \"\"\"Gets the nights task id currently in use on a project\"\"\"\n sql = \"\"\"select max(id) from tasks where project_id = {0} GROUP BY project_id\"\"\".format(project_id)\n result = db.engine.execute(sql)\n if result.rowcount == 0:\n raise NotFound()\n for row in result:\n return row[0]","target":" @staticmethod\n def get_max_task_id_for_project(project_id: int):\n \"\"\"Gets the nights task id currently in use on a project\"\"\"\n sql = \"\"\"select max(id) from tasks where project_id = :project_id GROUP BY project_id\"\"\"\n result = db.engine.execute(text(sql), project_id=project_id)\n if result.rowcount == 0:\n raise NotFound()\n for row in result:\n return row[0]","lang":"python","vul_type":"cwe-089","target_token_count":93,"sven_meta":{"func_name":"get_max_task_id_for_project","file_name":"server/models/postgis/task.py","commit_link":"github.com/hotosm/tasking-manager/commit/dee040a2d22b3c4d5e38e2dbf8c6b651ad4c241a","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#133-f284645044bb","input":" def add_input(self,data):\n connection = self.connect()\n\n try:\n query = \"INSERT INTO crimes (description) VALUES ('{}');\".format(data)\n with connection.cursor() as cursor:\n cursor.execute(query)\n connection.commit()\n finally:\n connection.close()","target":" def add_input(self,data):\n connection = self.connect()\n\n try:\n query = \"INSERT INTO crimes (description) VALUES (%s);\"\n with connection.cursor() as cursor:\n cursor.execute(query,data)\n connection.commit()\n finally:\n connection.close()","lang":"python","vul_type":"cwe-089","target_token_count":56,"sven_meta":{"func_name":"add_input","file_name":"dbhelper.py","commit_link":"github.com/sgnab/crime-map-app/commit/209b23bad13594c9cdf18d8788fcba7c8f68d37b","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#137-eb6d2b3ef725","input":"@mod.route('/like/<int:msg_id>', methods=['GET', 'POST'])\ndef like(msg_id):\n if request.method == 'GET':\n user_id = session['logged_id']\n c_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')\n sql = \"INSERT INTO like_msg(msg_id, user_id,c_time) \" + \\\n \"VALUES(%d,'%s','%s');\" % (msg_id, user_id, c_time)\n cursor.execute(sql)\n conn.commit()\n return redirect(url_for('show_entries'))","target":"@mod.route('/like/<int:msg_id>', methods=['GET', 'POST'])\ndef like(msg_id):\n if request.method == 'GET':\n user_id = session['logged_id']\n c_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')\n cursor.execute(\"INSERT INTO like_msg(msg_id, user_id,c_time) VALUES(%s,%s,%s);\", (msg_id, user_id, c_time))\n conn.commit()\n return redirect(url_for('show_entries'))","lang":"python","vul_type":"cwe-089","target_token_count":109,"sven_meta":{"func_name":"like","file_name":"flaskr/flaskr/views/like_msg.py","commit_link":"github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#138-8ef7ae917c04","input":" def tag_to_tag_num(self, tag):\n ''' Returns tag_num given tag. '''\n\n q = \"SELECT rowid FROM tags WHERE tag = '\" + tag + \"'\"\n self.query(q)\n return self.c.fetchone()[0]","target":" def tag_to_tag_num(self, tag):\n ''' Returns tag_num given tag. '''\n\n q = \"SELECT rowid FROM tags WHERE tag = ?\"\n self.query(q, tag)\n return self.c.fetchone()[0]","lang":"python","vul_type":"cwe-089","target_token_count":48,"sven_meta":{"func_name":"tag_to_tag_num","file_name":"modules/query_lastfm.py","commit_link":"github.com/pukkapies/urop2019/commit/3ca2e2c291d2d5fe262d20a8e0520bdfb622432b","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#140-83d4de462eb9","input":" def change_message(self, new_message, logged_user):\n update_sql = \"\"\"\n UPDATE Clients\n SET message = '{}'\n WHERE client_id = '{}'\n \"\"\".format(new_message, logged_user.get_client_id())\n\n cursor = self.__conn.cursor()\n\n cursor.execute(update_sql)\n self.__conn.commit()\n logged_user.set_message(new_message)","target":" def change_message(self, new_message, logged_user):\n update_sql = \"\"\"\n UPDATE Clients\n SET message = ?\n WHERE client_id = ?\n \"\"\"\n\n cursor = self.__conn.cursor()\n\n cursor.execute(update_sql, (new_message, logged_user.get_client_id()))\n self.__conn.commit()\n logged_user.set_message(new_message)","lang":"python","vul_type":"cwe-089","target_token_count":72,"sven_meta":{"func_name":"change_message","file_name":"Week_9/sql_manager.py","commit_link":"github.com/AnetaStoycheva/Programming101_HackBulgaria/commit/c0d6f4b8fe83a375832845a45952b5153e4c34f3","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#141-ed1d1bb0d18f","input":" def create_event(self, title, start_time, time_zone, server_id, description):\n sql = \"\"\"INSERT INTO events (title, start_time, time_zone, server_id, description)\n VALUES ('{0}', '{1}', '{2}', '{3}', '{4}')\n \"\"\".format(title, start_time, time_zone, server_id, description)\n self.cur.execute(sql)\n self.conn.commit()","target":" def create_event(self, title, start_time, time_zone, server_id, description):\n sql = \"\"\"\n INSERT INTO events (title, start_time, time_zone, server_id, description)\n VALUES (%s, %s, %s, %s, %s)\n \"\"\"\n self.cur.execute(sql, (title, start_time, time_zone, server_id, description))\n self.conn.commit()","lang":"python","vul_type":"cwe-089","target_token_count":85,"sven_meta":{"func_name":"create_event","file_name":"db/dbase.py","commit_link":"github.com/jgayfer/spirit/commit/01c846c534c8d3cf6763f8b7444a0efe2caa3799","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#143-faa8f5365ec1","input":"def get_bracket_graph_data(db, tag):\n # First, we have to find out which scenes this player has brackets in\n sql = \"SELECT DISTINCT scene FROM ranks WHERE player='{}'\".format(tag)\n scenes = db.exec(sql)\n scenes = [s[0] for s in scenes]\n\n bracket_placings_by_scene = {s: get_bracket_placings_in_scene(db, s, tag) for s in scenes}\n\n return bracket_placings_by_scene","target":"def get_bracket_graph_data(db, tag):\n # First, we have to find out which scenes this player has brackets in\n sql = \"SELECT DISTINCT scene FROM ranks WHERE player='{tag}'\"\n args = {'tag': tag}\n scenes = db.exec(sql, args)\n scenes = [s[0] for s in scenes]\n\n bracket_placings_by_scene = {s: get_bracket_placings_in_scene(db, s, tag) for s in scenes}\n\n return bracket_placings_by_scene","lang":"python","vul_type":"cwe-089","target_token_count":110,"sven_meta":{"func_name":"get_bracket_graph_data","file_name":"bracket_utils.py","commit_link":"github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#144-aacd766e8705","input":" def get(self, email):\n \"\"\" Fetch data for admin with the corresponding email \"\"\"\n return database_utilities.execute_query(f\"\"\"select * from admins where email = '{email}'\"\"\")","target":" def get(self, email):\n \"\"\" Fetch data for admin with the corresponding email \"\"\"\n return database_utilities.execute_query(f\"\"\"select * from admins where email = %s\"\"\", (email, ))","lang":"python","vul_type":"cwe-089","target_token_count":41,"sven_meta":{"func_name":"get","file_name":"apis/admins.py","commit_link":"github.com/sgosal2/tiger-boards-backend/commit/4670109dd613df2f2fe7e8403ebd149df2b55485","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#145-59731aa4b3d4","input":"def insertUsage(user, command):\n\tc, conn = getConnection()\n\tdate = now()\n\tc.execute(\"INSERT INTO usage (date,user,command) VALUES ('\"+date+\"','\"+str(user)+\"','\"+command+\"')\")\n\tconn.commit()\n\tconn.close()","target":"def insertUsage(user, command):\n\tc, conn = getConnection()\n\tdate = now()\n\tc.execute(\"INSERT INTO usage (date,user,command) VALUES (?,?,?)\",(date,str(user),command))\n\tconn.commit()\n\tconn.close()","lang":"python","vul_type":"cwe-089","target_token_count":46,"sven_meta":{"func_name":"insertUsage","file_name":"database.py","commit_link":"github.com/DangerBlack/DungeonsAndDragonsMasterBot/commit/63f980c6dff746f5fcf3005d0646b6c24f81cdc0","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#146-cb6f56984dbe","input":" def verify_email(self, member):\n query = \"SELECT COUNT(email) FROM members WHERE email = '{email}'\".format(email = member)\n self.cursor.execute(query)\n result = self.cursor.fetchone()\n if (int(result[0]) > 0):\n return True \n else:\n return False","target":" def verify_email(self, member):\n self.cursor.execute(\"SELECT COUNT(email) FROM members WHERE email = ':email'\", {'email':member})\n result = self.cursor.fetchone()\n if (int(result[0]) > 0):\n return True \n else:\n return False","lang":"python","vul_type":"cwe-089","target_token_count":59,"sven_meta":{"func_name":"verify_email","file_name":"book_rides/book_rides.py","commit_link":"github.com/kenboo98/291-Mini-Project-I/commit/3080ccb687c79c83954ce703faee8fcceec8c9eb","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#147-f53b171ae350","input":" def get_previous_yields(self, inverter_serial):\n query = '''\n SELECT TimeStamp, EToday, ETotal\n FROM Inverters\n WHERE Serial = '%s'\n ''' % (inverter_serial)\n self.c.execute(query)\n data = self.c.fetchone()\n return data[0], data[1], data[2]","target":" def get_previous_yields(self, inverter_serial):\n query = '''\n SELECT TimeStamp, EToday, ETotal\n FROM Inverters\n WHERE Serial=?\n '''\n self.c.execute(query, (inverter_serial,))\n data = self.c.fetchone()\n return data[0], data[1], data[2]","lang":"python","vul_type":"cwe-089","target_token_count":72,"sven_meta":{"func_name":"get_previous_yields","file_name":"util/database.py","commit_link":"github.com/philipptrenz/s0-bridge/commit/269b48caa05377b7c58c3e6d1622a4429cb5ba65","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#150-d0ae70bbe631","input":"def get_article(index):\n with conn.cursor(cursor_factory=DictCursor) as cur:\n query = \"SELECT * FROM articles WHERE index=\"+str(index)\n cur.execute(query)\n article = cur.fetchone()\n return article","target":"def get_article(index):\n with conn.cursor(cursor_factory=DictCursor) as cur:\n query = \"SELECT * FROM articles WHERE index=%s\"\n cur.execute(query, (index, ))\n article = cur.fetchone()\n return article","lang":"python","vul_type":"cwe-089","target_token_count":49,"sven_meta":{"func_name":"get_article","file_name":"app.py","commit_link":"github.com/sepehr125/arxiv-doc2vec-recommender/commit/f23a4c32e6192b145017f64734b0a9a384c9123a","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#152-121b5a564d34","input":"def closeGame(ID):\n\tdb.execute(\"UPDATE games set Running = 'No' WHERE ID = %i\" % ID)\n\tdatabase.commit()","target":"def closeGame(ID):\n\tdb.execute(\"UPDATE games set Running = 'No' WHERE ID = ?\", ID)\n\tdatabase.commit()","lang":"python","vul_type":"cwe-089","target_token_count":26,"sven_meta":{"func_name":"closeGame","file_name":"plugins/database.py","commit_link":"github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#153-ff692efe12c8","input":" def cancelFollow(self,userid,friendid):\n sqlText=\"delete from friends where userid=%d and friendid=%d;\"%(userid,friendid)\n result=sql.deleteDB(self.conn,sqlText)\n return result;","target":" def cancelFollow(self,userid,friendid):\n sqlText=\"delete from friends where userid=%d and friendid=%s;\"\n params=[userid,friendid]\n result=sql.deleteDB(self.conn,sqlText,params)\n return result;","lang":"python","vul_type":"cwe-089","target_token_count":53,"sven_meta":{"func_name":"cancelFollow","file_name":"modules/users.py","commit_link":"github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#154-3f53476e4249","input":" def change_pass(self, new_pass, logged_user):\n update_sql = \"\"\"\n UPDATE Clients\n SET password = '{}'\n WHERE client_id = '{}'\n \"\"\".format(new_pass, logged_user.get_client_id())\n\n cursor = self.__conn.cursor()\n\n cursor.execute(update_sql)\n self.__conn.commit()","target":" def change_pass(self, new_pass, logged_user):\n update_sql = \"\"\"\n UPDATE Clients\n SET password = ?\n WHERE client_id = ?\n \"\"\"\n\n cursor = self.__conn.cursor()\n\n cursor.execute(update_sql, (new_pass, logged_user.get_client_id()))\n self.__conn.commit()","lang":"python","vul_type":"cwe-089","target_token_count":64,"sven_meta":{"func_name":"change_pass","file_name":"Week_9/sql_manager.py","commit_link":"github.com/AnetaStoycheva/Programming101_HackBulgaria/commit/c0d6f4b8fe83a375832845a45952b5153e4c34f3","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#155-a938efe96c71","input":" def getCommentsByPostid(self,postid,userid):\n sqlText=\"select (select Count(*) from comment_like where comments.commentid = comment_like.commentid) as like,(select Count(*) from comment_like where comments.commentid = comment_like.commentid and comment_like.userid=%d) as flag,commentid,name,comment from users,comments where users.userid=comments.userid and postid=%d order by date desc;\"%(userid,postid)\n result=sql.queryDB(self.conn,sqlText)\n return result;","target":" def getCommentsByPostid(self,postid,userid):\n sqlText=\"select (select Count(*) from comment_like where \\\n comments.commentid = comment_like.commentid) as like,(select Count(*) \\\n from comment_like where comments.commentid = \\\n comment_like.commentid and comment_like.userid=%s) as \\\n flag,commentid,name,comment from users,comments where \\\n users.userid=comments.userid and postid=%s order by date desc;\"\n params=[userid,postid]\n result=sql.queryDB(self.conn,sqlText,params)\n return result;","lang":"python","vul_type":"cwe-089","target_token_count":124,"sven_meta":{"func_name":"getCommentsByPostid","file_name":"modules/comment.py","commit_link":"github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#157-d60196f172a8","input":" @jwt_required\n def patch(self, user_id):\n \"\"\" Replaces information of corresponding user_id with request body \"\"\"\n query = f\"\"\"update users set user_id = %s \"\"\"\n query += f\"\"\"where user_id = '{user_id}'\"\"\"\n json_data = request.get_json()\n parameters = (json_data['user_id'], )\n database_utilities.execute_query(query, parameters)","target":" @jwt_required\n def patch(self, user_id):\n \"\"\" Replaces information of corresponding user_id with request body \"\"\"\n query = f\"\"\"update users set user_id = %s \"\"\"\n query += f\"\"\"where user_id = %s\"\"\"\n json_data = request.get_json()\n parameters = (json_data['user_id'], user_id)\n database_utilities.execute_query(query, parameters)","lang":"python","vul_type":"cwe-089","target_token_count":82,"sven_meta":{"func_name":"patch","file_name":"apis/users.py","commit_link":"github.com/sgosal2/tiger-boards-backend/commit/4670109dd613df2f2fe7e8403ebd149df2b55485","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#160-97ca5316fd5e","input":" def can_user_pass_that_amount_of_money(self, user_id, money):\n self.cursor.execute(\"SELECT count(id) FROM kickstarter.users where id = %s and money >= %s\" % (user_id, money))\n return self.cursor.fetchall()[0][0]","target":" def can_user_pass_that_amount_of_money(self, user_id, money):\n self.cursor.execute(\"SELECT count(id) FROM kickstarter.users where id = %s and money >= %s\", (user_id, money))\n return self.cursor.fetchall()[0][0]","lang":"python","vul_type":"cwe-089","target_token_count":56,"sven_meta":{"func_name":"can_user_pass_that_amount_of_money","file_name":"backend/transactions/TransactionConnector.py","commit_link":"github.com/JLucka/kickstarter-dev/commit/e2ffa062697e060fdfbd2eccbb89a8c53a569e0b","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#161-c2c31e5ac593","input":"@endpoints.route(\"/placings\")\ndef placings():\n if db == None:\n init()\n\n tag = request.args.get('tag', default='christmas mike')\n\n # Get all the urls that this player has participated in\n sql = \"SELECT * FROM placings WHERE player = '{}'\".format(tag)\n results = list(db.exec(sql))\n results.sort(key=lambda x: int(x[2]))\n\n return json.dumps(results)","target":"@endpoints.route(\"/placings\")\ndef placings():\n if db == None:\n init()\n\n tag = request.args.get('tag', default='christmas mike')\n\n # Get all the urls that this player has participated in\n sql = \"SELECT * FROM placings WHERE player = '{tag}'\"\n args = {'tag': tag}\n results = list(db.exec(sql, args))\n results.sort(key=lambda x: int(x[2]))\n\n return json.dumps(results)","lang":"python","vul_type":"cwe-089","target_token_count":101,"sven_meta":{"func_name":"placings","file_name":"endpoints.py","commit_link":"github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#162-ba9a72bb9ac5","input":"def markTokenUsedExternal(token, optStr=\"\"):\n conn, c = connectDB()\n req = \"UPDATE {} SET \\\"options_selected\\\"='{}' WHERE token='{}'\".format(CFG(\"tokens_table_name\"), \\\n optStr, token)\n c.execute(req)\n closeDB(conn)","target":"def markTokenUsedExternal(token, optStr=\"\"):\n conn, c = connectDB()\n req = \"UPDATE {} SET \\\"options_selected\\\"=? WHERE token=?\".format(CFG(\"tokens_table_name\"))\n c.execute(req, (optStr, token,))\n closeDB(conn)","lang":"python","vul_type":"cwe-089","target_token_count":59,"sven_meta":{"func_name":"markTokenUsedExternal","file_name":"database.py","commit_link":"github.com/FAUSheppy/simple-python-poll/commit/186c5ff5cdf58272e253a1bb432419ee50d93109","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#163-a2f6b9569969","input":" def get_roster(self, server_id):\n sql = \"\"\"SELECT username, role\n FROM roles\n WHERE roles.server_id = {0};\n \"\"\".format(server_id)\n self.cur.execute(sql)\n return self.cur.fetchall()","target":" def get_roster(self, server_id):\n sql = \"\"\"\n SELECT username, role\n FROM roles\n WHERE roles.server_id = %s;\n \"\"\"\n self.cur.execute(sql, (server_id,))\n return self.cur.fetchall()","lang":"python","vul_type":"cwe-089","target_token_count":51,"sven_meta":{"func_name":"get_roster","file_name":"db/dbase.py","commit_link":"github.com/jgayfer/spirit/commit/01c846c534c8d3cf6763f8b7444a0efe2caa3799","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#164-704addd83613","input":"def retrieve_video(id, playlist_id, db):\n db.execute(\"SELECT id, position from video WHERE id={id} and playlist_id={playlist_id};\".format(\n id=id, playlist_id=playlist_id))\n row = db.fetchone()\n return row","target":"def retrieve_video(id, playlist_id, db):\n db.execute(\n \"SELECT id, position from video WHERE id=%s and playlist_id=%s;\", (id, playlist_id))\n row = db.fetchone()\n return row","lang":"python","vul_type":"cwe-089","target_token_count":47,"sven_meta":{"func_name":"retrieve_video","file_name":"video/video_repository.py","commit_link":"github.com/Madmous/playlist/commit/666e52c5f0b8c1f4296e84471637033d9542a7a6","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#165-a207f8dcff0d","input":" def followFriends(self,userid,friendid):\n sqlText=\"insert into friends values(%d,%d);\"%(friendid,userid)\n result=sql.insertDB(self.conn,sqlText)\n return result;","target":" def followFriends(self,userid,friendid):\n sqlText=\"insert into friends values(%s,%s);\"\n params=[friendid,userid]\n result=sql.insertDB(self.conn,sqlText,params)\n return result;","lang":"python","vul_type":"cwe-089","target_token_count":50,"sven_meta":{"func_name":"followFriends","file_name":"modules/users.py","commit_link":"github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#166-70853c3b7e16","input":"def getGameID(ID):\n\tdb.execute(\"SELECT * FROM games WHERE ID = %i\" % ID)\n\tID = db.fetchone()\n\treturn ID","target":"def getGameID(ID):\n\tdb.execute(\"SELECT * FROM games WHERE ID = ?\", ID)\n\tID = db.fetchone()\n\treturn ID","lang":"python","vul_type":"cwe-089","target_token_count":26,"sven_meta":{"func_name":"getGameID","file_name":"plugins/database.py","commit_link":"github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#168-93edba788617","input":" def userLogin(self):\n\n sqlName=\"select count(*) from users where name='%s' and \\\n password='%s';\"%(self.name,self.password)\n checkName=sql.queryDB(self.conn,sqlName)\n\n result=checkName[0][0]\n if result == 0:\n self.clean()\n return False\n else:\n return True","target":" def userLogin(self):\n\n sqlName=\"select count(*) from users where name=%s and password=%s;\"\n params = [self.name,self.password]\n checkName=sql.queryDB(self.conn,sqlName,params)\n result=checkName[0][0]\n if result == 0:\n self.clean()\n return False\n else:\n return True","lang":"python","vul_type":"cwe-089","target_token_count":78,"sven_meta":{"func_name":"userLogin","file_name":"modules/users.py","commit_link":"github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#169-e459b0e2f2e9","input":"@app.route(\"/search\", methods = [\"POST\"])\ndef search_pages():\n search = request.form.get(\"search\")\n page = db.query(\"select title from page where title = '%s'\" % search).namedresult()\n if len(page) == 0:\n return redirect(\"/%s\" % search)\n else:\n return place_holder(search)","target":"@app.route(\"/search\", methods = [\"POST\"])\ndef search_pages():\n search = request.form.get(\"search\")\n page = db.query(\"select title from page where title = $1\", search).namedresult()\n if len(page) == 0:\n return redirect(\"/%s\" % search)\n else:\n return place_holder(search)","lang":"python","vul_type":"cwe-089","target_token_count":72,"sven_meta":{"func_name":"search_pages","file_name":"server.py","commit_link":"github.com/jcortes0309/wiki_flask/commit/a6bf5316abe2eb528adf36c8241a013fd02c5ffa","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#170-142e3022677a","input":"def get_articles_by_subject(subject):\n with conn.cursor(cursor_factory=DictCursor) as cur:\n query = \"SELECT * FROM articles WHERE subject='\" + subject + \"' ORDER BY last_submitted DESC\"\n cur.execute(query)\n articles = cur.fetchall()\n return articles","target":"def get_articles_by_subject(subject):\n with conn.cursor(cursor_factory=DictCursor) as cur:\n query = \"SELECT * FROM articles WHERE subject=%s ORDER BY last_submitted DESC\"\n cur.execute(query, (subject,))\n articles = cur.fetchall()\n return articles","lang":"python","vul_type":"cwe-089","target_token_count":56,"sven_meta":{"func_name":"get_articles_by_subject","file_name":"app.py","commit_link":"github.com/sepehr125/arxiv-doc2vec-recommender/commit/f23a4c32e6192b145017f64734b0a9a384c9123a","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#171-fa88934a0d73","input":" def getQueue(self, numberOfLinks=10):\n self.cursor.execute(\"SELECT url FROM queue WHERE visited = '0' LIMIT {};\".format(numberOfLinks))\n result = self.cursor.fetchall()\n self.remove(result)\n return result","target":" def getQueue(self, numberOfLinks=10):\n self.cursor.execute(\"SELECT url FROM queue WHERE visited = '0' LIMIT ?;\", numberOfLinks)\n result = self.cursor.fetchall()\n self.remove(result)\n return result","lang":"python","vul_type":"cwe-089","target_token_count":48,"sven_meta":{"func_name":"getQueue","file_name":"beta/database.py","commit_link":"github.com/jappe999/WebScraper/commit/46a4e0843aa44d903293637afad53dfcbc37b480","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#175-daa6fec1e08c","input":"@mod.route('/test', methods=['GET', 'POST'])\ndef test():\n user_id = session['logged_id']\n sql = 'SELECT * FROM message where user_id = %d ORDER BY c_time DESC' \\\n % (user_id)\n cursor.execute(sql)\n m = cursor.fetchall()\n print(m)","target":"@mod.route('/test', methods=['GET', 'POST'])\ndef test():\n user_id = session['logged_id']\n cursor.execute('SELECT * FROM message where user_id = %s ORDER BY c_time DESC', (user_id,))\n m = cursor.fetchall()\n print(m)","lang":"python","vul_type":"cwe-089","target_token_count":59,"sven_meta":{"func_name":"test","file_name":"flaskr/flaskr/views/message.py","commit_link":"github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#177-079aaccfc020","input":" def on_save(self):\n connection = get_connection()\n cursor = connection.cursor()\n cursor.execute(\n f\"insert into visitors (ip_address, user_agent, referrer, full_path, visit_time) values ('{self.ip_address}', '{self.user_agent}', '{self.referrer}', '{self.full_path}', '{self.visit_time}');\")\n connection.commit()\n connection.close()\n return 0","target":" def on_save(self):\n connection = get_connection()\n cursor = connection.cursor()\n cursor.execute(\n \"insert into visitors (ip_address, user_agent, referrer, full_path, visit_time) values (%s, %s, %s, %s, %s);\",\n (str(self.ip_address), str(self.user_agent), str(self.referrer), str(self.full_path), self.visit_time))\n connection.commit()\n connection.close()\n return 0","lang":"python","vul_type":"cwe-089","target_token_count":98,"sven_meta":{"func_name":"on_save","file_name":"experimental/python/buford/model/visitor.py","commit_link":"github.com/onewyoming/onewyoming/commit/54fc7b076fda2de74eeb55e6b75b28e09ef231c2","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#180-153fe52c7749","input":" def deletePost(self,postid):\n sqlText=\"delete from post where post.postid=%d\"%(postid)\n result=sql.deleteDB(self.conn,sqlText)\n return result;","target":" def deletePost(self,postid):\n sqlText=\"delete from post where post.postid=%s\"\n params=[postid]\n result=sql.deleteDB(self.conn,sqlText,params)\n return result;","lang":"python","vul_type":"cwe-089","target_token_count":46,"sven_meta":{"func_name":"deletePost","file_name":"modules/post.py","commit_link":"github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#182-9840664644de","input":" def update_title(self, title = None):\n if (not self.title):\n self.title = title\n\n # This will fall to a sql injection \n sql = \"UPDATE jdk_entries SET title = '\" + self.title + \"'\" + \\\n \"WHERE jdk_entries.id = '\" + self.entry_id + \"';\" \n\n db_execute(sql)\n \n self.update_date_modified()\n\n return None","target":" def update_title(self, title = None):\n if (not self.title):\n self.title = title\n\n quote_tuple = self.title, self.entry_id\n\n # This will fall to a sql injection \n sql = \"UPDATE jdk_entries SET title = ?\" + \\\n \"WHERE jdk_entries.id = ?;\" \n\n db_execute(sql, quote_tuple)\n \n self.update_date_modified()\n\n return None","lang":"python","vul_type":"cwe-089","target_token_count":88,"sven_meta":{"func_name":"update_title","file_name":"entry.py","commit_link":"github.com/peterlebrun/jdk/commit/000238566fbe55ba09676c3d57af04ae207235ae","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-089#183-6943827e6f69","input":" def add_language(self, language):\n \"\"\"\"Add new language for item translations.\"\"\"\n if self.connection:\n self.cursor.execute('insert into itemlanguage (language) values (\"%s\")' % language[0])\n self.connection.commit()","target":" def add_language(self, language):\n \"\"\"\"Add new language for item translations.\"\"\"\n if self.connection:\n t = (language[0], )\n self.cursor.execute('insert into itemlanguage (language) values (?)', t)\n self.connection.commit()","lang":"python","vul_type":"cwe-089","target_token_count":54,"sven_meta":{"func_name":"add_language","file_name":"ecosldb/ecosldb.py","commit_link":"github.com/ecosl-developers/ecosl/commit/8af050a513338bf68ff2a243e4a2482d24e9aa3a","source_cwe_file":"cwe-089.jsonl"}}
{"problem_id":"cwe-125#17-ba0354c92804","input":"static inline size_t GetPSDRowSize(Image *image)\n{\n if (image->depth == 1)\n return((image->columns+7)/8);\n else\n return(image->columns*GetPSDPacketSize(image));\n}","target":"static inline size_t GetPSDRowSize(Image *image)\n{\n if (image->depth == 1)\n return(((image->columns+7)/8)*GetPSDPacketSize(image));\n else\n return(image->columns*GetPSDPacketSize(image));\n}","lang":"c","vul_type":"cwe-125","target_token_count":59,"sven_meta":{"func_name":"GetPSDRowSize","file_name":"coders/psd.c","commit_link":"github.com/ImageMagick/ImageMagick/commit/5f16640725b1225e6337c62526e6577f0f88edb8","source_cwe_file":"cwe-125.jsonl"}}
{"problem_id":"cwe-125#44-66e9d87c6a51","input":"matchCurrentInput(\n\t\tconst InString *input, int pos, const widechar *passInstructions, int passIC) {\n\tint k;\n\tint kk = pos;\n\tfor (k = passIC + 2; k < passIC + 2 + passInstructions[passIC + 1]; k++)\n\t\tif (input->chars[kk] == ENDSEGMENT || passInstructions[k] != input->chars[kk++])\n\t\t\treturn 0;\n\treturn 1;\n}","target":"matchCurrentInput(\n\t\tconst InString *input, int pos, const widechar *passInstructions, int passIC) {\n\tint k;\n\tint kk = pos;\n\tfor (k = passIC + 2;\n\t\t\t((k < passIC + 2 + passInstructions[passIC + 1]) && (kk < input->length));\n\t\t\tk++)\n\t\tif (input->chars[kk] == ENDSEGMENT || passInstructions[k] != input->chars[kk++])\n\t\t\treturn 0;\n\treturn 1;\n}","lang":"c","vul_type":"cwe-125","target_token_count":111,"sven_meta":{"func_name":"matchCurrentInput","file_name":"liblouis/lou_translateString.c","commit_link":"github.com/liblouis/liblouis/commit/5e4089659bb49b3095fa541fa6387b4c40d7396e","source_cwe_file":"cwe-125.jsonl"}}
{"problem_id":"cwe-125#55-f5c736a5c6b9","input":"int pure_strcmp(const char * const s1, const char * const s2)\n{\n return pure_memcmp(s1, s2, strlen(s1) + 1U);\n}","target":"int pure_strcmp(const char * const s1, const char * const s2)\n{\n const size_t s1_len = strlen(s1);\n const size_t s2_len = strlen(s2);\n\n if (s1_len != s2_len) {\n return -1;\n }\n return pure_memcmp(s1, s2, s1_len);\n}","lang":"c","vul_type":"cwe-125","target_token_count":77,"sven_meta":{"func_name":"pure_strcmp","file_name":"src/utils.c","commit_link":"github.com/jedisct1/pure-ftpd/commit/36c6d268cb190282a2c17106acfd31863121b58e","source_cwe_file":"cwe-125.jsonl"}}
{"problem_id":"cwe-125#62-daf50b8865a3","input":"static void rtc_irq_eoi_tracking_reset(struct kvm_ioapic *ioapic)\n{\n\tioapic->rtc_status.pending_eoi = 0;\n\tbitmap_zero(ioapic->rtc_status.dest_map.map, KVM_MAX_VCPUS);\n}","target":"static void rtc_irq_eoi_tracking_reset(struct kvm_ioapic *ioapic)\n{\n\tioapic->rtc_status.pending_eoi = 0;\n\tbitmap_zero(ioapic->rtc_status.dest_map.map, KVM_MAX_VCPU_ID);\n}","lang":"c","vul_type":"cwe-125","target_token_count":53,"sven_meta":{"func_name":"rtc_irq_eoi_tracking_reset","file_name":"arch/x86/kvm/ioapic.c","commit_link":"github.com/torvalds/linux/commit/81cdb259fb6d8c1c4ecfeea389ff5a73c07f5755","source_cwe_file":"cwe-125.jsonl"}}
{"problem_id":"cwe-125#76-d3549ed8811e","input":"ssize_t enc_untrusted_read(int fd, void *buf, size_t count) {\n return static_cast<ssize_t>(EnsureInitializedAndDispatchSyscall(\n asylo::system_call::kSYS_read, fd, buf, count));\n}","target":"ssize_t enc_untrusted_read(int fd, void *buf, size_t count) {\n ssize_t ret = static_cast<ssize_t>(EnsureInitializedAndDispatchSyscall(\n asylo::system_call::kSYS_read, fd, buf, count));\n if (ret != -1 && ret > count) {\n ::asylo::primitives::TrustedPrimitives::BestEffortAbort(\n \"enc_untrusted_read: read result exceeds requested\");\n }\n return ret;\n}","lang":"cpp","vul_type":"cwe-125","target_token_count":104,"sven_meta":{"func_name":"enc_untrusted_read","file_name":"asylo/platform/host_call/trusted/host_calls.cc","commit_link":"github.com/google/asylo/commit/b1d120a2c7d7446d2cc58d517e20a1b184b82200","source_cwe_file":"cwe-125.jsonl"}}
{"problem_id":"cwe-125#95-aa73fa6e51f7","input":"const TfLiteTensor* GetOptionalInputTensor(const TfLiteContext* context,\n const TfLiteNode* node, int index) {\n const bool use_tensor = index < node->inputs->size &&\n node->inputs->data[index] != kTfLiteOptionalTensor;\n if (use_tensor) {\n return GetMutableInput(context, node, index);\n }\n return nullptr;\n}","target":"const TfLiteTensor* GetOptionalInputTensor(const TfLiteContext* context,\n const TfLiteNode* node, int index) {\n return GetInput(context, node, index);\n}","lang":"cpp","vul_type":"cwe-125","target_token_count":39,"sven_meta":{"func_name":"tflite::GetOptionalInputTensor","file_name":"tensorflow/lite/kernels/kernel_util.cc","commit_link":"github.com/tensorflow/tensorflow/commit/00302787b788c5ff04cb6f62aed5a74d936e86c0","source_cwe_file":"cwe-125.jsonl"}}
{"problem_id":"cwe-125#99-5f94022d85cc","input":"static void ip_cmsg_recv_checksum(struct msghdr *msg, struct sk_buff *skb,\n\t\t\t\t int tlen, int offset)\n{\n\t__wsum csum = skb->csum;\n\n\tif (skb->ip_summed != CHECKSUM_COMPLETE)\n\t\treturn;\n\n\tif (offset != 0)\n\t\tcsum = csum_sub(csum,\n\t\t\t\tcsum_partial(skb_transport_header(skb) + tlen,\n\t\t\t\t\t offset, 0));\n\n\tput_cmsg(msg, SOL_IP, IP_CHECKSUM, sizeof(__wsum), &csum);\n}","target":"static void ip_cmsg_recv_checksum(struct msghdr *msg, struct sk_buff *skb,\n\t\t\t\t int tlen, int offset)\n{\n\t__wsum csum = skb->csum;\n\n\tif (skb->ip_summed != CHECKSUM_COMPLETE)\n\t\treturn;\n\n\tif (offset != 0) {\n\t\tint tend_off = skb_transport_offset(skb) + tlen;\n\t\tcsum = csum_sub(csum, skb_checksum(skb, tend_off, offset, 0));\n\t}\n\n\tput_cmsg(msg, SOL_IP, IP_CHECKSUM, sizeof(__wsum), &csum);\n}","lang":"c","vul_type":"cwe-125","target_token_count":124,"sven_meta":{"func_name":"ip_cmsg_recv_checksum","file_name":"net/ipv4/ip_sockglue.c","commit_link":"github.com/torvalds/linux/commit/ca4ef4574f1ee5252e2cd365f8f5d5bafd048f32","source_cwe_file":"cwe-125.jsonl"}}
{"problem_id":"cwe-125#106-6cf45e7c2ef9","input":"BOOL security_fips_decrypt(BYTE* data, size_t length, rdpRdp* rdp)\n{\n\tsize_t olen;\n\n\tif (!winpr_Cipher_Update(rdp->fips_decrypt, data, length, data, &olen))\n\t\treturn FALSE;\n\n\treturn TRUE;\n}","target":"BOOL security_fips_decrypt(BYTE* data, size_t length, rdpRdp* rdp)\n{\n\tsize_t olen;\n\n\tif (!rdp || !rdp->fips_decrypt)\n\t\treturn FALSE;\n\n\tif (!winpr_Cipher_Update(rdp->fips_decrypt, data, length, data, &olen))\n\t\treturn FALSE;\n\n\treturn TRUE;\n}","lang":"c","vul_type":"cwe-125","target_token_count":76,"sven_meta":{"func_name":"security_fips_decrypt","file_name":"libfreerdp/core/security.c","commit_link":"github.com/FreeRDP/FreeRDP/commit/d6cd14059b257318f176c0ba3ee0a348826a9ef8","source_cwe_file":"cwe-125.jsonl"}}
{"problem_id":"cwe-125#121-30f32dd44c31","input":"static int uas_switch_interface(struct usb_device *udev,\n\t\t\t\tstruct usb_interface *intf)\n{\n\tint alt;\n\n\talt = uas_find_uas_alt_setting(intf);\n\tif (alt < 0)\n\t\treturn alt;\n\n\treturn usb_set_interface(udev,\n\t\t\tintf->altsetting[0].desc.bInterfaceNumber, alt);\n}","target":"static int uas_switch_interface(struct usb_device *udev,\n\t\t\t\tstruct usb_interface *intf)\n{\n\tstruct usb_host_interface *alt;\n\n\talt = uas_find_uas_alt_setting(intf);\n\tif (!alt)\n\t\treturn -ENODEV;\n\n\treturn usb_set_interface(udev, alt->desc.bInterfaceNumber,\n\t\t\talt->desc.bAlternateSetting);\n}","lang":"c","vul_type":"cwe-125","target_token_count":75,"sven_meta":{"func_name":"uas_switch_interface","file_name":"drivers/usb/storage/uas.c","commit_link":"github.com/torvalds/linux/commit/786de92b3cb26012d3d0f00ee37adf14527f35c4","source_cwe_file":"cwe-125.jsonl"}}
{"problem_id":"cwe-078#3-2749cd99d586","input":" def _cliq_run(self, verb, cliq_args, check_exit_code=True):\n \"\"\"Runs a CLIQ command over SSH, without doing any result parsing\"\"\"\n cliq_arg_strings = []\n for k, v in cliq_args.items():\n cliq_arg_strings.append(\" %s=%s\" % (k, v))\n cmd = verb + ''.join(cliq_arg_strings)\n\n return self._run_ssh(cmd, check_exit_code)","target":" def _cliq_run(self, verb, cliq_args, check_exit_code=True):\n \"\"\"Runs a CLIQ command over SSH, without doing any result parsing\"\"\"\n cmd_list = [verb]\n for k, v in cliq_args.items():\n cmd_list.append(\"%s=%s\" % (k, v))\n\n return self._run_ssh(cmd_list, check_exit_code)","lang":"python","vul_type":"cwe-078","target_token_count":81,"sven_meta":{"func_name":"_cliq_run","file_name":"cinder/volume/drivers/san/hp_lefthand.py","commit_link":"github.com/thatsdone/cinder/commit/c55589b131828f3a595903f6796cb2d0babb772f","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#4-3d9210fc8110","input":" def _set_qos_rule(self, qos, vvs_name):\n max_io = self._get_qos_value(qos, 'maxIOPS')\n max_bw = self._get_qos_value(qos, 'maxBWS')\n cli_qos_string = \"\"\n if max_io is not None:\n cli_qos_string += ('-io %s ' % max_io)\n if max_bw is not None:\n cli_qos_string += ('-bw %sM ' % max_bw)\n self._cli_run('setqos %svvset:%s' %\n (cli_qos_string, vvs_name), None)","target":" def _set_qos_rule(self, qos, vvs_name):\n max_io = self._get_qos_value(qos, 'maxIOPS')\n max_bw = self._get_qos_value(qos, 'maxBWS')\n cli_qos_string = \"\"\n if max_io is not None:\n cli_qos_string += ('-io %s ' % max_io)\n if max_bw is not None:\n cli_qos_string += ('-bw %sM ' % max_bw)\n self._cli_run(['setqos', '%svvset:%s' % (cli_qos_string, vvs_name)])","lang":"python","vul_type":"cwe-078","target_token_count":127,"sven_meta":{"func_name":"_set_qos_rule","file_name":"cinder/volume/drivers/san/hp/hp_3par_common.py","commit_link":"github.com/thatsdone/cinder/commit/c55589b131828f3a595903f6796cb2d0babb772f","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#5-28ceb7882167","input":"def get_lines(command: str) -> List[str]:\n \"\"\"\n Run a command and return lines of output\n\n :param str command: the command to run\n :returns: list of whitespace-stripped lines output by command\n \"\"\"\n stdout = get_output(command)\n return [line.strip().decode() for line in stdout.splitlines()]","target":"def get_lines(command: List[str]) -> List[str]:\n \"\"\"\n Run a command and return lines of output\n\n :param str command: the command to run\n :returns: list of whitespace-stripped lines output by command\n \"\"\"\n stdout = get_output(command)\n return [line.strip() for line in stdout.splitlines()]","lang":"python","vul_type":"cwe-078","target_token_count":72,"sven_meta":{"func_name":"get_lines","file_name":"isort/hooks.py","commit_link":"github.com/timothycrosley/isort/commit/1ab38f4f7840a3c19bf961a24630a992a8373a76","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#6-fe9caa64b7b7","input":" def _modify_3par_iscsi_host(self, hostname, iscsi_iqn):\n # when using -add, you can not send the persona or domain options\n self.common._cli_run('createhost -iscsi -add %s %s'\n % (hostname, iscsi_iqn), None)","target":" def _modify_3par_iscsi_host(self, hostname, iscsi_iqn):\n # when using -add, you can not send the persona or domain options\n command = ['createhost', '-iscsi', '-add', hostname, iscsi_iqn]\n self.common._cli_run(command)","lang":"python","vul_type":"cwe-078","target_token_count":66,"sven_meta":{"func_name":"_modify_3par_iscsi_host","file_name":"cinder/volume/drivers/san/hp/hp_3par_iscsi.py","commit_link":"github.com/thatsdone/cinder/commit/c55589b131828f3a595903f6796cb2d0babb772f","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#9-d568442eb4a9","input":"def whitelist(users: str):\n for user in users.split():\n call(WHITELIST_COMMAND_TEMPLATE.format(user))","target":"def whitelist(channel: discord.TextChannel, users: str):\n for user in users.split():\n if not re.match(r'^[A-Za-z0-9_]{3,16}$', user): # as per https://help.mojang.com/customer/en/portal/articles/928638-minecraft-usernames?b_id=5408\n await channel.send('\\'{}\\' is not a valid Minecraft username'.format(user))\n else:\n call(WHITELIST_COMMAND_TEMPLATE.format(user))","lang":"python","vul_type":"cwe-078","target_token_count":112,"sven_meta":{"func_name":"whitelist","file_name":"bot.py","commit_link":"github.com/thomotron/Gatekeep/commit/955660f9b3dc336ab0d5dfb4392b3ab6deac6b25","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#24-3887008d41bf","input":"@app.route('/api/uploads/<sid>/logs')\ndef get_logs(sid):\n if '/' not in sid:\n path = os.path.join(app.config['UPLOAD_FOLDER'], sid)\n if os.path.isfile(os.path.join(path, app.config['LOG_FILE'])):\n return send_from_directory(directory=path,\n filename=app.config['LOG_FILE'])\n else:\n abort(404)\n else:\n abort(403)","target":"@app.route('/api/uploads/<sid>/logs')\ndef get_logs(sid):\n if utils.sid_is_valid(sid):\n path = join(app.config['UPLOAD_FOLDER'], sid)\n\n if os.path.isfile(join(path, app.config['LOG_FILE'])):\n return send_from_directory(directory=path,\n filename=app.config['LOG_FILE'])\n else:\n abort(404)\n else:\n abort(404)","lang":"python","vul_type":"cwe-078","target_token_count":87,"sven_meta":{"func_name":"get_logs","file_name":"app/views.py","commit_link":"github.com/cheukyin699/genset-demo-site/commit/abb55b1a6786b0a995c2cdf77a7977a1d51cfc0d","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#29-780234f49746","input":" def ls(self, data, path):\n credentials = self._formatCredentials(data, name='current')\n\n command = (\n '{credentials} '\n 'rclone lsjson current:{path}'\n ).format(\n credentials=credentials,\n path=path,\n )\n\n try:\n result = self._execute(command)\n result = json.loads(result)\n return result\n except subprocess.CalledProcessError as e:\n raise RcloneException(sanitize(str(e)))","target":" def ls(self, data, path):\n credentials = self._formatCredentials(data, name='current')\n command = [\n 'rclone',\n 'lsjson',\n 'current:{}'.format(path),\n ]\n\n try:\n result = self._execute(command, credentials)\n result = json.loads(result)\n return result\n except subprocess.CalledProcessError as e:\n raise RcloneException(sanitize(str(e)))","lang":"python","vul_type":"cwe-078","target_token_count":90,"sven_meta":{"func_name":"ls","file_name":"src/backend/api/utils/rclone_connection.py","commit_link":"github.com/FredHutch/motuz/commit/045468cb9bff47bb3bb72268b6d5a3fe44e383db","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#31-0667a378a149","input":" def verify(self, data):\n credentials = self._formatCredentials(data, name='current')\n command = '{} rclone lsjson current:'.format(credentials)\n\n try:\n result = self._execute(command)\n return {\n 'result': True,\n 'message': 'Success',\n }\n except subprocess.CalledProcessError as e:\n returncode = e.returncode\n return {\n 'result': False,\n 'message': 'Exit status {}'.format(returncode),\n }","target":" def verify(self, data):\n credentials = self._formatCredentials(data, name='current')\n command = [\n 'rclone',\n 'lsjson',\n 'current:',\n ]\n\n try:\n result = self._execute(command, credentials)\n return {\n 'result': True,\n 'message': 'Success',\n }\n except subprocess.CalledProcessError as e:\n returncode = e.returncode\n return {\n 'result': False,\n 'message': 'Exit status {}'.format(returncode),\n }","lang":"python","vul_type":"cwe-078","target_token_count":112,"sven_meta":{"func_name":"verify","file_name":"src/backend/api/utils/rclone_connection.py","commit_link":"github.com/FredHutch/motuz/commit/045468cb9bff47bb3bb72268b6d5a3fe44e383db","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#33-aba413e8fa92","input":" def _get_vdisk_fc_mappings(self, vdisk_name):\n \"\"\"Return FlashCopy mappings that this vdisk is associated with.\"\"\"\n\n ssh_cmd = 'svcinfo lsvdiskfcmappings -nohdr %s' % vdisk_name\n out, err = self._run_ssh(ssh_cmd)\n\n mapping_ids = []\n if (len(out.strip())):\n lines = out.strip().split('\\n')\n mapping_ids = [line.split()[0] for line in lines]\n return mapping_ids","target":" def _get_vdisk_fc_mappings(self, vdisk_name):\n \"\"\"Return FlashCopy mappings that this vdisk is associated with.\"\"\"\n\n ssh_cmd = ['svcinfo', 'lsvdiskfcmappings', '-nohdr', vdisk_name]\n out, err = self._run_ssh(ssh_cmd)\n\n mapping_ids = []\n if (len(out.strip())):\n lines = out.strip().split('\\n')\n mapping_ids = [line.split()[0] for line in lines]\n return mapping_ids","lang":"python","vul_type":"cwe-078","target_token_count":107,"sven_meta":{"func_name":"_get_vdisk_fc_mappings","file_name":"cinder/volume/drivers/storwize_svc.py","commit_link":"github.com/thatsdone/cinder/commit/f752302d181583a95cf44354aea607ce9d9283f4","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#36-b80859948956","input":" def _get_active_nsp(self, hostname):\n \"\"\"Return the active nsp, if one exists, for the given host.\"\"\"\n result = self.common._cli_run('showvlun -a -host %s' % hostname, None)\n if result:\n # first line is header\n result = result[1:]\n for line in result:\n info = line.split(\",\")\n if info and len(info) > 4:\n return info[4]","target":" def _get_active_nsp(self, hostname):\n \"\"\"Return the active nsp, if one exists, for the given host.\"\"\"\n result = self.common._cli_run(['showvlun', '-a', '-host', hostname])\n if result:\n # first line is header\n result = result[1:]\n for line in result:\n info = line.split(\",\")\n if info and len(info) > 4:\n return info[4]","lang":"python","vul_type":"cwe-078","target_token_count":96,"sven_meta":{"func_name":"_get_active_nsp","file_name":"cinder/volume/drivers/san/hp/hp_3par_iscsi.py","commit_link":"github.com/thatsdone/cinder/commit/c55589b131828f3a595903f6796cb2d0babb772f","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#38-1738ca2b645f","input":" def mkdir(self, data, path):\n credentials = self._formatCredentials(data, name='current')\n\n command = (\n '{credentials} '\n 'rclone touch current:{path}/.keep'\n ).format(\n credentials=credentials,\n path=path,\n )\n\n try:\n result = self._execute(command)\n return {\n 'message': 'Success',\n }\n except subprocess.CalledProcessError as e:\n raise RcloneException(sanitize(str(e)))","target":" def mkdir(self, data, path):\n credentials = self._formatCredentials(data, name='current')\n command = [\n 'rclone',\n 'touch',\n 'current:{}/.keep'.format(path),\n ]\n\n try:\n result = self._execute(command, credentials)\n return {\n 'message': 'Success',\n }\n except subprocess.CalledProcessError as e:\n raise RcloneException(sanitize(str(e)))","lang":"python","vul_type":"cwe-078","target_token_count":93,"sven_meta":{"func_name":"mkdir","file_name":"src/backend/api/utils/rclone_connection.py","commit_link":"github.com/FredHutch/motuz/commit/045468cb9bff47bb3bb72268b6d5a3fe44e383db","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#42-407563b7e25f","input":" def _remove_volume_from_volume_set(self, volume_name, vvs_name):\n self._cli_run('removevvset -f %s %s' % (vvs_name, volume_name), None)","target":" def _remove_volume_from_volume_set(self, volume_name, vvs_name):\n self._cli_run(['removevvset', '-f', vvs_name, volume_name])","lang":"python","vul_type":"cwe-078","target_token_count":37,"sven_meta":{"func_name":"_remove_volume_from_volume_set","file_name":"cinder/volume/drivers/san/hp/hp_3par_common.py","commit_link":"github.com/thatsdone/cinder/commit/c55589b131828f3a595903f6796cb2d0babb772f","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#44-2097a321f7c9","input":" def _add_chapsecret_to_host(self, host_name):\n \"\"\"Generate and store a randomly-generated CHAP secret for the host.\"\"\"\n\n chap_secret = utils.generate_password()\n ssh_cmd = ('svctask chhost -chapsecret \"%(chap_secret)s\" %(host_name)s'\n % {'chap_secret': chap_secret, 'host_name': host_name})\n out, err = self._run_ssh(ssh_cmd)\n # No output should be returned from chhost\n self._assert_ssh_return(len(out.strip()) == 0,\n '_add_chapsecret_to_host', ssh_cmd, out, err)\n return chap_secret","target":" def _add_chapsecret_to_host(self, host_name):\n \"\"\"Generate and store a randomly-generated CHAP secret for the host.\"\"\"\n\n chap_secret = utils.generate_password()\n ssh_cmd = ['svctask', 'chhost', '-chapsecret', chap_secret, host_name]\n out, err = self._run_ssh(ssh_cmd)\n # No output should be returned from chhost\n self._assert_ssh_return(len(out.strip()) == 0,\n '_add_chapsecret_to_host', ssh_cmd, out, err)\n return chap_secret","lang":"python","vul_type":"cwe-078","target_token_count":119,"sven_meta":{"func_name":"_add_chapsecret_to_host","file_name":"cinder/volume/drivers/storwize_svc.py","commit_link":"github.com/thatsdone/cinder/commit/f752302d181583a95cf44354aea607ce9d9283f4","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#47-0f61a83ed3f1","input":" def on_message( self, profile_id, profile_name, level, message, timeout ):\n if 1 == level:\n cmd = \"notify-send \"\n if timeout > 0:\n cmd = cmd + \" -t %s\" % (1000 * timeout)\n\n title = \"Back In Time (%s) : %s\" % (self.user, profile_name)\n message = message.replace(\"\\n\", ' ')\n message = message.replace(\"\\r\", '')\n\n cmd = cmd + \" \\\"%s\\\" \\\"%s\\\"\" % (title, message)\n print(cmd)\n os.system(cmd)\n return","target":" def on_message( self, profile_id, profile_name, level, message, timeout ):\n if 1 == level:\n cmd = ['notify-send']\n if timeout > 0:\n cmd.extend(['-t', str(1000 * timeout)])\n\n title = \"Back In Time (%s) : %s\" % (self.user, profile_name)\n message = message.replace(\"\\n\", ' ')\n message = message.replace(\"\\r\", '')\n\n cmd.append(title)\n cmd.append(message)\n subprocess.Popen(cmd).communicate()\n return","lang":"python","vul_type":"cwe-078","target_token_count":117,"sven_meta":{"func_name":"on_message","file_name":"qt4/plugins/notifyplugin.py","commit_link":"github.com/bit-team/backintime/commit/cef81d0da93ff601252607df3db1a48f7f6f01b3","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#48-d9e4237d3d32","input":"void pb_controller::play_file(const std::string& file) {\n\tstd::string cmdline;\n\tstd::string player = cfg->get_configvalue(\"player\");\n\tif (player == \"\")\n\t\treturn;\n\tcmdline.append(player);\n\tcmdline.append(\" \\\"\");\n\tcmdline.append(utils::replace_all(file,\"\\\"\", \"\\\\\\\"\"));\n\tcmdline.append(\"\\\"\");\n\tstfl::reset();\n\tutils::run_interactively(cmdline, \"pb_controller::play_file\");\n}","target":"void pb_controller::play_file(const std::string& file) {\n\tstd::string cmdline;\n\tstd::string player = cfg->get_configvalue(\"player\");\n\tif (player == \"\")\n\t\treturn;\n\tcmdline.append(player);\n\tcmdline.append(\" '\");\n\tcmdline.append(utils::replace_all(file,\"'\", \"%27\"));\n\tcmdline.append(\"'\");\n\tstfl::reset();\n\tutils::run_interactively(cmdline, \"pb_controller::play_file\");\n}","lang":"cpp","vul_type":"cwe-078","target_token_count":91,"sven_meta":{"func_name":"podbeuter::pb_controller::play_file","file_name":"src/pb_controller.cpp","commit_link":"github.com/akrennmair/newsbeuter/commit/c8fea2f60c18ed30bdd1bb6f798e994e51a58260","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#52-7eebfc1fd84c","input":"def get_output(command: str) -> bytes:\n \"\"\"\n Run a command and return raw output\n\n :param str command: the command to run\n :returns: the stdout output of the command\n \"\"\"\n return subprocess.check_output(command.split())","target":"def get_output(command: List[str]) -> str:\n \"\"\"\n Run a command and return raw output\n\n :param str command: the command to run\n :returns: the stdout output of the command\n \"\"\"\n result = subprocess.run(command, stdout=subprocess.PIPE, check=True)\n return result.stdout.decode()","lang":"python","vul_type":"cwe-078","target_token_count":66,"sven_meta":{"func_name":"get_output","file_name":"isort/hooks.py","commit_link":"github.com/timothycrosley/isort/commit/1ab38f4f7840a3c19bf961a24630a992a8373a76","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#54-3e841e7e2ab2","input":"def add_user(username, password):\n encPass = crypt.crypt(password,\"22\")\n os.system(\"useradd -G docker,wheel -p \"+encPass+\" \"+username)","target":"def add_user(username, password):\n encPass = crypt.crypt(password,\"22\")\n #subprocess escapes the username stopping code injection\n subprocess.call(['useradd','-G','docker,wheel','-p',encPass,username])","lang":"python","vul_type":"cwe-078","target_token_count":50,"sven_meta":{"func_name":"add_user","file_name":"vuedj/configtitania/views.py","commit_link":"github.com/Internet-of-People/titania-os/commit/9b7805119938343fcac9dc929d8882f1d97cf14a","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#61-dc3536a3c0b9","input":"@then(parsers.parse(\"the hostname '{hostname}' should be resolved\"))\ndef resolve_hostname(busybox_pod, host, hostname):\n with host.sudo():\n # test dns resolve\n cmd_nslookup = (\"kubectl --kubeconfig=/etc/kubernetes/admin.conf\"\n \" exec -ti {0} nslookup {1}\".format(\n pod_name,\n hostname))\n res = host.run(cmd_nslookup)\n assert res.rc == 0, \"Cannot resolve {}\".format(hostname)","target":"@then(parsers.parse(\"the hostname '{hostname}' should be resolved\"))\ndef resolve_hostname(busybox_pod, host, hostname):\n with host.sudo():\n # test dns resolve\n result = host.run(\n \"kubectl --kubeconfig=/etc/kubernetes/admin.conf \"\n \"exec -ti %s nslookup %s\",\n busybox_pod,\n hostname,\n )\n\n assert result.rc == 0, \"Cannot resolve {}\".format(hostname)","lang":"python","vul_type":"cwe-078","target_token_count":94,"sven_meta":{"func_name":"resolve_hostname","file_name":"tests/post/steps/test_dns.py","commit_link":"github.com/scality/metalk8s/commit/82d92836d4ff78c623a0e06302c94cfa5ff79908","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#62-a97be4ff9b58","input":" def _modify_3par_fibrechan_host(self, hostname, wwn):\n # when using -add, you can not send the persona or domain options\n out = self.common._cli_run('createhost -add %s %s'\n % (hostname, \" \".join(wwn)), None)","target":" def _modify_3par_fibrechan_host(self, hostname, wwns):\n # when using -add, you can not send the persona or domain options\n command = ['createhost', '-add', hostname]\n for wwn in wwns:\n command.append(wwn)\n\n out = self.common._cli_run(command)","lang":"python","vul_type":"cwe-078","target_token_count":74,"sven_meta":{"func_name":"_modify_3par_fibrechan_host","file_name":"cinder/volume/drivers/san/hp/hp_3par_fc.py","commit_link":"github.com/thatsdone/cinder/commit/c55589b131828f3a595903f6796cb2d0babb772f","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#67-710824cc00da","input":" def adb_call(*args):\n clean_name = name.replace('_', '-')\n arg_str = ' '.join(str(elem) for elem in args)\n return self._exec_adb_cmd(clean_name, arg_str)","target":" def adb_call(args=None, shell=False):\n \"\"\"Wrapper for an ADB command.\n\n Args:\n args: string or list of strings, arguments to the adb command.\n See subprocess.Proc() documentation.\n shell: bool, True to run this command through the system shell,\n False to invoke it directly. See subprocess.Proc() docs.\n\n Returns:\n The output of the adb command run if exit code is 0.\n \"\"\"\n args = args or ''\n clean_name = name.replace('_', '-')\n return self._exec_adb_cmd(clean_name, args, shell=shell)","lang":"python","vul_type":"cwe-078","target_token_count":125,"sven_meta":{"func_name":"__getattr__.adb_call","file_name":"mobly/controllers/android_device_lib/adb.py","commit_link":"github.com/google/mobly/commit/3862e8ba359040fbdd6e1a6d36e51d07cda8e1ee","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#70-1eb822794898","input":" def tcp_forward(self, host_port, device_port):\n \"\"\"Starts tcp forwarding.\n\n Args:\n host_port: Port number to use on the computer.\n device_port: Port number to use on the android device.\n \"\"\"\n self.forward('tcp:%d tcp:%d' % (host_port, device_port))","target":" def tcp_forward(self, host_port, device_port):\n \"\"\"Starts tcp forwarding.\n\n Args:\n host_port: Port number to use on the computer.\n device_port: Port number to use on the android device.\n \"\"\"\n self.forward(['tcp:%d' % host_port, 'tcp:%d' % device_port])","lang":"python","vul_type":"cwe-078","target_token_count":70,"sven_meta":{"func_name":"tcp_forward","file_name":"mobly/controllers/android_device_lib/adb.py","commit_link":"github.com/google/mobly/commit/3862e8ba359040fbdd6e1a6d36e51d07cda8e1ee","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#73-f2f42b9cbbe4","input":" def _remove_volume_set(self, vvs_name):\n # Must first clear the QoS rules before removing the volume set\n self._cli_run('setqos -clear vvset:%s' % (vvs_name), None)\n self._cli_run('removevvset -f %s' % (vvs_name), None)","target":" def _remove_volume_set(self, vvs_name):\n # Must first clear the QoS rules before removing the volume set\n self._cli_run(['setqos', '-clear', 'vvset:%s' % (vvs_name)])\n self._cli_run(['removevvset', '-f', vvs_name])","lang":"python","vul_type":"cwe-078","target_token_count":68,"sven_meta":{"func_name":"_remove_volume_set","file_name":"cinder/volume/drivers/san/hp/hp_3par_common.py","commit_link":"github.com/thatsdone/cinder/commit/c55589b131828f3a595903f6796cb2d0babb772f","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#78-692aef5d8428","input":" def _cli_run(self, verb, cli_args):\n \"\"\"Runs a CLI command over SSH, without doing any result parsing.\"\"\"\n cli_arg_strings = []\n if cli_args:\n for k, v in cli_args.items():\n if k == '':\n cli_arg_strings.append(\" %s\" % k)\n else:\n cli_arg_strings.append(\" %s=%s\" % (k, v))\n\n cmd = verb + ''.join(cli_arg_strings)\n LOG.debug(\"SSH CMD = %s \" % cmd)\n\n (stdout, stderr) = self._run_ssh(cmd, False)\n\n # we have to strip out the input and exit lines\n tmp = stdout.split(\"\\r\\n\")\n out = tmp[5:len(tmp) - 2]\n return out","target":" def _cli_run(self, cmd):\n \"\"\"Runs a CLI command over SSH, without doing any result parsing.\"\"\"\n LOG.debug(\"SSH CMD = %s \" % cmd)\n\n (stdout, stderr) = self._run_ssh(cmd, False)\n\n # we have to strip out the input and exit lines\n tmp = stdout.split(\"\\r\\n\")\n out = tmp[5:len(tmp) - 2]\n return out","lang":"python","vul_type":"cwe-078","target_token_count":90,"sven_meta":{"func_name":"_cli_run","file_name":"cinder/volume/drivers/san/hp/hp_3par_common.py","commit_link":"github.com/thatsdone/cinder/commit/c55589b131828f3a595903f6796cb2d0babb772f","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#84-50aaf885963a","input":" def _get_conn_fc_wwpns(self, host_name):\n wwpns = []\n cmd = 'svcinfo lsfabric -host %s' % host_name\n generator = self._port_conf_generator(cmd)\n header = next(generator, None)\n if not header:\n return wwpns\n\n for port_data in generator:\n try:\n wwpns.append(port_data['local_wwpn'])\n except KeyError as e:\n self._handle_keyerror('lsfabric', header)\n\n return wwpns","target":" def _get_conn_fc_wwpns(self, host_name):\n wwpns = []\n cmd = ['svcinfo', 'lsfabric', '-host', host_name]\n generator = self._port_conf_generator(cmd)\n header = next(generator, None)\n if not header:\n return wwpns\n\n for port_data in generator:\n try:\n wwpns.append(port_data['local_wwpn'])\n except KeyError as e:\n self._handle_keyerror('lsfabric', header)\n\n return wwpns","lang":"python","vul_type":"cwe-078","target_token_count":113,"sven_meta":{"func_name":"_get_conn_fc_wwpns","file_name":"cinder/volume/drivers/storwize_svc.py","commit_link":"github.com/thatsdone/cinder/commit/f752302d181583a95cf44354aea607ce9d9283f4","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#86-b6b329d00d9b","input":" def _delete_3par_host(self, hostname):\n self._cli_run('removehost %s' % hostname, None)","target":" def _delete_3par_host(self, hostname):\n self._cli_run(['removehost', hostname])","lang":"python","vul_type":"cwe-078","target_token_count":23,"sven_meta":{"func_name":"_delete_3par_host","file_name":"cinder/volume/drivers/san/hp/hp_3par_common.py","commit_link":"github.com/thatsdone/cinder/commit/c55589b131828f3a595903f6796cb2d0babb772f","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-078#88-e006b7badd21","input":" def _delete_host(self, host_name):\n \"\"\"Delete a host on the storage system.\"\"\"\n\n LOG.debug(_('enter: _delete_host: host %s ') % host_name)\n\n ssh_cmd = 'svctask rmhost %s ' % host_name\n out, err = self._run_ssh(ssh_cmd)\n # No output should be returned from rmhost\n self._assert_ssh_return(len(out.strip()) == 0,\n '_delete_host', ssh_cmd, out, err)\n\n LOG.debug(_('leave: _delete_host: host %s ') % host_name)","target":" def _delete_host(self, host_name):\n \"\"\"Delete a host on the storage system.\"\"\"\n\n LOG.debug(_('enter: _delete_host: host %s ') % host_name)\n\n ssh_cmd = ['svctask', 'rmhost', host_name]\n out, err = self._run_ssh(ssh_cmd)\n # No output should be returned from rmhost\n self._assert_ssh_return(len(out.strip()) == 0,\n '_delete_host', ssh_cmd, out, err)\n\n LOG.debug(_('leave: _delete_host: host %s ') % host_name)","lang":"python","vul_type":"cwe-078","target_token_count":122,"sven_meta":{"func_name":"_delete_host","file_name":"cinder/volume/drivers/storwize_svc.py","commit_link":"github.com/thatsdone/cinder/commit/f752302d181583a95cf44354aea607ce9d9283f4","source_cwe_file":"cwe-078.jsonl"}}
{"problem_id":"cwe-476#6-5544abd56a8e","input":"static int changedline (const Proto *p, int oldpc, int newpc) {\n while (oldpc++ < newpc) {\n if (p->lineinfo[oldpc] != 0)\n return (luaG_getfuncline(p, oldpc - 1) != luaG_getfuncline(p, newpc));\n }\n return 0; /* no line changes in the way */\n}","target":"static int changedline (const Proto *p, int oldpc, int newpc) {\n if (p->lineinfo == NULL) /* no debug information? */\n return 0;\n while (oldpc++ < newpc) {\n if (p->lineinfo[oldpc] != 0)\n return (luaG_getfuncline(p, oldpc - 1) != luaG_getfuncline(p, newpc));\n }\n return 0; /* no line changes between positions */\n}","lang":"c","vul_type":"cwe-476","target_token_count":110,"sven_meta":{"func_name":"changedline","file_name":"ldebug.c","commit_link":"github.com/lua/lua/commit/ae5b5ba529753c7a653901ffc29b5ea24c3fdf3a","source_cwe_file":"cwe-476.jsonl"}}
{"problem_id":"cwe-476#16-e7b8e1971aa9","input":"mrb_class_real(struct RClass* cl)\n{\n if (cl == 0)\n return NULL;\n while ((cl->tt == MRB_TT_SCLASS) || (cl->tt == MRB_TT_ICLASS)) {\n cl = cl->super;\n }\n return cl;\n}","target":"mrb_class_real(struct RClass* cl)\n{\n if (cl == 0) return NULL;\n while ((cl->tt == MRB_TT_SCLASS) || (cl->tt == MRB_TT_ICLASS)) {\n cl = cl->super;\n if (cl == 0) return NULL;\n }\n return cl;\n}","lang":"c","vul_type":"cwe-476","target_token_count":76,"sven_meta":{"func_name":"mrb_class_real","file_name":"src/class.c","commit_link":"github.com/mruby/mruby/commit/faa4eaf6803bd11669bc324b4c34e7162286bfa3","source_cwe_file":"cwe-476.jsonl"}}
{"problem_id":"cwe-476#28-da074368d1c7","input":"file_transfer_t *imcb_file_send_start(struct im_connection *ic, char *handle, char *file_name, size_t file_size)\n{\n\tbee_t *bee = ic->bee;\n\tbee_user_t *bu = bee_user_by_handle(bee, ic, handle);\n\n\tif (bee->ui->ft_in_start) {\n\t\treturn bee->ui->ft_in_start(bee, bu, file_name, file_size);\n\t} else {\n\t\treturn NULL;\n\t}\n}","target":"file_transfer_t *imcb_file_send_start(struct im_connection *ic, char *handle, char *file_name, size_t file_size)\n{\n\tbee_t *bee = ic->bee;\n\tbee_user_t *bu = bee_user_by_handle(bee, ic, handle);\n\n\tif (bee->ui->ft_in_start && bu) {\n\t\treturn bee->ui->ft_in_start(bee, bu, file_name, file_size);\n\t} else {\n\t\treturn NULL;\n\t}\n}","lang":"c","vul_type":"cwe-476","target_token_count":102,"sven_meta":{"func_name":"imcb_file_send_start","file_name":"protocols/bee_ft.c","commit_link":"github.com/bitlbee/bitlbee/commit/701ab8129ba9ea64f569daedca9a8603abad740f","source_cwe_file":"cwe-476.jsonl"}}
{"problem_id":"cwe-476#40-803fea2fbe49","input":"static void copyIPv6IfDifferent(void * dest, const void * src)\n{\n\tif(dest != src) {\n\t\tmemcpy(dest, src, sizeof(struct in6_addr));\n\t}\n}","target":"static void copyIPv6IfDifferent(void * dest, const void * src)\n{\n\tif(dest != src && src != NULL) {\n\t\tmemcpy(dest, src, sizeof(struct in6_addr));\n\t}\n}","lang":"c","vul_type":"cwe-476","target_token_count":42,"sven_meta":{"func_name":"copyIPv6IfDifferent","file_name":"miniupnpd/pcpserver.c","commit_link":"github.com/miniupnp/miniupnp/commit/cb8a02af7a5677cf608e86d57ab04241cf34e24f","source_cwe_file":"cwe-476.jsonl"}}
{"problem_id":"cwe-476#52-c11e40dd75e7","input":"static int __init fm10k_init_module(void)\n{\n\tpr_info(\"%s - version %s\\n\", fm10k_driver_string, fm10k_driver_version);\n\tpr_info(\"%s\\n\", fm10k_copyright);\n\n\t/* create driver workqueue */\n\tfm10k_workqueue = alloc_workqueue(\"%s\", WQ_MEM_RECLAIM, 0,\n\t\t\t\t\t fm10k_driver_name);\n\n\tfm10k_dbg_init();\n\n\treturn fm10k_register_pci_driver();\n}","target":"static int __init fm10k_init_module(void)\n{\n\tpr_info(\"%s - version %s\\n\", fm10k_driver_string, fm10k_driver_version);\n\tpr_info(\"%s\\n\", fm10k_copyright);\n\n\t/* create driver workqueue */\n\tfm10k_workqueue = alloc_workqueue(\"%s\", WQ_MEM_RECLAIM, 0,\n\t\t\t\t\t fm10k_driver_name);\n\tif (!fm10k_workqueue)\n\t\treturn -ENOMEM;\n\n\tfm10k_dbg_init();\n\n\treturn fm10k_register_pci_driver();\n}","lang":"c","vul_type":"cwe-476","target_token_count":120,"sven_meta":{"func_name":"fm10k_init_module","file_name":"drivers/net/ethernet/intel/fm10k/fm10k_main.c","commit_link":"github.com/torvalds/linux/commit/01ca667133d019edc9f0a1f70a272447c84ec41f","source_cwe_file":"cwe-476.jsonl"}}
{"problem_id":"cwe-476#67-65d9f9ddfcb5","input":"filter_session_io(struct io *io, int evt, void *arg)\n{\n\tstruct filter_session *fs = arg;\n\tchar *line = NULL;\n\tssize_t len;\n\n\tlog_trace(TRACE_IO, \"filter session: %p: %s %s\", fs, io_strevent(evt),\n\t io_strio(io));\n\n\tswitch (evt) {\n\tcase IO_DATAIN:\n\tnextline:\n\t\tline = io_getline(fs->io, &len);\n\t\t/* No complete line received */\n\t\tif (line == NULL)\n\t\t\treturn;\n\n\t\tfilter_data(fs->id, line);\n\n\t\tgoto nextline;\n\n\tcase IO_DISCONNECTED:\n\t\tio_free(fs->io);\n\t\tfs->io = NULL;\n\t\tbreak;\n\t}\n}","target":"filter_session_io(struct io *io, int evt, void *arg)\n{\n\tstruct filter_session *fs = arg;\n\tchar *line = NULL;\n\tssize_t len;\n\n\tlog_trace(TRACE_IO, \"filter session: %p: %s %s\", fs, io_strevent(evt),\n\t io_strio(io));\n\n\tswitch (evt) {\n\tcase IO_DATAIN:\n\tnextline:\n\t\tline = io_getline(fs->io, &len);\n\t\t/* No complete line received */\n\t\tif (line == NULL)\n\t\t\treturn;\n\n\t\tfilter_data(fs->id, line);\n\n\t\tgoto nextline;\n\t}\n}","lang":"c","vul_type":"cwe-476","target_token_count":128,"sven_meta":{"func_name":"filter_session_io","file_name":"usr.sbin/smtpd/lka_filter.c","commit_link":"github.com/openbsd/src/commit/6c3220444ed06b5796dedfd53a0f4becd903c0d1","source_cwe_file":"cwe-476.jsonl"}}
{"problem_id":"cwe-416#0-eb9b3e8040bf","input":"static void disk_seqf_stop(struct seq_file *seqf, void *v)\n{\n\tstruct class_dev_iter *iter = seqf->private;\n\n\t/* stop is called even after start failed :-( */\n\tif (iter) {\n\t\tclass_dev_iter_exit(iter);\n\t\tkfree(iter);\n\t}\n}","target":"static void disk_seqf_stop(struct seq_file *seqf, void *v)\n{\n\tstruct class_dev_iter *iter = seqf->private;\n\n\t/* stop is called even after start failed :-( */\n\tif (iter) {\n\t\tclass_dev_iter_exit(iter);\n\t\tkfree(iter);\n\t\tseqf->private = NULL;\n\t}\n}","lang":"c","vul_type":"cwe-416","target_token_count":69,"sven_meta":{"func_name":"disk_seqf_stop","file_name":"block/genhd.c","commit_link":"github.com/torvalds/linux/commit/77da160530dd1dc94f6ae15a981f24e5f0021e84","source_cwe_file":"cwe-416.jsonl"}}
{"problem_id":"cwe-416#18-e757c3320e5f","input":"ExprAppendMultiKeysymList(ExprDef *expr, ExprDef *append)\n{\n unsigned nSyms = darray_size(expr->keysym_list.syms);\n unsigned numEntries = darray_size(append->keysym_list.syms);\n\n darray_append(expr->keysym_list.symsMapIndex, nSyms);\n darray_append(expr->keysym_list.symsNumEntries, numEntries);\n darray_concat(expr->keysym_list.syms, append->keysym_list.syms);\n\n FreeStmt((ParseCommon *) &append);\n\n return expr;\n}","target":"ExprAppendMultiKeysymList(ExprDef *expr, ExprDef *append)\n{\n unsigned nSyms = darray_size(expr->keysym_list.syms);\n unsigned numEntries = darray_size(append->keysym_list.syms);\n\n darray_append(expr->keysym_list.symsMapIndex, nSyms);\n darray_append(expr->keysym_list.symsNumEntries, numEntries);\n darray_concat(expr->keysym_list.syms, append->keysym_list.syms);\n\n FreeStmt((ParseCommon *) append);\n\n return expr;\n}","lang":"c","vul_type":"cwe-416","target_token_count":121,"sven_meta":{"func_name":"ExprAppendMultiKeysymList","file_name":"src/xkbcomp/ast-build.c","commit_link":"github.com/xkbcommon/libxkbcommon/commit/c1e5ac16e77a21f87bdf3bc4dea61b037a17dddb","source_cwe_file":"cwe-416.jsonl"}}
{"problem_id":"cwe-416#27-b1b8f495f594","input":"static int get_task_ioprio(struct task_struct *p)\n{\n\tint ret;\n\n\tret = security_task_getioprio(p);\n\tif (ret)\n\t\tgoto out;\n\tret = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, IOPRIO_NORM);\n\tif (p->io_context)\n\t\tret = p->io_context->ioprio;\nout:\n\treturn ret;\n}","target":"static int get_task_ioprio(struct task_struct *p)\n{\n\tint ret;\n\n\tret = security_task_getioprio(p);\n\tif (ret)\n\t\tgoto out;\n\tret = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, IOPRIO_NORM);\n\ttask_lock(p);\n\tif (p->io_context)\n\t\tret = p->io_context->ioprio;\n\ttask_unlock(p);\nout:\n\treturn ret;\n}","lang":"c","vul_type":"cwe-416","target_token_count":91,"sven_meta":{"func_name":"get_task_ioprio","file_name":"block/ioprio.c","commit_link":"github.com/torvalds/linux/commit/8ba8682107ee2ca3347354e018865d8e1967c5f4","source_cwe_file":"cwe-416.jsonl"}}
{"problem_id":"cwe-416#34-361e7defc730","input":"static int hci_uart_set_proto(struct hci_uart *hu, int id)\n{\n\tconst struct hci_uart_proto *p;\n\tint err;\n\n\tp = hci_uart_get_proto(id);\n\tif (!p)\n\t\treturn -EPROTONOSUPPORT;\n\n\thu->proto = p;\n\tset_bit(HCI_UART_PROTO_READY, &hu->flags);\n\n\terr = hci_uart_register_dev(hu);\n\tif (err) {\n\t\tclear_bit(HCI_UART_PROTO_READY, &hu->flags);\n\t\treturn err;\n\t}\n\n\treturn 0;\n}","target":"static int hci_uart_set_proto(struct hci_uart *hu, int id)\n{\n\tconst struct hci_uart_proto *p;\n\tint err;\n\n\tp = hci_uart_get_proto(id);\n\tif (!p)\n\t\treturn -EPROTONOSUPPORT;\n\n\thu->proto = p;\n\n\terr = hci_uart_register_dev(hu);\n\tif (err) {\n\t\treturn err;\n\t}\n\n\tset_bit(HCI_UART_PROTO_READY, &hu->flags);\n\treturn 0;\n}","lang":"c","vul_type":"cwe-416","target_token_count":98,"sven_meta":{"func_name":"hci_uart_set_proto","file_name":"drivers/bluetooth/hci_ldisc.c","commit_link":"github.com/torvalds/linux/commit/56897b217a1d0a91c9920cb418d6b3fe922f590a","source_cwe_file":"cwe-416.jsonl"}}
{"problem_id":"cwe-416#37-825ae2642222","input":"PlayerGeneric::~PlayerGeneric()\n{\n\tif (mixer)\n\t\tdelete mixer;\n\n\tif (player)\n\t{\n\t\tif (mixer->isActive() && !mixer->isDeviceRemoved(player))\n\t\t\tmixer->removeDevice(player);\n\t\tdelete player;\n\t}\n\n\tdelete[] audioDriverName;\n\t\n\tdelete listener;\n}","target":"PlayerGeneric::~PlayerGeneric()\n{\n\n\tif (player)\n\t{\n\t\tif (mixer && mixer->isActive() && !mixer->isDeviceRemoved(player))\n\t\t\tmixer->removeDevice(player);\n\t\tdelete player;\n\t}\n\t\n\tif (mixer)\n\t\tdelete mixer;\n\n\tdelete[] audioDriverName;\n\t\n\tdelete listener;\n}","lang":"cpp","vul_type":"cwe-416","target_token_count":68,"sven_meta":{"func_name":"PlayerGeneric::~PlayerGeneric","file_name":"src/milkyplay/PlayerGeneric.cpp","commit_link":"github.com/milkytracker/MilkyTracker/commit/7afd55c42ad80d01a339197a2d8b5461d214edaf","source_cwe_file":"cwe-416.jsonl"}}
{"problem_id":"cwe-416#48-1b92d67df79b","input":"struct net *get_net_ns_by_id(struct net *net, int id)\n{\n\tstruct net *peer;\n\n\tif (id < 0)\n\t\treturn NULL;\n\n\trcu_read_lock();\n\tspin_lock_bh(&net->nsid_lock);\n\tpeer = idr_find(&net->netns_ids, id);\n\tif (peer)\n\t\tget_net(peer);\n\tspin_unlock_bh(&net->nsid_lock);\n\trcu_read_unlock();\n\n\treturn peer;\n}","target":"struct net *get_net_ns_by_id(struct net *net, int id)\n{\n\tstruct net *peer;\n\n\tif (id < 0)\n\t\treturn NULL;\n\n\trcu_read_lock();\n\tspin_lock_bh(&net->nsid_lock);\n\tpeer = idr_find(&net->netns_ids, id);\n\tif (peer)\n\t\tpeer = maybe_get_net(peer);\n\tspin_unlock_bh(&net->nsid_lock);\n\trcu_read_unlock();\n\n\treturn peer;\n}","lang":"c","vul_type":"cwe-416","target_token_count":95,"sven_meta":{"func_name":"get_net_ns_by_id","file_name":"net/core/net_namespace.c","commit_link":"github.com/torvalds/linux/commit/21b5944350052d2583e82dd59b19a9ba94a007f0","source_cwe_file":"cwe-416.jsonl"}}
{"problem_id":"cwe-416#53-1f6d62676756","input":"static int snd_seq_device_dev_free(struct snd_device *device)\n{\n\tstruct snd_seq_device *dev = device->device_data;\n\n\tput_device(&dev->dev);\n\treturn 0;\n}","target":"static int snd_seq_device_dev_free(struct snd_device *device)\n{\n\tstruct snd_seq_device *dev = device->device_data;\n\n\tcancel_autoload_drivers();\n\tput_device(&dev->dev);\n\treturn 0;\n}","lang":"c","vul_type":"cwe-416","target_token_count":44,"sven_meta":{"func_name":"snd_seq_device_dev_free","file_name":"sound/core/seq_device.c","commit_link":"github.com/torvalds/linux/commit/fc27fe7e8deef2f37cba3f2be2d52b6ca5eb9d57","source_cwe_file":"cwe-416.jsonl"}}
{"problem_id":"cwe-022#2-6241e4c1b809","input":"static int nntp_hcache_namer(const char *path, char *dest, size_t destlen)\n{\n return snprintf(dest, destlen, \"%s.hcache\", path);\n}","target":"static int nntp_hcache_namer(const char *path, char *dest, size_t destlen)\n{\n int count = snprintf(dest, destlen, \"%s.hcache\", path);\n\n /* Strip out any directories in the path */\n char *first = strchr(dest, '/');\n char *last = strrchr(dest, '/');\n if (first && last && (last > first))\n {\n memmove(first, last, strlen(last) + 1);\n count -= (last - first);\n }\n\n return count;\n}","lang":"c","vul_type":"cwe-022","target_token_count":112,"sven_meta":{"func_name":"nntp_hcache_namer","file_name":"newsrc.c","commit_link":"github.com/neomutt/neomutt/commit/9bfab35522301794483f8f9ed60820bdec9be59e","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-022#5-226e5ab02e65","input":"def _inject_file_into_fs(fs, path, contents):\n absolute_path = os.path.join(fs, path.lstrip('/'))\n parent_dir = os.path.dirname(absolute_path)\n utils.execute('mkdir', '-p', parent_dir, run_as_root=True)\n utils.execute('tee', absolute_path, process_input=contents,\n run_as_root=True)","target":"def _inject_file_into_fs(fs, path, contents, append=False):\n absolute_path = _join_and_check_path_within_fs(fs, path.lstrip('/'))\n\n parent_dir = os.path.dirname(absolute_path)\n utils.execute('mkdir', '-p', parent_dir, run_as_root=True)\n\n args = []\n if append:\n args.append('-a')\n args.append(absolute_path)\n\n kwargs = dict(process_input=contents, run_as_root=True)\n\n utils.execute('tee', *args, **kwargs)","lang":"python","vul_type":"cwe-022","target_token_count":108,"sven_meta":{"func_name":"_inject_file_into_fs","file_name":"nova/virt/disk/api.py","commit_link":"github.com/openstack/nova/commit/2427d4a99bed35baefd8f17ba422cb7aae8dcca7","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-022#7-ad0f9aabe39b","input":" def cut(self, key):\n try:\n self.etcd.delete(os.path.join(self.namespace, key))\n except etcd.EtcdKeyNotFound:\n return False\n except etcd.EtcdException as err:\n log_error(\"Error removing key %s: [%r]\" % (key, repr(err)))\n raise CSStoreError('Error occurred while trying to cut key')\n return True","target":" def cut(self, key):\n try:\n self.etcd.delete(self._absolute_key(key))\n except etcd.EtcdKeyNotFound:\n return False\n except etcd.EtcdException as err:\n log_error(\"Error removing key %s: [%r]\" % (key, repr(err)))\n raise CSStoreError('Error occurred while trying to cut key')\n return True","lang":"python","vul_type":"cwe-022","target_token_count":83,"sven_meta":{"func_name":"cut","file_name":"custodia/store/etcdstore.py","commit_link":"github.com/latchset/custodia/commit/785fc87f38b4811bc4ce43a0a9b2267ee7d500b4","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-022#9-bb0b57f9d8fa","input":" def candidate_paths_for_url(self, url):\n for root, prefix in self.directories:\n if url.startswith(prefix):\n yield os.path.join(root, url[len(prefix):])","target":" def candidate_paths_for_url(self, url):\n for root, prefix in self.directories:\n if url.startswith(prefix):\n path = os.path.join(root, url[len(prefix):])\n if os.path.commonprefix((root, path)) == root:\n yield path","lang":"python","vul_type":"cwe-022","target_token_count":56,"sven_meta":{"func_name":"candidate_paths_for_url","file_name":"whitenoise/base.py","commit_link":"github.com/evansd/whitenoise/commit/4d8a3ab1e97d7ddb18b3fa8b4909c92bad5529c6","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-022#11-3bdc24de76e9","input":"def create_basename_core(basename):\n try:\n basename = basename.casefold()\n except Exception:\n basename = basename.lower()\n\n basename = basename.replace(' ', '-')\n basename = re.sub(r'<[^>]*>', r'', basename)\n basename = re.sub(r'[^a-z0-9\\-]', r'', basename)\n basename = re.sub(r'\\-\\-', r'-', basename)\n basename = urllib.parse.quote_plus(basename)\n\n return basename","target":"def create_basename_core(basename):\n try:\n basename = basename.casefold()\n except Exception:\n basename = basename.lower()\n\n basename = re.sub(r'[ \\./]', r'-', basename)\n basename = re.sub(r'<[^>]*>', r'', basename)\n basename = re.sub(r'[^a-z0-9\\-]', r'', basename)\n basename = re.sub(r'\\-\\-', r'-', basename)\n basename = urllib.parse.quote_plus(basename)\n\n return basename","lang":"python","vul_type":"cwe-022","target_token_count":103,"sven_meta":{"func_name":"create_basename_core","file_name":"MeTal/core/utils.py","commit_link":"github.com/syegulalp/mercury/commit/3f7c7442fa49aec37577dbdb47ce11a848e7bd03","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-022#12-71b22f274d93","input":" def get(self, key):\n try:\n result = self.etcd.get(os.path.join(self.namespace, key))\n except etcd.EtcdException as err:\n log_error(\"Error fetching key %s: [%r]\" % (key, repr(err)))\n raise CSStoreError('Error occurred while trying to get key')\n return result.value","target":" def get(self, key):\n try:\n result = self.etcd.get(self._absolute_key(key))\n except etcd.EtcdException as err:\n log_error(\"Error fetching key %s: [%r]\" % (key, repr(err)))\n raise CSStoreError('Error occurred while trying to get key')\n return result.value","lang":"python","vul_type":"cwe-022","target_token_count":72,"sven_meta":{"func_name":"get","file_name":"custodia/store/etcdstore.py","commit_link":"github.com/latchset/custodia/commit/785fc87f38b4811bc4ce43a0a9b2267ee7d500b4","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-022#23-7d2d7dc8d2fd","input":"void dd_save_text(struct dump_dir *dd, const char *name, const char *data)\n{\n if (!dd->locked)\n error_msg_and_die(\"dump_dir is not opened\"); /* bug */\n\n char *full_path = concat_path_file(dd->dd_dirname, name);\n save_binary_file(full_path, data, strlen(data), dd->dd_uid, dd->dd_gid, dd->mode);\n free(full_path);\n}","target":"void dd_save_text(struct dump_dir *dd, const char *name, const char *data)\n{\n if (!dd->locked)\n error_msg_and_die(\"dump_dir is not opened\"); /* bug */\n\n if (!str_is_correct_filename(name))\n error_msg_and_die(\"Cannot save text. '%s' is not a valid file name\", name);\n\n char *full_path = concat_path_file(dd->dd_dirname, name);\n save_binary_file(full_path, data, strlen(data), dd->dd_uid, dd->dd_gid, dd->mode);\n free(full_path);\n}","lang":"c","vul_type":"cwe-022","target_token_count":123,"sven_meta":{"func_name":"dd_save_text","file_name":"src/lib/dump_dir.c","commit_link":"github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-022#25-398e401855d6","input":"void dd_save_binary(struct dump_dir* dd, const char* name, const char* data, unsigned size)\n{\n if (!dd->locked)\n error_msg_and_die(\"dump_dir is not opened\"); /* bug */\n\n char *full_path = concat_path_file(dd->dd_dirname, name);\n save_binary_file(full_path, data, size, dd->dd_uid, dd->dd_gid, dd->mode);\n free(full_path);\n}","target":"void dd_save_binary(struct dump_dir* dd, const char* name, const char* data, unsigned size)\n{\n if (!dd->locked)\n error_msg_and_die(\"dump_dir is not opened\"); /* bug */\n\n if (!str_is_correct_filename(name))\n error_msg_and_die(\"Cannot save binary. '%s' is not a valid file name\", name);\n\n char *full_path = concat_path_file(dd->dd_dirname, name);\n save_binary_file(full_path, data, size, dd->dd_uid, dd->dd_gid, dd->mode);\n free(full_path);\n}","lang":"c","vul_type":"cwe-022","target_token_count":125,"sven_meta":{"func_name":"dd_save_binary","file_name":"src/lib/dump_dir.c","commit_link":"github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-022#26-4f0f9c1b3ddc","input":"def pascal_case(value: str) -> str:\n return stringcase.pascalcase(value)","target":"def pascal_case(value: str) -> str:\n return stringcase.pascalcase(_sanitize(value))","lang":"python","vul_type":"cwe-022","target_token_count":22,"sven_meta":{"func_name":"pascal_case","file_name":"openapi_python_client/utils.py","commit_link":"github.com/openapi-generators/openapi-python-client/commit/3e7dfae5d0b3685abf1ede1bc6c086a116ac4746","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-022#34-0bfc2f9cdba5","input":" @staticmethod\n def _download_file(bucket, filename, local_dir):\n key = bucket.get_key(filename)\n local_filename = os.path.join(local_dir, filename)\n key.get_contents_to_filename(local_filename)\n return local_filename","target":" @staticmethod\n def _download_file(bucket, filename, local_dir):\n key = bucket.get_key(filename)\n local_filename = os.path.join(local_dir, os.path.basename(filename))\n key.get_contents_to_filename(local_filename)\n return local_filename","lang":"python","vul_type":"cwe-022","target_token_count":52,"sven_meta":{"func_name":"_download_file","file_name":"nova/image/s3.py","commit_link":"github.com/openstack/nova/commit/76363226bd8533256f7795bba358d7f4b8a6c9e6","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-022#42-7b8d67274477","input":"def get_paths(base_path: pathlib.Path):\n data_file = pathlib.Path(str(base_path) + \".data\")\n metadata_file = pathlib.Path(str(base_path) + \".meta\")\n\n return data_file, metadata_file","target":"def get_paths(root: str, sub_path: str) \\\n -> typing.Tuple[pathlib.Path, pathlib.Path]:\n base_path = flask.safe_join(root, sub_path)\n data_file = pathlib.Path(base_path + \".data\")\n metadata_file = pathlib.Path(base_path + \".meta\")\n\n return data_file, metadata_file","lang":"python","vul_type":"cwe-022","target_token_count":68,"sven_meta":{"func_name":"get_paths","file_name":"xhu.py","commit_link":"github.com/horazont/xmpp-http-upload/commit/82056540191e89f0cd697c81f57714c00962ed75","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-022#44-c2312c8f5b91","input":"def valid_id(opts, id_):\n '''\n Returns if the passed id is valid\n '''\n try:\n return bool(clean_path(opts['pki_dir'], id_)) and clean_id(id_)\n except (AttributeError, KeyError, TypeError) as e:\n return False","target":"def valid_id(opts, id_):\n '''\n Returns if the passed id is valid\n '''\n try:\n if any(x in id_ for x in ('/', '\\\\', '\\0')):\n return False\n return bool(clean_path(opts['pki_dir'], id_))\n except (AttributeError, KeyError, TypeError):\n return False","lang":"python","vul_type":"cwe-022","target_token_count":72,"sven_meta":{"func_name":"valid_id","file_name":"salt/utils/verify.py","commit_link":"github.com/saltstack/salt/commit/80d90307b07b3703428ecbb7c8bb468e28a9ae6d","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-022#45-df0c3974d942","input":" def get(self, path):\n return static_file(path, self.get_base_path())","target":" def get(self, path):\n path = self.sanitize_path(path)\n base_paths = self.get_base_paths()\n if hasattr(base_paths, 'split'):\n # String, so go simple\n base_path = base_paths\n else:\n base_path = self.get_first_base(base_paths, path)\n return static_file(path, base_path)","lang":"python","vul_type":"cwe-022","target_token_count":74,"sven_meta":{"func_name":"get","file_name":"seagull/routes/app.py","commit_link":"github.com/foxbunny/seagull/commit/1fb790712fe0c1d1957b31e34a8e0e6593af87a7","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-022#46-48fed782bfed","input":"int dd_exist(const struct dump_dir *dd, const char *path)\n{\n char *full_path = concat_path_file(dd->dd_dirname, path);\n int ret = exist_file_dir(full_path);\n free(full_path);\n return ret;\n}","target":"int dd_exist(const struct dump_dir *dd, const char *path)\n{\n if (!str_is_correct_filename(path))\n error_msg_and_die(\"Cannot test existence. '%s' is not a valid file name\", path);\n\n char *full_path = concat_path_file(dd->dd_dirname, path);\n int ret = exist_file_dir(full_path);\n free(full_path);\n return ret;\n}","lang":"c","vul_type":"cwe-022","target_token_count":84,"sven_meta":{"func_name":"dd_exist","file_name":"src/lib/dump_dir.c","commit_link":"github.com/abrt/libreport/commit/239c4f7d1f47265526b39ad70106767d00805277","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-022#48-80f68c61320e","input":"def deleteKey(client):\n\t\"\"\"Deletes the specified key.\n\tReturns an error if the key doesn't exist\n\t\"\"\"\n\tglobal BAD_REQUEST\n\tglobal NOT_FOUND\n\n\tvalidateClient(client)\n\n\tclient_pub_key = loadClientRSAKey(client)\n\ttoken_data = decodeRequestToken(request.data, client_pub_key)\n\n\tif re.search('[^a-zA-Z0-9]', token_data['key']):\n\t\traise FoxlockError(BAD_REQUEST, 'Invalid key requested')\n\n\ttry:\n\t\tos.remove('keys/%s/%s.key' % (client, token_data['key']))\n\texcept FileNotFoundError:\n\t\traise FoxlockError(NOT_FOUND, \"Key '%s' not found\" % token_data['key'])\n\n\treturn \"Key '%s' successfully deleted\" % token_data['key']","target":"def deleteKey(client):\n\t\"\"\"Deletes the specified key.\n\tReturns an error if the key doesn't exist\n\t\"\"\"\n\tglobal NOT_FOUND\n\n\tvalidateClient(client)\n\tclient_pub_key = loadClientRSAKey(client)\n\ttoken_data = decodeRequestToken(request.data, client_pub_key)\n\tvalidateKeyName(token_data['key'])\n\n\ttry:\n\t\tos.remove('keys/%s/%s.key' % (client, token_data['key']))\n\texcept FileNotFoundError:\n\t\traise FoxlockError(NOT_FOUND, \"Key '%s' not found\" % token_data['key'])\n\n\treturn \"Key '%s' successfully deleted\" % token_data['key']","lang":"python","vul_type":"cwe-022","target_token_count":127,"sven_meta":{"func_name":"deleteKey","file_name":"impl.py","commit_link":"github.com/Mimickal/FoxLock/commit/7c665e556987f4e2c1a75e143a1e80ae066ad833","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-022#49-641b4cfbd863","input":" def set(self, key, value, replace=False):\n path = os.path.join(self.namespace, key)\n try:\n self.etcd.write(path, value, prevExist=replace)\n except etcd.EtcdAlreadyExist as err:\n raise CSStoreExists(str(err))\n except etcd.EtcdException as err:\n log_error(\"Error storing key %s: [%r]\" % (key, repr(err)))\n raise CSStoreError('Error occurred while trying to store key')","target":" def set(self, key, value, replace=False):\n path = self._absolute_key(key)\n try:\n self.etcd.write(path, value, prevExist=replace)\n except etcd.EtcdAlreadyExist as err:\n raise CSStoreExists(str(err))\n except etcd.EtcdException as err:\n log_error(\"Error storing key %s: [%r]\" % (key, repr(err)))\n raise CSStoreError('Error occurred while trying to store key')","lang":"python","vul_type":"cwe-022","target_token_count":103,"sven_meta":{"func_name":"set","file_name":"custodia/store/etcdstore.py","commit_link":"github.com/latchset/custodia/commit/785fc87f38b4811bc4ce43a0a9b2267ee7d500b4","source_cwe_file":"cwe-022.jsonl"}}
{"problem_id":"cwe-079#7-ef681c040ce3","input":"@register.filter\ndef json_dumps(value, indent=None):\n if isinstance(value, QuerySet):\n result = serialize('json', value, indent=indent)\n else:\n result = json.dumps(value, indent=indent, cls=DjbletsJSONEncoder)\n\n return mark_safe(result)","target":"@register.filter\ndef json_dumps(value, indent=None):\n if isinstance(value, QuerySet):\n result = serialize('json', value, indent=indent)\n else:\n result = json.dumps(value, indent=indent, cls=DjbletsJSONEncoder)\n\n return mark_safe(force_text(result).translate(_safe_js_escapes))","lang":"python","vul_type":"cwe-079","target_token_count":70,"sven_meta":{"func_name":"json_dumps","file_name":"djblets/util/templatetags/djblets_js.py","commit_link":"github.com/djblets/djblets/commit/77a68c03cd619a0996f3f37337b8c39ca6643d6e","source_cwe_file":"cwe-079.jsonl"}}
{"problem_id":"cwe-079#8-9869a184bb30","input":" def htmlvalue(self, val):\n return self.block.render_basic(val)","target":" def htmlvalue(self, val):\n \"\"\"\n Return an HTML representation of this block that is safe to be included\n in comparison views\n \"\"\"\n return escape(text_from_html(self.block.render_basic(val)))","lang":"python","vul_type":"cwe-079","target_token_count":44,"sven_meta":{"func_name":"htmlvalue","file_name":"wagtail/admin/compare.py","commit_link":"github.com/wagtail/wagtail/commit/61045ceefea114c40ac4b680af58990dbe732389","source_cwe_file":"cwe-079.jsonl"}}
{"problem_id":"cwe-079#12-27bf8de1e44d","input":" def get_context_data(self, **kwargs):\n context = super().get_context_data(**kwargs)\n context['comments'] = self.object.comment_set.all().order_by('-time')\n context['form'] = self.get_form()\n context['md'] = markdown(self.object.content,\n extensions=[\n 'markdown.extensions.extra',\n 'markdown.extensions.codehilite',\n 'markdown.extensions.toc',\n ])\n\n return context","target":" def get_context_data(self, **kwargs):\n context = super().get_context_data(**kwargs)\n context['comments'] = self.object.comment_set.all().order_by('-time')\n context['form'] = self.get_form()\n context['md'] = safe_md(self.object.content)\n\n return context","lang":"python","vul_type":"cwe-079","target_token_count":63,"sven_meta":{"func_name":"get_context_data","file_name":"app/Index/views.py","commit_link":"github.com/Cheng-mq1216/production-practice/commit/333dc34f5feada55d1f6ff1255949ca00dec0f9c","source_cwe_file":"cwe-079.jsonl"}}
{"problem_id":"cwe-079#14-5914b850b3e2","input":" @classmethod\n def simple_search(cls, query, using=None, index=None):\n es_search = cls.search(using=using, index=index)\n es_query = cls.get_es_query(query=query)\n highlighted_fields = [f.split('^', 1)[0] for f in cls.search_fields]\n\n es_search = es_search.query(es_query).highlight(*highlighted_fields)\n return es_search","target":" @classmethod\n def simple_search(cls, query, using=None, index=None):\n \"\"\"\n Do a search without facets.\n\n This is used in:\n\n * The Docsearch API\n * The Project Admin Search page\n \"\"\"\n\n es_search = cls.search(using=using, index=index)\n es_search = es_search.highlight_options(encoder='html')\n\n es_query = cls.get_es_query(query=query)\n highlighted_fields = [f.split('^', 1)[0] for f in cls.search_fields]\n es_search = es_search.query(es_query).highlight(*highlighted_fields)\n\n return es_search","lang":"python","vul_type":"cwe-079","target_token_count":127,"sven_meta":{"func_name":"simple_search","file_name":"readthedocs/search/documents.py","commit_link":"github.com/readthedocs/readthedocs.org/commit/1ebe494ffde18109307f205d2bd94102452f697a","source_cwe_file":"cwe-079.jsonl"}}
{"problem_id":"cwe-079#18-d6fc2ce88441","input":"def _keyify(key):\n return _key_pattern.sub(' ', key.lower())","target":"def _keyify(key):\n key = escape(key.lower(), quote=True)\n return _key_pattern.sub(' ', key)","lang":"python","vul_type":"cwe-079","target_token_count":26,"sven_meta":{"func_name":"_keyify","file_name":"mistune.py","commit_link":"github.com/lepture/mistune/commit/5f06d724bc05580e7f203db2d4a4905fc1127f98","source_cwe_file":"cwe-079.jsonl"}}
{"problem_id":"cwe-079#20-544180b3a8dc","input":"def make_eb_config(application_name, default_region):\n # Capture our current directory\n UTILS_DIR = os.path.dirname(os.path.abspath(__file__))\n # Create the jinja2 environment.\n # Notice the use of trim_blocks, which greatly helps control whitespace.\n j2_env = Environment(loader=FileSystemLoader(UTILS_DIR))\n return j2_env.get_template('templates/eb/config.yml').render(\n APPLICATION_NAME=application_name,\n DEFAULT_REGION=default_region\n )","target":"def make_eb_config(application_name, default_region):\n # Capture our current directory\n UTILS_DIR = os.path.dirname(os.path.abspath(__file__))\n # Create the jinja2 environment.\n # Notice the use of trim_blocks, which greatly helps control whitespace.\n j2_env = Environment(loader=FileSystemLoader(UTILS_DIR), autoescape=True)\n return j2_env.get_template('templates/eb/config.yml').render(\n APPLICATION_NAME=application_name,\n DEFAULT_REGION=default_region\n )","lang":"python","vul_type":"cwe-079","target_token_count":106,"sven_meta":{"func_name":"make_eb_config","file_name":"utils/make_eb_config.py","commit_link":"github.com/OkunaOrg/okuna-www-api/commit/8c40c66ea7c483a0cbda4c21940180af909aab99","source_cwe_file":"cwe-079.jsonl"}}
{"problem_id":"cwe-079#21-e935be5d8294","input":" def mode_keepalive(self, request):\n \"\"\"\n This is called by render_POST when the\n client is replying to the keepalive.\n \"\"\"\n csessid = request.args.get('csessid')[0]\n self.last_alive[csessid] = (time.time(), False)\n return '\"\"'","target":" def mode_keepalive(self, request):\n \"\"\"\n This is called by render_POST when the\n client is replying to the keepalive.\n \"\"\"\n csessid = cgi.escape(request.args['csessid'][0])\n self.last_alive[csessid] = (time.time(), False)\n return '\"\"'","lang":"python","vul_type":"cwe-079","target_token_count":70,"sven_meta":{"func_name":"mode_keepalive","file_name":"evennia/server/portal/webclient_ajax.py","commit_link":"github.com/evennia/evennia/commit/300261529b82f95414c9d1d7150d6eda4695bb93","source_cwe_file":"cwe-079.jsonl"}}
{"problem_id":"cwe-079#22-576cdf9d07a6","input":"void Logger::addPeer(const QString &ip, bool blocked, const QString &reason)\n{\n QWriteLocker locker(&lock);\n\n Log::Peer temp = { peerCounter++, QDateTime::currentMSecsSinceEpoch(), ip, blocked, reason };\n m_peers.push_back(temp);\n\n if (m_peers.size() >= MAX_LOG_MESSAGES)\n m_peers.pop_front();\n\n emit newLogPeer(temp);\n}","target":"void Logger::addPeer(const QString &ip, bool blocked, const QString &reason)\n{\n QWriteLocker locker(&lock);\n\n Log::Peer temp = { peerCounter++, QDateTime::currentMSecsSinceEpoch(), Utils::String::toHtmlEscaped(ip), blocked, Utils::String::toHtmlEscaped(reason) };\n m_peers.push_back(temp);\n\n if (m_peers.size() >= MAX_LOG_MESSAGES)\n m_peers.pop_front();\n\n emit newLogPeer(temp);\n}","lang":"cpp","vul_type":"cwe-079","target_token_count":104,"sven_meta":{"func_name":"Logger::addPeer","file_name":"src/base/logger.cpp","commit_link":"github.com/qbittorrent/qBittorrent/commit/6ca3e4f094da0a0017cb2d483ec1db6176bb0b16","source_cwe_file":"cwe-079.jsonl"}}
{"problem_id":"cwe-079#28-2b222187be43","input":" def save(self):\n # copy the user's input from plain text to description to be processed\n self.description = self.description_plain_text\n if CE.settings.auto_cross_reference:\n self.auto_cross_ref()\n else:\n self.find_tag()\n self.slug = slugify(self.title)\n super().save()","target":" def save(self):\n # copy the user's input from plain text to description to be processed\n # uses bleach to remove potentially harmful HTML code\n self.description = bleach.clean(str(self.description_plain_text),\n tags=CE.settings.bleach_allowed,\n strip=True)\n if CE.settings.auto_cross_reference:\n self.auto_cross_ref()\n else:\n self.find_tag()\n self.slug = slugify(self.title)\n super().save()","lang":"python","vul_type":"cwe-079","target_token_count":94,"sven_meta":{"func_name":"save","file_name":"CE/models.py","commit_link":"github.com/stevetasticsteve/CLA_Hub/commit/a06d85cd0b0964f8469e5c4bc9a6c132aa0b4c37","source_cwe_file":"cwe-079.jsonl"}}
{"problem_id":"cwe-079#30-fbdb24f62060","input":" def mode_close(self, request):\n \"\"\"\n This is called by render_POST when the client is signalling\n that it is about to be closed.\n\n Args:\n request (Request): Incoming request.\n\n \"\"\"\n csessid = request.args.get('csessid')[0]\n try:\n sess = self.sessionhandler.sessions_from_csessid(csessid)[0]\n sess.sessionhandler.disconnect(sess)\n except IndexError:\n self.client_disconnect(csessid)\n return '\"\"'","target":" def mode_close(self, request):\n \"\"\"\n This is called by render_POST when the client is signalling\n that it is about to be closed.\n\n Args:\n request (Request): Incoming request.\n\n \"\"\"\n csessid = cgi.escape(request.args['csessid'][0])\n try:\n sess = self.sessionhandler.sessions_from_csessid(csessid)[0]\n sess.sessionhandler.disconnect(sess)\n except IndexError:\n self.client_disconnect(csessid)\n return '\"\"'","lang":"python","vul_type":"cwe-079","target_token_count":105,"sven_meta":{"func_name":"mode_close","file_name":"evennia/server/portal/webclient_ajax.py","commit_link":"github.com/evennia/evennia/commit/300261529b82f95414c9d1d7150d6eda4695bb93","source_cwe_file":"cwe-079.jsonl"}}
{"problem_id":"cwe-079#31-692feaf28db0","input":" def get_queryset(self, **kwargs):\n queryset = Article.objects.order_by('-time')\n for i in queryset:\n i.md = markdown(i.content, extensions=[\n 'markdown.extensions.extra',\n 'markdown.extensions.codehilite',\n 'markdown.extensions.toc',\n ])\n\n return queryset","target":" def get_queryset(self, **kwargs):\n queryset = Article.objects.order_by('-time')\n for i in queryset:\n i.md = safe_md(i.content)\n\n return queryset","lang":"python","vul_type":"cwe-079","target_token_count":37,"sven_meta":{"func_name":"get_queryset","file_name":"app/Index/views.py","commit_link":"github.com/Cheng-mq1216/production-practice/commit/333dc34f5feada55d1f6ff1255949ca00dec0f9c","source_cwe_file":"cwe-079.jsonl"}}
{"problem_id":"cwe-079#39-df317e1ae5be","input":"void Logger::addMessage(const QString &message, const Log::MsgType &type)\n{\n QWriteLocker locker(&lock);\n\n Log::Msg temp = { msgCounter++, QDateTime::currentMSecsSinceEpoch(), type, message };\n m_messages.push_back(temp);\n\n if (m_messages.size() >= MAX_LOG_MESSAGES)\n m_messages.pop_front();\n\n emit newLogMessage(temp);\n}","target":"void Logger::addMessage(const QString &message, const Log::MsgType &type)\n{\n QWriteLocker locker(&lock);\n\n Log::Msg temp = { msgCounter++, QDateTime::currentMSecsSinceEpoch(), type, Utils::String::toHtmlEscaped(message) };\n m_messages.push_back(temp);\n\n if (m_messages.size() >= MAX_LOG_MESSAGES)\n m_messages.pop_front();\n\n emit newLogMessage(temp);\n}","lang":"cpp","vul_type":"cwe-079","target_token_count":91,"sven_meta":{"func_name":"Logger::addMessage","file_name":"src/base/logger.cpp","commit_link":"github.com/qbittorrent/qBittorrent/commit/6ca3e4f094da0a0017cb2d483ec1db6176bb0b16","source_cwe_file":"cwe-079.jsonl"}}
{"problem_id":"cwe-079#40-9a01affe0d76","input":" @handler.unsupported_on_local_server\n @handler.get(handler.HTML)\n def get(self):\n \"\"\"Handle a get request.\"\"\"\n self.render(\n 'login.html', {\n 'apiKey': local_config.ProjectConfig().get('firebase.api_key'),\n 'authDomain': auth.auth_domain(),\n 'dest': self.request.get('dest'),\n })","target":" @handler.unsupported_on_local_server\n @handler.get(handler.HTML)\n def get(self):\n \"\"\"Handle a get request.\"\"\"\n dest = self.request.get('dest')\n base_handler.check_redirect_url(dest)\n\n self.render(\n 'login.html', {\n 'apiKey': local_config.ProjectConfig().get('firebase.api_key'),\n 'authDomain': auth.auth_domain(),\n 'dest': dest,\n })","lang":"python","vul_type":"cwe-079","target_token_count":87,"sven_meta":{"func_name":"get","file_name":"src/appengine/handlers/login.py","commit_link":"github.com/google/clusterfuzz/commit/3d66c1146550eecd4e34d47332a8616b435a21fe","source_cwe_file":"cwe-079.jsonl"}}
{"problem_id":"cwe-079#42-b9eec320d323","input":" @property\n async def html_content(self):\n content = await self.content\n if not content:\n return ''\n return markdown(content)","target":" @property\n async def html_content(self):\n content = markupsafe.escape(await self.content)\n if not content:\n return ''\n return markdown(content)","lang":"python","vul_type":"cwe-079","target_token_count":35,"sven_meta":{"func_name":"html_content","file_name":"models/comment.py","commit_link":"github.com/dongweiming/lyanna/commit/fcefac79e4b7601e81a3b3fe0ad26ab18ee95d7d","source_cwe_file":"cwe-079.jsonl"}}
{"problem_id":"cwe-079#43-87b0eb38c618","input":" def get_context_data(self, *args, **kwargs):\n data = super().get_context_data(*args, **kwargs)\n\n if self.request.GET.get('back', None) is not None:\n data['back_link'] = self.request.GET['back']\n\n return data","target":" def get_context_data(self, *args, **kwargs):\n data = super().get_context_data(*args, **kwargs)\n\n back = self.request.GET.get('back', None)\n parsed_back_url = urllib.parse.urlparse(back)\n\n # We only allow blank scheme, e.g. relative urls to avoid reflected XSS\n if back is not None and parsed_back_url.scheme == \"\":\n data['back_link'] = back\n\n return data","lang":"python","vul_type":"cwe-079","target_token_count":93,"sven_meta":{"func_name":"get_context_data","file_name":"socialsystem/core/views.py","commit_link":"github.com/pirati-web/socialnisystem.cz/commit/1bd25d971ac3f9ac7ae3915cc2dd86b0ceb44b53","source_cwe_file":"cwe-079.jsonl"}}
{"problem_id":"cwe-190#5-c781f360c33f","input":" long WebPImage::getHeaderOffset(byte *data, long data_size,\n byte *header, long header_size) {\n long pos = -1;\n for (long i=0; i < data_size - header_size; i++) {\n if (memcmp(header, &data[i], header_size) == 0) {\n pos = i;\n break;\n }\n }\n return pos;\n }","target":" long WebPImage::getHeaderOffset(byte* data, long data_size, byte* header, long header_size)\n {\n if (data_size < header_size) { return -1; }\n long pos = -1;\n for (long i=0; i < data_size - header_size; i++) {\n if (memcmp(header, &data[i], header_size) == 0) {\n pos = i;\n break;\n }\n }\n return pos;\n }","lang":"cpp","vul_type":"cwe-190","target_token_count":104,"sven_meta":{"func_name":"Exiv2::WebPImage::getHeaderOffset","file_name":"src/webpimage.cpp","commit_link":"github.com/Exiv2/exiv2/commit/e925bc5addd881543fa503470c8a859e112cca62","source_cwe_file":"cwe-190.jsonl"}}
{"problem_id":"cwe-190#20-39c4a938bc37","input":"int mem_check_range(struct rxe_mem *mem, u64 iova, size_t length)\n{\n\tswitch (mem->type) {\n\tcase RXE_MEM_TYPE_DMA:\n\t\treturn 0;\n\n\tcase RXE_MEM_TYPE_MR:\n\tcase RXE_MEM_TYPE_FMR:\n\t\treturn ((iova < mem->iova) ||\n\t\t\t((iova + length) > (mem->iova + mem->length))) ?\n\t\t\t-EFAULT : 0;\n\n\tdefault:\n\t\treturn -EFAULT;\n\t}\n}","target":"int mem_check_range(struct rxe_mem *mem, u64 iova, size_t length)\n{\n\tswitch (mem->type) {\n\tcase RXE_MEM_TYPE_DMA:\n\t\treturn 0;\n\n\tcase RXE_MEM_TYPE_MR:\n\tcase RXE_MEM_TYPE_FMR:\n\t\tif (iova < mem->iova ||\n\t\t length > mem->length ||\n\t\t iova > mem->iova + mem->length - length)\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\n\tdefault:\n\t\treturn -EFAULT;\n\t}\n}","lang":"c","vul_type":"cwe-190","target_token_count":109,"sven_meta":{"func_name":"mem_check_range","file_name":"drivers/infiniband/sw/rxe/rxe_mr.c","commit_link":"github.com/torvalds/linux/commit/647bf3d8a8e5777319da92af672289b2a6c4dc66","source_cwe_file":"cwe-190.jsonl"}}
{"problem_id":"cwe-190#33-3d4adfe350d5","input":"SWFInput_readSBits(SWFInput input, int number)\n{\n\tint num = SWFInput_readBits(input, number);\n\n\tif ( num & (1<<(number-1)) )\n\t\treturn num - (1<<number);\n\telse\n\t\treturn num;\n}","target":"SWFInput_readSBits(SWFInput input, int number)\n{\n\tint num = SWFInput_readBits(input, number);\n\n\tif(number && num & (1<<(number-1)))\n\t\treturn num - (1<<number);\n\telse\n\t\treturn num;\n}","lang":"c","vul_type":"cwe-190","target_token_count":55,"sven_meta":{"func_name":"SWFInput_readSBits","file_name":"src/blocks/input.c","commit_link":"github.com/libming/libming/commit/2223f7a1e431455a1411bee77c90db94a6f8e8fe","source_cwe_file":"cwe-190.jsonl"}}
{"problem_id":"cwe-190#36-d6d83138474a","input":"authDigestNonceLink(digest_nonce_h * nonce)\n{\n assert(nonce != NULL);\n ++nonce->references;\n debugs(29, 9, \"nonce '\" << nonce << \"' now at '\" << nonce->references << \"'.\");\n}","target":"authDigestNonceLink(digest_nonce_h * nonce)\n{\n assert(nonce != NULL);\n ++nonce->references;\n assert(nonce->references != 0); // no overflows\n debugs(29, 9, \"nonce '\" << nonce << \"' now at '\" << nonce->references << \"'.\");\n}","lang":"cpp","vul_type":"cwe-190","target_token_count":68,"sven_meta":{"func_name":"authDigestNonceLink","file_name":"src/auth/digest/Config.cc","commit_link":"github.com/squid-cache/squid/commit/eeebf0f37a72a2de08348e85ae34b02c34e9a811","source_cwe_file":"cwe-190.jsonl"}}
|