prompt stringclasses 1 value | completions listlengths 2 1.33k | labels listlengths 2 1.33k | source stringclasses 1 value | other_info dict | index int64 0 719 | cwe stringclasses 9 values | language stringclasses 6 values |
|---|---|---|---|---|---|---|---|
Determine whether the {function_name} code is vulnerable or not. | [
"def fetch_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, sid)",
" query = (\"SELECT data FROM %s WHERE identifier = '%s';\" %\n (self.table, sid)",
" )",
" res = self._query(query)",
" try:\n data = res.dictresult()[0]['data']\n except IndexError:\n raise ObjectDoesNotExistException(id)\n try:\n ndata = pg.unescape_bytea(data)\n except:\n # insufficient PyGreSQL version\n ndata = data.replace(\"\\\\'\", \"'\")",
" ndata = ndata.replace('\\\\000\\\\001', nonTextToken)\n ndata = ndata.replace('\\\\012', '\\n')\n return ndata"
] | [
1,
0,
1,
0,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 266,
"char_start": 264,
"chars": "$1"
},
{
"char_end": 356,
"char_start": 351,
"chars": ", sid"
}
],
"deleted": [
{
"char_end": 268,
"char_start": 264,
"chars": "'%s'"
},
{
"char_end": 306,
"char_start": 301,
"chars": ", sid"
}
]
},
"commit_link": "github.com/cheshire3/cheshire3/commit/d350363b4ea10f102c24c8f26d7b76b006323e8e",
"file_name": "cheshire3/sql/postgresStore.py",
"func_name": "fetch_data",
"line_changes": {
"added": [
{
"char_end": 271,
"char_start": 207,
"line": " query = (\"SELECT data FROM %s WHERE identifier = $1;\" %\n",
"line_no": 6
},
{
"char_end": 301,
"char_start": 271,
"line": " (self.table)\n",
"line_no": 7
},
{
"char_end": 358,
"char_start": 320,
"line": " res = self._query(query, sid)\n",
"line_no": 9
}
],
"deleted": [
{
"char_end": 273,
"char_start": 207,
"line": " query = (\"SELECT data FROM %s WHERE identifier = '%s';\" %\n",
"line_no": 6
},
{
"char_end": 308,
"char_start": 273,
"line": " (self.table, sid)\n",
"line_no": 7
},
{
"char_end": 360,
"char_start": 327,
"line": " res = self._query(query)\n",
"line_no": 9
}
]
},
"vul_type": "cwe-089"
} | 250 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def fetch_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, sid)",
" query = (\"SELECT data FROM %s WHERE identifier = $1;\" %\n (self.table)",
" )",
" res = self._query(query, sid)",
" try:\n data = res.dictresult()[0]['data']\n except IndexError:\n raise ObjectDoesNotExistException(id)\n try:\n ndata = pg.unescape_bytea(data)\n except:\n # insufficient PyGreSQL version\n ndata = data.replace(\"\\\\'\", \"'\")",
" ndata = ndata.replace('\\\\000\\\\001', nonTextToken)\n ndata = ndata.replace('\\\\012', '\\n')\n return ndata"
] | [
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 266,
"char_start": 264,
"chars": "$1"
},
{
"char_end": 356,
"char_start": 351,
"chars": ", sid"
}
],
"deleted": [
{
"char_end": 268,
"char_start": 264,
"chars": "'%s'"
},
{
"char_end": 306,
"char_start": 301,
"chars": ", sid"
}
]
},
"commit_link": "github.com/cheshire3/cheshire3/commit/d350363b4ea10f102c24c8f26d7b76b006323e8e",
"file_name": "cheshire3/sql/postgresStore.py",
"func_name": "fetch_data",
"line_changes": {
"added": [
{
"char_end": 271,
"char_start": 207,
"line": " query = (\"SELECT data FROM %s WHERE identifier = $1;\" %\n",
"line_no": 6
},
{
"char_end": 301,
"char_start": 271,
"line": " (self.table)\n",
"line_no": 7
},
{
"char_end": 358,
"char_start": 320,
"line": " res = self._query(query, sid)\n",
"line_no": 9
}
],
"deleted": [
{
"char_end": 273,
"char_start": 207,
"line": " query = (\"SELECT data FROM %s WHERE identifier = '%s';\" %\n",
"line_no": 6
},
{
"char_end": 308,
"char_start": 273,
"line": " (self.table, sid)\n",
"line_no": 7
},
{
"char_end": 360,
"char_start": 327,
"line": " res = self._query(query)\n",
"line_no": 9
}
]
},
"vul_type": "cwe-089"
} | 250 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def registerPlayer(name):\n \"\"\"Adds a player to the tournament database.",
" 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.)",
" Args:\n name: the player's full name (need not be unique).\n \"\"\"\n conn = connect()\n cursor = conn.cursor()",
" cursor.execute(\"INSERT INTO players (name) VALUES ('%s')\" % (name,));",
" conn.commit()\n conn.close()"
] | [
1,
1,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 356,
"char_start": 355,
"chars": "q"
},
{
"char_end": 363,
"char_start": 358,
"chars": "ry = "
},
{
"char_end": 403,
"char_start": 402,
"chars": ";"
},
{
"char_end": 405,
"char_start": 404,
"chars": "\n"
},
{
"char_end": 430,
"char_start": 406,
"chars": " cursor.execute(query,"
}
],
"deleted": [
{
"char_end": 356,
"char_start": 355,
"chars": "c"
},
{
"char_end": 360,
"char_start": 357,
"chars": "rso"
},
{
"char_end": 370,
"char_start": 361,
"chars": ".execute("
},
{
"char_end": 407,
"char_start": 406,
"chars": "'"
},
{
"char_end": 410,
"char_start": 409,
"chars": "'"
},
{
"char_end": 414,
"char_start": 413,
"chars": "%"
},
{
"char_end": 424,
"char_start": 423,
"chars": ";"
}
]
},
"commit_link": "github.com/sarahkcaplan/tournament/commit/40aba5686059f5f398f6323b1483412c56140cc0",
"file_name": "tournament.py",
"func_name": "registerPlayer",
"line_changes": {
"added": [
{
"char_end": 405,
"char_start": 351,
"line": " query = \"INSERT INTO players (name) VALUES (%s);\"\n",
"line_no": 12
},
{
"char_end": 440,
"char_start": 405,
"line": " cursor.execute(query, (name,))\n",
"line_no": 13
}
],
"deleted": [
{
"char_end": 425,
"char_start": 351,
"line": " cursor.execute(\"INSERT INTO players (name) VALUES ('%s')\" % (name,));\n",
"line_no": 12
}
]
},
"vul_type": "cwe-089"
} | 251 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def registerPlayer(name):\n \"\"\"Adds a player to the tournament database.",
" 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.)",
" Args:\n name: the player's full name (need not be unique).\n \"\"\"\n conn = connect()\n cursor = conn.cursor()",
" query = \"INSERT INTO players (name) VALUES (%s);\"\n cursor.execute(query, (name,))",
" conn.commit()\n conn.close()"
] | [
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 356,
"char_start": 355,
"chars": "q"
},
{
"char_end": 363,
"char_start": 358,
"chars": "ry = "
},
{
"char_end": 403,
"char_start": 402,
"chars": ";"
},
{
"char_end": 405,
"char_start": 404,
"chars": "\n"
},
{
"char_end": 430,
"char_start": 406,
"chars": " cursor.execute(query,"
}
],
"deleted": [
{
"char_end": 356,
"char_start": 355,
"chars": "c"
},
{
"char_end": 360,
"char_start": 357,
"chars": "rso"
},
{
"char_end": 370,
"char_start": 361,
"chars": ".execute("
},
{
"char_end": 407,
"char_start": 406,
"chars": "'"
},
{
"char_end": 410,
"char_start": 409,
"chars": "'"
},
{
"char_end": 414,
"char_start": 413,
"chars": "%"
},
{
"char_end": 424,
"char_start": 423,
"chars": ";"
}
]
},
"commit_link": "github.com/sarahkcaplan/tournament/commit/40aba5686059f5f398f6323b1483412c56140cc0",
"file_name": "tournament.py",
"func_name": "registerPlayer",
"line_changes": {
"added": [
{
"char_end": 405,
"char_start": 351,
"line": " query = \"INSERT INTO players (name) VALUES (%s);\"\n",
"line_no": 12
},
{
"char_end": 440,
"char_start": 405,
"line": " cursor.execute(query, (name,))\n",
"line_no": 13
}
],
"deleted": [
{
"char_end": 425,
"char_start": 351,
"line": " cursor.execute(\"INSERT INTO players (name) VALUES ('%s')\" % (name,));\n",
"line_no": 12
}
]
},
"vul_type": "cwe-089"
} | 251 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@mod.route('/register', methods=['GET', 'POST'])\ndef register():\n if request.method == 'POST':\n error = None\n email = request.form['email'].strip()\n nickname = request.form['nickname'].strip()\n password = request.form['password'].strip()\n password2 = request.form['password2'].strip()",
" email = email.lower()",
" if email == \"\" or nickname == \"\" or password == \"\" or password2 == \"\":\n error = 'Please input all the information'\n elif password2 != password:\n error = 'The password is not repeated correctly'\n elif len(password) < 6:\n error = 'The password has at least 6 characters'\n elif not re.match(r'^[0-9a-zA-Z_]{0,19}@' +\n '[0-9a-zA-Z]{1,15}\\.[com,cn,net]', email):\n error = 'Please input the right email'\n",
" sql = \"SELECT * FROM users where email = '%s';\" % (email)\n cursor.execute(sql)",
" u = cursor.fetchone()",
" if u is not None:\n error = 'The email has already exsit'",
" if error is not None:\n return render_template('register.html', error=error)\n else:\n password = bcrypt.generate_password_hash(password)\n cursor.execute(\"INSERT INTO users(email,nickname,password) VALUES(%s,%s,%s);\", (email, nickname, password))\n conn.commit()\n flash('Register Success!')\n return redirect(url_for('users.login'))",
" return render_template('register.html')"
] | [
1,
1,
1,
0,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 863,
"char_start": 860,
"chars": "cur"
},
{
"char_end": 875,
"char_start": 864,
"chars": "or.execute("
},
{
"char_end": 915,
"char_start": 914,
"chars": ","
},
{
"char_end": 923,
"char_start": 922,
"chars": ","
}
],
"deleted": [
{
"char_end": 866,
"char_start": 861,
"chars": "ql = "
},
{
"char_end": 902,
"char_start": 901,
"chars": "'"
},
{
"char_end": 905,
"char_start": 904,
"chars": "'"
},
{
"char_end": 909,
"char_start": 907,
"chars": " %"
},
{
"char_end": 944,
"char_start": 917,
"chars": "\n cursor.execute(sql"
}
]
},
"commit_link": "github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9",
"file_name": "flaskr/flaskr/views/users.py",
"func_name": "register",
"line_changes": {
"added": [
{
"char_end": 926,
"char_start": 852,
"line": " cursor.execute(\"SELECT * FROM users where email = %s;\", (email,))\n",
"line_no": 22
}
],
"deleted": [
{
"char_end": 918,
"char_start": 852,
"line": " sql = \"SELECT * FROM users where email = '%s';\" % (email)\n",
"line_no": 22
},
{
"char_end": 946,
"char_start": 918,
"line": " cursor.execute(sql)\n",
"line_no": 23
}
]
},
"vul_type": "cwe-089"
} | 252 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@mod.route('/register', methods=['GET', 'POST'])\ndef register():\n if request.method == 'POST':\n error = None\n email = request.form['email'].strip()\n nickname = request.form['nickname'].strip()\n password = request.form['password'].strip()\n password2 = request.form['password2'].strip()",
" email = email.lower()",
" if email == \"\" or nickname == \"\" or password == \"\" or password2 == \"\":\n error = 'Please input all the information'\n elif password2 != password:\n error = 'The password is not repeated correctly'\n elif len(password) < 6:\n error = 'The password has at least 6 characters'\n elif not re.match(r'^[0-9a-zA-Z_]{0,19}@' +\n '[0-9a-zA-Z]{1,15}\\.[com,cn,net]', email):\n error = 'Please input the right email'\n",
" cursor.execute(\"SELECT * FROM users where email = %s;\", (email,))",
" u = cursor.fetchone()",
" if u is not None:\n error = 'The email has already exsit'",
" if error is not None:\n return render_template('register.html', error=error)\n else:\n password = bcrypt.generate_password_hash(password)\n cursor.execute(\"INSERT INTO users(email,nickname,password) VALUES(%s,%s,%s);\", (email, nickname, password))\n conn.commit()\n flash('Register Success!')\n return redirect(url_for('users.login'))",
" return render_template('register.html')"
] | [
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 863,
"char_start": 860,
"chars": "cur"
},
{
"char_end": 875,
"char_start": 864,
"chars": "or.execute("
},
{
"char_end": 915,
"char_start": 914,
"chars": ","
},
{
"char_end": 923,
"char_start": 922,
"chars": ","
}
],
"deleted": [
{
"char_end": 866,
"char_start": 861,
"chars": "ql = "
},
{
"char_end": 902,
"char_start": 901,
"chars": "'"
},
{
"char_end": 905,
"char_start": 904,
"chars": "'"
},
{
"char_end": 909,
"char_start": 907,
"chars": " %"
},
{
"char_end": 944,
"char_start": 917,
"chars": "\n cursor.execute(sql"
}
]
},
"commit_link": "github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9",
"file_name": "flaskr/flaskr/views/users.py",
"func_name": "register",
"line_changes": {
"added": [
{
"char_end": 926,
"char_start": 852,
"line": " cursor.execute(\"SELECT * FROM users where email = %s;\", (email,))\n",
"line_no": 22
}
],
"deleted": [
{
"char_end": 918,
"char_start": 852,
"line": " sql = \"SELECT * FROM users where email = '%s';\" % (email)\n",
"line_no": 22
},
{
"char_end": 946,
"char_start": 918,
"line": " cursor.execute(sql)\n",
"line_no": 23
}
]
},
"vul_type": "cwe-089"
} | 252 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def process_form():\n # see https://docs.python.org/3.4/library/cgi.html for the basic usage\n # here.\n form = cgi.FieldStorage()",
"\n # connect to the database\n conn = MySQLdb.connect(host = pnsdp.SQL_HOST,\n user = pnsdp.SQL_USER,\n passwd = pnsdp.SQL_PASSWD,\n db = pnsdp.SQL_DB)",
"\n if \"user\" not in form or \"game\" not in form:\n raise FormError(\"Invalid parameters.\")\n if \"pos\" not in form and \"resign\" not in form:\n raise FormError(\"Invalid parameters.\")",
" game = int(form[\"game\"].value)",
"\n (players,size,state) = get_game_info(conn, game)",
" user = form[\"user\"].value\n if user not in players:\n raise FormError(\"Invalid player ID - player is not part of this game\")",
"\n if \"resign\" in form:\n resign = True\n else:\n resign = False\n pos = form[\"pos\"].value.split(\",\")\n assert len(pos) == 2\n x = int(pos[0])\n y = int(pos[1])",
"\n (board,nextPlayer,letter) = build_board(conn, game,size)",
" if user != players[nextPlayer]:\n raise FormError(\"Internal error, incorrect player is attempting to move.\")",
"\n if resign:\n # this user is choosing to resign. Update the game state to reflect that.\n other_player_name = players[1-nextPlayer]",
" cursor = conn.cursor()",
" cursor.execute(\"\"\"UPDATE games SET state=\"%s:resignation\" WHERE id=%d;\"\"\" % (other_player_name,game))",
" cursor.close()",
" else:\n assert x >= 0 and x < size\n assert y >= 0 and y < size",
" assert board[x][y] == \"\"\n board[x][y] = \"XO\"[nextPlayer]",
" # we've done all of our sanity checks. We now know enough to say that\n # it's safe to add a new move.\n cursor = conn.cursor()",
" cursor.execute(\"\"\"INSERT INTO moves(gameID,x,y,letter,time) VALUES(%d,%d,%d,\"%s\",NOW());\"\"\" % (game,x,y,letter))",
"\n if cursor.rowcount != 1:\n raise FormError(\"Could not make move, reason unknown.\")",
" cursor.close()",
" result = analyze_board(board)\n if result != \"\":\n if result == \"win\":\n result = players[nextPlayer]+\":win\"",
" cursor = conn.cursor()",
" cursor.execute(\"\"\"UPDATE games SET state=\"%s\" WHERE id=%d;\"\"\" % (result,game))",
" cursor.close()",
" # we've made changes, make sure to commit them!\n conn.commit()\n conn.close()",
"\n # return the parms to the caller, so that they can build a good redirect\n return (user,game)"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
0,
1,
1,
1,
1,
0,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1451,
"char_start": 1450,
"chars": ","
},
{
"char_end": 1905,
"char_start": 1904,
"chars": ","
},
{
"char_end": 2309,
"char_start": 2308,
"chars": ","
}
],
"deleted": [
{
"char_end": 1452,
"char_start": 1450,
"chars": " %"
},
{
"char_end": 1907,
"char_start": 1905,
"chars": " %"
},
{
"char_end": 2312,
"char_start": 2310,
"chars": " %"
}
]
},
"commit_link": "github.com/russ-lewis/ttt_-_python_cgi/commit/6096f43fd4b2d91211eec4614b7960c0816900da",
"file_name": "cgi/move.py",
"func_name": "process_form",
"line_changes": {
"added": [
{
"char_end": 1478,
"char_start": 1369,
"line": " cursor.execute(\"\"\"UPDATE games SET state=\"%s:resignation\" WHERE id=%d;\"\"\", (other_player_name,game))\n",
"line_no": 50
},
{
"char_end": 1925,
"char_start": 1805,
"line": " cursor.execute(\"\"\"INSERT INTO moves(gameID,x,y,letter,time) VALUES(%d,%d,%d,\"%s\",NOW());\"\"\", (game,x,y,letter))\n",
"line_no": 63
},
{
"char_end": 2325,
"char_start": 2235,
"line": " cursor.execute(\"\"\"UPDATE games SET state=\"%s\" WHERE id=%d;\"\"\", (result,game))\n",
"line_no": 76
}
],
"deleted": [
{
"char_end": 1479,
"char_start": 1369,
"line": " cursor.execute(\"\"\"UPDATE games SET state=\"%s:resignation\" WHERE id=%d;\"\"\" % (other_player_name,game))\n",
"line_no": 50
},
{
"char_end": 1927,
"char_start": 1806,
"line": " cursor.execute(\"\"\"INSERT INTO moves(gameID,x,y,letter,time) VALUES(%d,%d,%d,\"%s\",NOW());\"\"\" % (game,x,y,letter))\n",
"line_no": 63
},
{
"char_end": 2328,
"char_start": 2237,
"line": " cursor.execute(\"\"\"UPDATE games SET state=\"%s\" WHERE id=%d;\"\"\" % (result,game))\n",
"line_no": 76
}
]
},
"vul_type": "cwe-089"
} | 253 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def process_form():\n # see https://docs.python.org/3.4/library/cgi.html for the basic usage\n # here.\n form = cgi.FieldStorage()",
"\n # connect to the database\n conn = MySQLdb.connect(host = pnsdp.SQL_HOST,\n user = pnsdp.SQL_USER,\n passwd = pnsdp.SQL_PASSWD,\n db = pnsdp.SQL_DB)",
"\n if \"user\" not in form or \"game\" not in form:\n raise FormError(\"Invalid parameters.\")\n if \"pos\" not in form and \"resign\" not in form:\n raise FormError(\"Invalid parameters.\")",
" game = int(form[\"game\"].value)",
"\n (players,size,state) = get_game_info(conn, game)",
" user = form[\"user\"].value\n if user not in players:\n raise FormError(\"Invalid player ID - player is not part of this game\")",
"\n if \"resign\" in form:\n resign = True\n else:\n resign = False\n pos = form[\"pos\"].value.split(\",\")\n assert len(pos) == 2\n x = int(pos[0])\n y = int(pos[1])",
"\n (board,nextPlayer,letter) = build_board(conn, game,size)",
" if user != players[nextPlayer]:\n raise FormError(\"Internal error, incorrect player is attempting to move.\")",
"\n if resign:\n # this user is choosing to resign. Update the game state to reflect that.\n other_player_name = players[1-nextPlayer]",
" cursor = conn.cursor()",
" cursor.execute(\"\"\"UPDATE games SET state=\"%s:resignation\" WHERE id=%d;\"\"\", (other_player_name,game))",
" cursor.close()",
" else:\n assert x >= 0 and x < size\n assert y >= 0 and y < size",
" assert board[x][y] == \"\"\n board[x][y] = \"XO\"[nextPlayer]",
" # we've done all of our sanity checks. We now know enough to say that\n # it's safe to add a new move.\n cursor = conn.cursor()",
" cursor.execute(\"\"\"INSERT INTO moves(gameID,x,y,letter,time) VALUES(%d,%d,%d,\"%s\",NOW());\"\"\", (game,x,y,letter))",
"\n if cursor.rowcount != 1:\n raise FormError(\"Could not make move, reason unknown.\")",
" cursor.close()",
" result = analyze_board(board)\n if result != \"\":\n if result == \"win\":\n result = players[nextPlayer]+\":win\"",
" cursor = conn.cursor()",
" cursor.execute(\"\"\"UPDATE games SET state=\"%s\" WHERE id=%d;\"\"\", (result,game))",
" cursor.close()",
" # we've made changes, make sure to commit them!\n conn.commit()\n conn.close()",
"\n # return the parms to the caller, so that they can build a good redirect\n return (user,game)"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1451,
"char_start": 1450,
"chars": ","
},
{
"char_end": 1905,
"char_start": 1904,
"chars": ","
},
{
"char_end": 2309,
"char_start": 2308,
"chars": ","
}
],
"deleted": [
{
"char_end": 1452,
"char_start": 1450,
"chars": " %"
},
{
"char_end": 1907,
"char_start": 1905,
"chars": " %"
},
{
"char_end": 2312,
"char_start": 2310,
"chars": " %"
}
]
},
"commit_link": "github.com/russ-lewis/ttt_-_python_cgi/commit/6096f43fd4b2d91211eec4614b7960c0816900da",
"file_name": "cgi/move.py",
"func_name": "process_form",
"line_changes": {
"added": [
{
"char_end": 1478,
"char_start": 1369,
"line": " cursor.execute(\"\"\"UPDATE games SET state=\"%s:resignation\" WHERE id=%d;\"\"\", (other_player_name,game))\n",
"line_no": 50
},
{
"char_end": 1925,
"char_start": 1805,
"line": " cursor.execute(\"\"\"INSERT INTO moves(gameID,x,y,letter,time) VALUES(%d,%d,%d,\"%s\",NOW());\"\"\", (game,x,y,letter))\n",
"line_no": 63
},
{
"char_end": 2325,
"char_start": 2235,
"line": " cursor.execute(\"\"\"UPDATE games SET state=\"%s\" WHERE id=%d;\"\"\", (result,game))\n",
"line_no": 76
}
],
"deleted": [
{
"char_end": 1479,
"char_start": 1369,
"line": " cursor.execute(\"\"\"UPDATE games SET state=\"%s:resignation\" WHERE id=%d;\"\"\" % (other_player_name,game))\n",
"line_no": 50
},
{
"char_end": 1927,
"char_start": 1806,
"line": " cursor.execute(\"\"\"INSERT INTO moves(gameID,x,y,letter,time) VALUES(%d,%d,%d,\"%s\",NOW());\"\"\" % (game,x,y,letter))\n",
"line_no": 63
},
{
"char_end": 2328,
"char_start": 2237,
"line": " cursor.execute(\"\"\"UPDATE games SET state=\"%s\" WHERE id=%d;\"\"\" % (result,game))\n",
"line_no": 76
}
]
},
"vul_type": "cwe-089"
} | 253 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@login_manager.user_loader\ndef load_user(s_id):\n email = str(s_id)",
" query = '''select * from usr where email like\\'''' + email + '\\''\n cursor = g.conn.execute(query)",
" user = User()\n for row in cursor:\n user.name = str(row.name)\n user.email = str(row.email)\n break\n return user"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 120,
"char_start": 118,
"chars": "%s"
},
{
"char_end": 166,
"char_start": 155,
"chars": ", (email, )"
}
],
"deleted": [
{
"char_end": 85,
"char_start": 83,
"chars": "''"
},
{
"char_end": 124,
"char_start": 119,
"chars": "\\''''"
},
{
"char_end": 138,
"char_start": 125,
"chars": "+ email + '\\'"
}
]
},
"commit_link": "github.com/Daniel-Bu/w4111-project1/commit/fe04bedc72e62fd4c4ee046a9af29fd81e9b3340",
"file_name": "Web-app/Server.py",
"func_name": "load_user",
"line_changes": {
"added": [
{
"char_end": 122,
"char_start": 70,
"line": " query = 'select * from usr where email like %s'\n",
"line_no": 4
},
{
"char_end": 168,
"char_start": 122,
"line": " cursor = g.conn.execute(query, (email, ))\n",
"line_no": 5
}
],
"deleted": [
{
"char_end": 140,
"char_start": 70,
"line": " query = '''select * from usr where email like\\'''' + email + '\\''\n",
"line_no": 4
},
{
"char_end": 175,
"char_start": 140,
"line": " cursor = g.conn.execute(query)\n",
"line_no": 5
}
]
},
"vul_type": "cwe-089"
} | 254 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@login_manager.user_loader\ndef load_user(s_id):\n email = str(s_id)",
" query = 'select * from usr where email like %s'\n cursor = g.conn.execute(query, (email, ))",
" user = User()\n for row in cursor:\n user.name = str(row.name)\n user.email = str(row.email)\n break\n return user"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 120,
"char_start": 118,
"chars": "%s"
},
{
"char_end": 166,
"char_start": 155,
"chars": ", (email, )"
}
],
"deleted": [
{
"char_end": 85,
"char_start": 83,
"chars": "''"
},
{
"char_end": 124,
"char_start": 119,
"chars": "\\''''"
},
{
"char_end": 138,
"char_start": 125,
"chars": "+ email + '\\'"
}
]
},
"commit_link": "github.com/Daniel-Bu/w4111-project1/commit/fe04bedc72e62fd4c4ee046a9af29fd81e9b3340",
"file_name": "Web-app/Server.py",
"func_name": "load_user",
"line_changes": {
"added": [
{
"char_end": 122,
"char_start": 70,
"line": " query = 'select * from usr where email like %s'\n",
"line_no": 4
},
{
"char_end": 168,
"char_start": 122,
"line": " cursor = g.conn.execute(query, (email, ))\n",
"line_no": 5
}
],
"deleted": [
{
"char_end": 140,
"char_start": 70,
"line": " query = '''select * from usr where email like\\'''' + email + '\\''\n",
"line_no": 4
},
{
"char_end": 175,
"char_start": 140,
"line": " cursor = g.conn.execute(query)\n",
"line_no": 5
}
]
},
"vul_type": "cwe-089"
} | 254 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@mod.route('/delete/<int:cmt_id>', methods=['GET', 'POST'])\ndef delete(cmt_id):\n if request.method == 'GET':",
" sql = \"SELECT msg_id FROM comment where cmt_id = %d;\" % (cmt_id)\n cursor.execute(sql)",
" m = cursor.fetchone()",
" sql = \"DELETE FROM comment where cmt_id = '%d';\" % (cmt_id)\n cursor.execute(sql)",
" conn.commit()\n flash('Delete Success!')\n return redirect(url_for('comment.show', msg_id=m[0]))"
] | [
1,
0,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 123,
"char_start": 120,
"chars": "cur"
},
{
"char_end": 135,
"char_start": 124,
"chars": "or.execute("
},
{
"char_end": 180,
"char_start": 179,
"chars": "s"
},
{
"char_end": 183,
"char_start": 182,
"chars": ","
},
{
"char_end": 193,
"char_start": 191,
"chars": ",)"
},
{
"char_end": 207,
"char_start": 203,
"chars": "m = "
},
{
"char_end": 215,
"char_start": 214,
"chars": "f"
},
{
"char_end": 221,
"char_start": 217,
"chars": "chon"
},
{
"char_end": 245,
"char_start": 241,
"chars": "xecu"
},
{
"char_end": 286,
"char_start": 285,
"chars": "s"
},
{
"char_end": 289,
"char_start": 288,
"chars": ","
},
{
"char_end": 298,
"char_start": 297,
"chars": ","
}
],
"deleted": [
{
"char_end": 126,
"char_start": 121,
"chars": "ql = "
},
{
"char_end": 171,
"char_start": 170,
"chars": "d"
},
{
"char_end": 175,
"char_start": 173,
"chars": " %"
},
{
"char_end": 211,
"char_start": 184,
"chars": "\n cursor.execute(sql"
},
{
"char_end": 257,
"char_start": 252,
"chars": "ql = "
},
{
"char_end": 294,
"char_start": 293,
"chars": "'"
},
{
"char_end": 297,
"char_start": 295,
"chars": "d'"
},
{
"char_end": 301,
"char_start": 299,
"chars": " %"
},
{
"char_end": 337,
"char_start": 310,
"chars": "\n cursor.execute(sql"
}
]
},
"commit_link": "github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9",
"file_name": "flaskr/flaskr/views/comment.py",
"func_name": "delete",
"line_changes": {
"added": [
{
"char_end": 195,
"char_start": 112,
"line": " cursor.execute(\"SELECT msg_id FROM comment where cmt_id = %s;\", (cmt_id,))\n",
"line_no": 4
},
{
"char_end": 301,
"char_start": 225,
"line": " cursor.execute(\"DELETE FROM comment where cmt_id = %s;\", (cmt_id,))\n",
"line_no": 6
}
],
"deleted": [
{
"char_end": 185,
"char_start": 112,
"line": " sql = \"SELECT msg_id FROM comment where cmt_id = %d;\" % (cmt_id)\n",
"line_no": 4
},
{
"char_end": 213,
"char_start": 185,
"line": " cursor.execute(sql)\n",
"line_no": 5
},
{
"char_end": 311,
"char_start": 243,
"line": " sql = \"DELETE FROM comment where cmt_id = '%d';\" % (cmt_id)\n",
"line_no": 7
},
{
"char_end": 339,
"char_start": 311,
"line": " cursor.execute(sql)\n",
"line_no": 8
}
]
},
"vul_type": "cwe-089"
} | 255 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@mod.route('/delete/<int:cmt_id>', methods=['GET', 'POST'])\ndef delete(cmt_id):\n if request.method == 'GET':",
" cursor.execute(\"SELECT msg_id FROM comment where cmt_id = %s;\", (cmt_id,))",
" m = cursor.fetchone()",
" cursor.execute(\"DELETE FROM comment where cmt_id = %s;\", (cmt_id,))",
" conn.commit()\n flash('Delete Success!')\n return redirect(url_for('comment.show', msg_id=m[0]))"
] | [
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 123,
"char_start": 120,
"chars": "cur"
},
{
"char_end": 135,
"char_start": 124,
"chars": "or.execute("
},
{
"char_end": 180,
"char_start": 179,
"chars": "s"
},
{
"char_end": 183,
"char_start": 182,
"chars": ","
},
{
"char_end": 193,
"char_start": 191,
"chars": ",)"
},
{
"char_end": 207,
"char_start": 203,
"chars": "m = "
},
{
"char_end": 215,
"char_start": 214,
"chars": "f"
},
{
"char_end": 221,
"char_start": 217,
"chars": "chon"
},
{
"char_end": 245,
"char_start": 241,
"chars": "xecu"
},
{
"char_end": 286,
"char_start": 285,
"chars": "s"
},
{
"char_end": 289,
"char_start": 288,
"chars": ","
},
{
"char_end": 298,
"char_start": 297,
"chars": ","
}
],
"deleted": [
{
"char_end": 126,
"char_start": 121,
"chars": "ql = "
},
{
"char_end": 171,
"char_start": 170,
"chars": "d"
},
{
"char_end": 175,
"char_start": 173,
"chars": " %"
},
{
"char_end": 211,
"char_start": 184,
"chars": "\n cursor.execute(sql"
},
{
"char_end": 257,
"char_start": 252,
"chars": "ql = "
},
{
"char_end": 294,
"char_start": 293,
"chars": "'"
},
{
"char_end": 297,
"char_start": 295,
"chars": "d'"
},
{
"char_end": 301,
"char_start": 299,
"chars": " %"
},
{
"char_end": 337,
"char_start": 310,
"chars": "\n cursor.execute(sql"
}
]
},
"commit_link": "github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9",
"file_name": "flaskr/flaskr/views/comment.py",
"func_name": "delete",
"line_changes": {
"added": [
{
"char_end": 195,
"char_start": 112,
"line": " cursor.execute(\"SELECT msg_id FROM comment where cmt_id = %s;\", (cmt_id,))\n",
"line_no": 4
},
{
"char_end": 301,
"char_start": 225,
"line": " cursor.execute(\"DELETE FROM comment where cmt_id = %s;\", (cmt_id,))\n",
"line_no": 6
}
],
"deleted": [
{
"char_end": 185,
"char_start": 112,
"line": " sql = \"SELECT msg_id FROM comment where cmt_id = %d;\" % (cmt_id)\n",
"line_no": 4
},
{
"char_end": 213,
"char_start": 185,
"line": " cursor.execute(sql)\n",
"line_no": 5
},
{
"char_end": 311,
"char_start": 243,
"line": " sql = \"DELETE FROM comment where cmt_id = '%d';\" % (cmt_id)\n",
"line_no": 7
},
{
"char_end": 339,
"char_start": 311,
"line": " cursor.execute(sql)\n",
"line_no": 8
}
]
},
"vul_type": "cwe-089"
} | 255 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route('/get_markets')\ndef get_markets():\n asset_id = request.args.get('asset_id')",
" if not isObject(asset_id):\n ws.send('{\"id\":1, \"method\":\"call\", \"params\":[0,\"lookup_asset_symbols\",[[\"' + asset_id + '\"], 0]]}')\n result_l = ws.recv()\n j_l = json.loads(result_l)\n asset_id = j_l[\"result\"][0][\"id\"]",
"\n con = psycopg2.connect(**config.POSTGRES)\n cur = con.cursor()\n",
" query = \"SELECT * FROM markets WHERE aid='\"+asset_id+\"'\"\n cur.execute(query)",
" results = cur.fetchall()\n con.close()\n return jsonify(results)"
] | [
1,
1,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 454,
"char_start": 453,
"chars": "%"
},
{
"char_end": 491,
"char_start": 478,
"chars": ", (asset_id,)"
}
],
"deleted": [
{
"char_end": 457,
"char_start": 453,
"chars": "'\"+a"
},
{
"char_end": 467,
"char_start": 458,
"chars": "set_id+\"'"
}
]
},
"commit_link": "github.com/VinChain/vinchain-python-api-backend/commit/b78088a551fbb712121269c6eb7f43ede120ff60",
"file_name": "api.py",
"func_name": "get_markets",
"line_changes": {
"added": [
{
"char_end": 457,
"char_start": 408,
"line": " query = \"SELECT * FROM markets WHERE aid=%s\"\n",
"line_no": 15
},
{
"char_end": 493,
"char_start": 457,
"line": " cur.execute(query, (asset_id,))\n",
"line_no": 16
}
],
"deleted": [
{
"char_end": 469,
"char_start": 408,
"line": " query = \"SELECT * FROM markets WHERE aid='\"+asset_id+\"'\"\n",
"line_no": 15
},
{
"char_end": 492,
"char_start": 469,
"line": " cur.execute(query)\n",
"line_no": 16
}
]
},
"vul_type": "cwe-089"
} | 256 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route('/get_markets')\ndef get_markets():\n asset_id = request.args.get('asset_id')",
" if not isObject(asset_id):\n ws.send('{\"id\":1, \"method\":\"call\", \"params\":[0,\"lookup_asset_symbols\",[[\"' + asset_id + '\"], 0]]}')\n result_l = ws.recv()\n j_l = json.loads(result_l)\n asset_id = j_l[\"result\"][0][\"id\"]",
"\n con = psycopg2.connect(**config.POSTGRES)\n cur = con.cursor()\n",
" query = \"SELECT * FROM markets WHERE aid=%s\"\n cur.execute(query, (asset_id,))",
" results = cur.fetchall()\n con.close()\n return jsonify(results)"
] | [
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 454,
"char_start": 453,
"chars": "%"
},
{
"char_end": 491,
"char_start": 478,
"chars": ", (asset_id,)"
}
],
"deleted": [
{
"char_end": 457,
"char_start": 453,
"chars": "'\"+a"
},
{
"char_end": 467,
"char_start": 458,
"chars": "set_id+\"'"
}
]
},
"commit_link": "github.com/VinChain/vinchain-python-api-backend/commit/b78088a551fbb712121269c6eb7f43ede120ff60",
"file_name": "api.py",
"func_name": "get_markets",
"line_changes": {
"added": [
{
"char_end": 457,
"char_start": 408,
"line": " query = \"SELECT * FROM markets WHERE aid=%s\"\n",
"line_no": 15
},
{
"char_end": 493,
"char_start": 457,
"line": " cur.execute(query, (asset_id,))\n",
"line_no": 16
}
],
"deleted": [
{
"char_end": 469,
"char_start": 408,
"line": " query = \"SELECT * FROM markets WHERE aid='\"+asset_id+\"'\"\n",
"line_no": 15
},
{
"char_end": 492,
"char_start": 469,
"line": " cur.execute(query)\n",
"line_no": 16
}
]
},
"vul_type": "cwe-089"
} | 256 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_secrets(self, from_date_added=0):\n\t\tsecrets = []",
"\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):",
"\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)"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 162,
"char_start": 161,
"chars": "?"
},
{
"char_end": 189,
"char_start": 188,
"chars": ","
},
{
"char_end": 191,
"char_start": 190,
"chars": "("
},
{
"char_end": 208,
"char_start": 206,
"chars": ",)"
}
],
"deleted": [
{
"char_end": 163,
"char_start": 161,
"chars": "%s"
},
{
"char_end": 191,
"char_start": 189,
"chars": " %"
}
]
},
"commit_link": "github.com/imachug/ZeroMailProxy/commit/8f62d024c6c4c957079d147e59f26d15c07dc888",
"file_name": "zeromail.py",
"func_name": "get_secrets",
"line_changes": {
"added": [
{
"char_end": 211,
"char_start": 58,
"line": "\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",
"line_no": 3
}
],
"deleted": [
{
"char_end": 210,
"char_start": 58,
"line": "\t\tfor row in self.cursor.execute('SELECT encrypted, json_id, date_added FROM secret WHERE date_added > %s ORDER BY date_added DESC' % from_date_added):\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 257 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_secrets(self, from_date_added=0):\n\t\tsecrets = []",
"\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,)):",
"\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)"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 162,
"char_start": 161,
"chars": "?"
},
{
"char_end": 189,
"char_start": 188,
"chars": ","
},
{
"char_end": 191,
"char_start": 190,
"chars": "("
},
{
"char_end": 208,
"char_start": 206,
"chars": ",)"
}
],
"deleted": [
{
"char_end": 163,
"char_start": 161,
"chars": "%s"
},
{
"char_end": 191,
"char_start": 189,
"chars": " %"
}
]
},
"commit_link": "github.com/imachug/ZeroMailProxy/commit/8f62d024c6c4c957079d147e59f26d15c07dc888",
"file_name": "zeromail.py",
"func_name": "get_secrets",
"line_changes": {
"added": [
{
"char_end": 211,
"char_start": 58,
"line": "\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",
"line_no": 3
}
],
"deleted": [
{
"char_end": 210,
"char_start": 58,
"line": "\t\tfor row in self.cursor.execute('SELECT encrypted, json_id, date_added FROM secret WHERE date_added > %s ORDER BY date_added DESC' % from_date_added):\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 257 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def add_consumption_data_row(self, ts, energy_used, power_used):",
" if power_used > 0:",
" query = '''\n INSERT OR IGNORE INTO Consumption (\n TimeStamp,\n EnergyUsed,\n PowerUsed \n ) VALUES (",
" %s,\n %s,\n %s",
" );",
" ''' % (ts, 0, 0)\n self.c.execute(query)",
"\n query = '''\n UPDATE Consumption SET ",
" EnergyUsed = EnergyUsed + %s,\n PowerUsed = PowerUsed + %s\n WHERE TimeStamp = %s;\n ''' % (energy_used, power_used, ts)",
"",
" self.c.execute(query)",
"\n self.db.commit()"
] | [
1,
1,
1,
0,
1,
0,
1,
0,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 347,
"char_start": 346,
"chars": "?"
},
{
"char_end": 370,
"char_start": 369,
"chars": "?"
},
{
"char_end": 393,
"char_start": 392,
"chars": "?"
},
{
"char_end": 473,
"char_start": 461,
"chars": ", (ts, 0, 0)"
},
{
"char_end": 583,
"char_start": 582,
"chars": "?"
},
{
"char_end": 626,
"char_start": 625,
"chars": "?"
},
{
"char_end": 660,
"char_start": 659,
"chars": "?"
},
{
"char_end": 742,
"char_start": 711,
"chars": ", (energy_used, power_used, ts)"
}
],
"deleted": [
{
"char_end": 348,
"char_start": 346,
"chars": "%s"
},
{
"char_end": 372,
"char_start": 370,
"chars": "%s"
},
{
"char_end": 396,
"char_start": 394,
"chars": "%s"
},
{
"char_end": 444,
"char_start": 431,
"chars": " % (ts, 0, 0)"
},
{
"char_end": 588,
"char_start": 586,
"chars": "%s"
},
{
"char_end": 632,
"char_start": 630,
"chars": "%s"
},
{
"char_end": 665,
"char_start": 664,
"chars": " "
},
{
"char_end": 669,
"char_start": 666,
"chars": " %s"
},
{
"char_end": 718,
"char_start": 686,
"chars": " % (energy_used, power_used, ts)"
}
]
},
"commit_link": "github.com/philipptrenz/s0-bridge/commit/269b48caa05377b7c58c3e6d1622a4429cb5ba65",
"file_name": "util/database.py",
"func_name": "add_consumption_data_row",
"line_changes": {
"added": [
{
"char_end": 349,
"char_start": 326,
"line": " ?,\n",
"line_no": 11
},
{
"char_end": 372,
"char_start": 349,
"line": " ?,\n",
"line_no": 12
},
{
"char_end": 394,
"char_start": 372,
"line": " ?\n",
"line_no": 13
},
{
"char_end": 429,
"char_start": 413,
"line": " '''\n",
"line_no": 15
},
{
"char_end": 475,
"char_start": 429,
"line": " self.c.execute(query, (ts, 0, 0))\n",
"line_no": 16
},
{
"char_end": 585,
"char_start": 540,
"line": " EnergyUsed = EnergyUsed + ?,\n",
"line_no": 20
},
{
"char_end": 627,
"char_start": 585,
"line": " PowerUsed = PowerUsed + ?\n",
"line_no": 21
},
{
"char_end": 662,
"char_start": 627,
"line": " WHERE TimeStamp=?;\n",
"line_no": 22
},
{
"char_end": 678,
"char_start": 662,
"line": " '''\n",
"line_no": 23
},
{
"char_end": 744,
"char_start": 679,
"line": " self.c.execute(query, (energy_used, power_used, ts))\n",
"line_no": 25
}
],
"deleted": [
{
"char_end": 350,
"char_start": 326,
"line": " %s,\n",
"line_no": 11
},
{
"char_end": 374,
"char_start": 350,
"line": " %s,\n",
"line_no": 12
},
{
"char_end": 397,
"char_start": 374,
"line": " %s\n",
"line_no": 13
},
{
"char_end": 445,
"char_start": 416,
"line": " ''' % (ts, 0, 0)\n",
"line_no": 15
},
{
"char_end": 479,
"char_start": 445,
"line": " self.c.execute(query)\n",
"line_no": 16
},
{
"char_end": 590,
"char_start": 544,
"line": " EnergyUsed = EnergyUsed + %s,\n",
"line_no": 20
},
{
"char_end": 633,
"char_start": 590,
"line": " PowerUsed = PowerUsed + %s\n",
"line_no": 21
},
{
"char_end": 671,
"char_start": 633,
"line": " WHERE TimeStamp = %s;\n",
"line_no": 22
},
{
"char_end": 719,
"char_start": 671,
"line": " ''' % (energy_used, power_used, ts)\n",
"line_no": 23
},
{
"char_end": 754,
"char_start": 720,
"line": " self.c.execute(query)\n",
"line_no": 25
}
]
},
"vul_type": "cwe-089"
} | 258 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def add_consumption_data_row(self, ts, energy_used, power_used):",
" if power_used > 0:",
" query = '''\n INSERT OR IGNORE INTO Consumption (\n TimeStamp,\n EnergyUsed,\n PowerUsed \n ) VALUES (",
" ?,\n ?,\n ?",
" );",
" '''\n self.c.execute(query, (ts, 0, 0))",
"\n query = '''\n UPDATE Consumption SET ",
" EnergyUsed = EnergyUsed + ?,\n PowerUsed = PowerUsed + ?\n WHERE TimeStamp=?;\n '''",
"",
" self.c.execute(query, (energy_used, power_used, ts))",
"\n self.db.commit()"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 347,
"char_start": 346,
"chars": "?"
},
{
"char_end": 370,
"char_start": 369,
"chars": "?"
},
{
"char_end": 393,
"char_start": 392,
"chars": "?"
},
{
"char_end": 473,
"char_start": 461,
"chars": ", (ts, 0, 0)"
},
{
"char_end": 583,
"char_start": 582,
"chars": "?"
},
{
"char_end": 626,
"char_start": 625,
"chars": "?"
},
{
"char_end": 660,
"char_start": 659,
"chars": "?"
},
{
"char_end": 742,
"char_start": 711,
"chars": ", (energy_used, power_used, ts)"
}
],
"deleted": [
{
"char_end": 348,
"char_start": 346,
"chars": "%s"
},
{
"char_end": 372,
"char_start": 370,
"chars": "%s"
},
{
"char_end": 396,
"char_start": 394,
"chars": "%s"
},
{
"char_end": 444,
"char_start": 431,
"chars": " % (ts, 0, 0)"
},
{
"char_end": 588,
"char_start": 586,
"chars": "%s"
},
{
"char_end": 632,
"char_start": 630,
"chars": "%s"
},
{
"char_end": 665,
"char_start": 664,
"chars": " "
},
{
"char_end": 669,
"char_start": 666,
"chars": " %s"
},
{
"char_end": 718,
"char_start": 686,
"chars": " % (energy_used, power_used, ts)"
}
]
},
"commit_link": "github.com/philipptrenz/s0-bridge/commit/269b48caa05377b7c58c3e6d1622a4429cb5ba65",
"file_name": "util/database.py",
"func_name": "add_consumption_data_row",
"line_changes": {
"added": [
{
"char_end": 349,
"char_start": 326,
"line": " ?,\n",
"line_no": 11
},
{
"char_end": 372,
"char_start": 349,
"line": " ?,\n",
"line_no": 12
},
{
"char_end": 394,
"char_start": 372,
"line": " ?\n",
"line_no": 13
},
{
"char_end": 429,
"char_start": 413,
"line": " '''\n",
"line_no": 15
},
{
"char_end": 475,
"char_start": 429,
"line": " self.c.execute(query, (ts, 0, 0))\n",
"line_no": 16
},
{
"char_end": 585,
"char_start": 540,
"line": " EnergyUsed = EnergyUsed + ?,\n",
"line_no": 20
},
{
"char_end": 627,
"char_start": 585,
"line": " PowerUsed = PowerUsed + ?\n",
"line_no": 21
},
{
"char_end": 662,
"char_start": 627,
"line": " WHERE TimeStamp=?;\n",
"line_no": 22
},
{
"char_end": 678,
"char_start": 662,
"line": " '''\n",
"line_no": 23
},
{
"char_end": 744,
"char_start": 679,
"line": " self.c.execute(query, (energy_used, power_used, ts))\n",
"line_no": 25
}
],
"deleted": [
{
"char_end": 350,
"char_start": 326,
"line": " %s,\n",
"line_no": 11
},
{
"char_end": 374,
"char_start": 350,
"line": " %s,\n",
"line_no": 12
},
{
"char_end": 397,
"char_start": 374,
"line": " %s\n",
"line_no": 13
},
{
"char_end": 445,
"char_start": 416,
"line": " ''' % (ts, 0, 0)\n",
"line_no": 15
},
{
"char_end": 479,
"char_start": 445,
"line": " self.c.execute(query)\n",
"line_no": 16
},
{
"char_end": 590,
"char_start": 544,
"line": " EnergyUsed = EnergyUsed + %s,\n",
"line_no": 20
},
{
"char_end": 633,
"char_start": 590,
"line": " PowerUsed = PowerUsed + %s\n",
"line_no": 21
},
{
"char_end": 671,
"char_start": 633,
"line": " WHERE TimeStamp = %s;\n",
"line_no": 22
},
{
"char_end": 719,
"char_start": 671,
"line": " ''' % (energy_used, power_used, ts)\n",
"line_no": 23
},
{
"char_end": 754,
"char_start": 720,
"line": " self.c.execute(query)\n",
"line_no": 25
}
]
},
"vul_type": "cwe-089"
} | 258 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route('/lookup_assets')\ndef lookup_assets():\n start = request.args.get('start')",
" con = psycopg2.connect(**config.POSTGRES)\n cur = con.cursor()\n",
" query = \"SELECT aname FROM assets WHERE aname LIKE '\"+start+\"%'\"\n cur.execute(query)",
" results = cur.fetchall()\n con.close()\n return jsonify(results)"
] | [
1,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 215,
"char_start": 214,
"chars": "%"
},
{
"char_end": 253,
"char_start": 239,
"chars": ", (start+'%',)"
}
],
"deleted": [
{
"char_end": 224,
"char_start": 214,
"chars": "'\"+start+\""
},
{
"char_end": 226,
"char_start": 225,
"chars": "'"
}
]
},
"commit_link": "github.com/VinChain/vinchain-python-api-backend/commit/b78088a551fbb712121269c6eb7f43ede120ff60",
"file_name": "api.py",
"func_name": "lookup_assets",
"line_changes": {
"added": [
{
"char_end": 218,
"char_start": 159,
"line": " query = \"SELECT aname FROM assets WHERE aname LIKE %s\"\n",
"line_no": 8
},
{
"char_end": 255,
"char_start": 218,
"line": " cur.execute(query, (start+'%',))\n",
"line_no": 9
}
],
"deleted": [
{
"char_end": 228,
"char_start": 159,
"line": " query = \"SELECT aname FROM assets WHERE aname LIKE '\"+start+\"%'\"\n",
"line_no": 8
},
{
"char_end": 251,
"char_start": 228,
"line": " cur.execute(query)\n",
"line_no": 9
}
]
},
"vul_type": "cwe-089"
} | 259 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route('/lookup_assets')\ndef lookup_assets():\n start = request.args.get('start')",
" con = psycopg2.connect(**config.POSTGRES)\n cur = con.cursor()\n",
" query = \"SELECT aname FROM assets WHERE aname LIKE %s\"\n cur.execute(query, (start+'%',))",
" results = cur.fetchall()\n con.close()\n return jsonify(results)"
] | [
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 215,
"char_start": 214,
"chars": "%"
},
{
"char_end": 253,
"char_start": 239,
"chars": ", (start+'%',)"
}
],
"deleted": [
{
"char_end": 224,
"char_start": 214,
"chars": "'\"+start+\""
},
{
"char_end": 226,
"char_start": 225,
"chars": "'"
}
]
},
"commit_link": "github.com/VinChain/vinchain-python-api-backend/commit/b78088a551fbb712121269c6eb7f43ede120ff60",
"file_name": "api.py",
"func_name": "lookup_assets",
"line_changes": {
"added": [
{
"char_end": 218,
"char_start": 159,
"line": " query = \"SELECT aname FROM assets WHERE aname LIKE %s\"\n",
"line_no": 8
},
{
"char_end": 255,
"char_start": 218,
"line": " cur.execute(query, (start+'%',))\n",
"line_no": 9
}
],
"deleted": [
{
"char_end": 228,
"char_start": 159,
"line": " query = \"SELECT aname FROM assets WHERE aname LIKE '\"+start+\"%'\"\n",
"line_no": 8
},
{
"char_end": 251,
"char_start": 228,
"line": " cur.execute(query)\n",
"line_no": 9
}
]
},
"vul_type": "cwe-089"
} | 259 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def set_state(chat_id, value):\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\bases\\\\settings.db\")\n conn = settings.cursor()",
" conn.execute(\"update users set state ='\" + str(value) + \"' where chat_id = '\" + str(chat_id) + \"'\")",
" settings.commit()\n settings.close()"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 204,
"char_start": 203,
"chars": "?"
},
{
"char_end": 222,
"char_start": 221,
"chars": "?"
},
{
"char_end": 224,
"char_start": 223,
"chars": ","
},
{
"char_end": 237,
"char_start": 225,
"chars": "(str(value),"
},
{
"char_end": 251,
"char_start": 250,
"chars": ")"
}
],
"deleted": [
{
"char_end": 204,
"char_start": 202,
"chars": "'\""
},
{
"char_end": 222,
"char_start": 205,
"chars": "+ str(value) + \"'"
},
{
"char_end": 240,
"char_start": 239,
"chars": "'"
},
{
"char_end": 243,
"char_start": 242,
"chars": "+"
},
{
"char_end": 262,
"char_start": 256,
"chars": " + \"'\""
}
]
},
"commit_link": "github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90",
"file_name": "bot.py",
"func_name": "set_state",
"line_changes": {
"added": [
{
"char_end": 253,
"char_start": 160,
"line": " conn.execute(\"update users set state = ? where chat_id = ?\", (str(value), str(chat_id)))\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 264,
"char_start": 160,
"line": " conn.execute(\"update users set state ='\" + str(value) + \"' where chat_id = '\" + str(chat_id) + \"'\")\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 260 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def set_state(chat_id, value):\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\bases\\\\settings.db\")\n conn = settings.cursor()",
" conn.execute(\"update users set state = ? where chat_id = ?\", (str(value), str(chat_id)))",
" settings.commit()\n settings.close()"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 204,
"char_start": 203,
"chars": "?"
},
{
"char_end": 222,
"char_start": 221,
"chars": "?"
},
{
"char_end": 224,
"char_start": 223,
"chars": ","
},
{
"char_end": 237,
"char_start": 225,
"chars": "(str(value),"
},
{
"char_end": 251,
"char_start": 250,
"chars": ")"
}
],
"deleted": [
{
"char_end": 204,
"char_start": 202,
"chars": "'\""
},
{
"char_end": 222,
"char_start": 205,
"chars": "+ str(value) + \"'"
},
{
"char_end": 240,
"char_start": 239,
"chars": "'"
},
{
"char_end": 243,
"char_start": 242,
"chars": "+"
},
{
"char_end": 262,
"char_start": 256,
"chars": " + \"'\""
}
]
},
"commit_link": "github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90",
"file_name": "bot.py",
"func_name": "set_state",
"line_changes": {
"added": [
{
"char_end": 253,
"char_start": 160,
"line": " conn.execute(\"update users set state = ? where chat_id = ?\", (str(value), str(chat_id)))\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 264,
"char_start": 160,
"line": " conn.execute(\"update users set state ='\" + str(value) + \"' where chat_id = '\" + str(chat_id) + \"'\")\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 260 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def _get_degree_2(user_id, cnx):\n \"\"\"Get all users of degree 2 follow that are not currently followed.\n Example:\n this user (follows) user B (follows) user B\n AND user (does NOT follow) user B\n means that user B will be in the list\n Args:\n user_id (int): id of user\n cnx: DB connection\n Returns:\n list: list of user_ids\n \"\"\"\n sql = 'WITH tmp_suggest (followed_id) AS ' \\\n '(' \\\n 'SELECT b.followed_id AS followed_id ' \\\n 'FROM ' \\\n 'tbl_follow a INNER JOIN tbl_follow b ' \\\n 'ON a.followed_id = b.follower_id ' \\\n 'WHERE a.follower_id = %s ' \\\n 'AND b.followed_id NOT IN ' \\\n '(SELECT followed_id FROM tbl_follow WHERE follower_id = %s) ' \\\n 'AND b.followed_id != %s ' \\\n ') ' \\\n 'SELECT followed_id, COUNT(*) AS num_mutual FROM tmp_suggest ' \\\n 'GROUP BY followed_id ' \\",
" 'ORDER BY num_mutual DESC' % (user_id, user_id, user_id)",
" with cnx.cursor() as cursor:",
" cursor.execute(sql)",
" res = cursor.fetchall()\n return list(map(lambda x: x[0], res))"
] | [
1,
0,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1031,
"char_start": 1002,
"chars": ", (user_id, user_id, user_id)"
}
],
"deleted": [
{
"char_end": 972,
"char_start": 942,
"chars": " % (user_id, user_id, user_id)"
}
]
},
"commit_link": "github.com/young-goons/rifflo-server/commit/fb311df76713b638c9486250f9badb288ffb2189",
"file_name": "server/ygoons/modules/user/follow_suggest.py",
"func_name": "_get_degree_2",
"line_changes": {
"added": [
{
"char_end": 943,
"char_start": 912,
"line": " 'ORDER BY num_mutual DESC'\n",
"line_no": 26
},
{
"char_end": 1033,
"char_start": 976,
"line": " cursor.execute(sql, (user_id, user_id, user_id))\n",
"line_no": 28
}
],
"deleted": [
{
"char_end": 973,
"char_start": 912,
"line": " 'ORDER BY num_mutual DESC' % (user_id, user_id, user_id)\n",
"line_no": 26
},
{
"char_end": 1034,
"char_start": 1006,
"line": " cursor.execute(sql)\n",
"line_no": 28
}
]
},
"vul_type": "cwe-089"
} | 261 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def _get_degree_2(user_id, cnx):\n \"\"\"Get all users of degree 2 follow that are not currently followed.\n Example:\n this user (follows) user B (follows) user B\n AND user (does NOT follow) user B\n means that user B will be in the list\n Args:\n user_id (int): id of user\n cnx: DB connection\n Returns:\n list: list of user_ids\n \"\"\"\n sql = 'WITH tmp_suggest (followed_id) AS ' \\\n '(' \\\n 'SELECT b.followed_id AS followed_id ' \\\n 'FROM ' \\\n 'tbl_follow a INNER JOIN tbl_follow b ' \\\n 'ON a.followed_id = b.follower_id ' \\\n 'WHERE a.follower_id = %s ' \\\n 'AND b.followed_id NOT IN ' \\\n '(SELECT followed_id FROM tbl_follow WHERE follower_id = %s) ' \\\n 'AND b.followed_id != %s ' \\\n ') ' \\\n 'SELECT followed_id, COUNT(*) AS num_mutual FROM tmp_suggest ' \\\n 'GROUP BY followed_id ' \\",
" 'ORDER BY num_mutual DESC'",
" with cnx.cursor() as cursor:",
" cursor.execute(sql, (user_id, user_id, user_id))",
" res = cursor.fetchall()\n return list(map(lambda x: x[0], res))"
] | [
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1031,
"char_start": 1002,
"chars": ", (user_id, user_id, user_id)"
}
],
"deleted": [
{
"char_end": 972,
"char_start": 942,
"chars": " % (user_id, user_id, user_id)"
}
]
},
"commit_link": "github.com/young-goons/rifflo-server/commit/fb311df76713b638c9486250f9badb288ffb2189",
"file_name": "server/ygoons/modules/user/follow_suggest.py",
"func_name": "_get_degree_2",
"line_changes": {
"added": [
{
"char_end": 943,
"char_start": 912,
"line": " 'ORDER BY num_mutual DESC'\n",
"line_no": 26
},
{
"char_end": 1033,
"char_start": 976,
"line": " cursor.execute(sql, (user_id, user_id, user_id))\n",
"line_no": 28
}
],
"deleted": [
{
"char_end": 973,
"char_start": 912,
"line": " 'ORDER BY num_mutual DESC' % (user_id, user_id, user_id)\n",
"line_no": 26
},
{
"char_end": 1034,
"char_start": 1006,
"line": " cursor.execute(sql)\n",
"line_no": 28
}
]
},
"vul_type": "cwe-089"
} | 261 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_tournaments_during_month(db, scene, date):\n y, m, d = date.split('-')\n ym_date = '{}-{}'.format(y, m)",
" sql = \"select url, date from matches where scene='{}' and date like '%{}%' group by url, date order by date\".format(scene, ym_date)\n res = db.exec(sql)",
" urls = [r[0] for r in res]\n return urls"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 176,
"char_start": 171,
"chars": "scene"
},
{
"char_end": 200,
"char_start": 196,
"chars": "date"
},
{
"char_end": 242,
"char_start": 237,
"chars": "\n "
},
{
"char_end": 259,
"char_start": 243,
"chars": "rgs = {'scene': "
},
{
"char_end": 274,
"char_start": 266,
"chars": "'date': "
},
{
"char_end": 282,
"char_start": 281,
"chars": "}"
},
{
"char_end": 310,
"char_start": 304,
"chars": ", args"
}
],
"deleted": [
{
"char_end": 231,
"char_start": 228,
"chars": ".fo"
},
{
"char_end": 236,
"char_start": 232,
"chars": "mat("
},
{
"char_end": 251,
"char_start": 250,
"chars": ")"
}
]
},
"commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63",
"file_name": "bracket_utils.py",
"func_name": "get_tournaments_during_month",
"line_changes": {
"added": [
{
"char_end": 238,
"char_start": 116,
"line": " sql = \"select url, date from matches where scene='{scene}' and date like '%{date}%' group by url, date order by date\"\n",
"line_no": 4
},
{
"char_end": 283,
"char_start": 238,
"line": " args = {'scene': scene, 'date': ym_date}\n",
"line_no": 5
},
{
"char_end": 312,
"char_start": 283,
"line": " res = db.exec(sql, args)\n",
"line_no": 6
}
],
"deleted": [
{
"char_end": 252,
"char_start": 116,
"line": " sql = \"select url, date from matches where scene='{}' and date like '%{}%' group by url, date order by date\".format(scene, ym_date)\n",
"line_no": 4
},
{
"char_end": 275,
"char_start": 252,
"line": " res = db.exec(sql)\n",
"line_no": 5
}
]
},
"vul_type": "cwe-089"
} | 262 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_tournaments_during_month(db, scene, date):\n y, m, d = date.split('-')\n ym_date = '{}-{}'.format(y, m)",
" sql = \"select url, date from matches where scene='{scene}' and date like '%{date}%' group by url, date order by date\"\n args = {'scene': scene, 'date': ym_date}\n res = db.exec(sql, args)",
" urls = [r[0] for r in res]\n return urls"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 176,
"char_start": 171,
"chars": "scene"
},
{
"char_end": 200,
"char_start": 196,
"chars": "date"
},
{
"char_end": 242,
"char_start": 237,
"chars": "\n "
},
{
"char_end": 259,
"char_start": 243,
"chars": "rgs = {'scene': "
},
{
"char_end": 274,
"char_start": 266,
"chars": "'date': "
},
{
"char_end": 282,
"char_start": 281,
"chars": "}"
},
{
"char_end": 310,
"char_start": 304,
"chars": ", args"
}
],
"deleted": [
{
"char_end": 231,
"char_start": 228,
"chars": ".fo"
},
{
"char_end": 236,
"char_start": 232,
"chars": "mat("
},
{
"char_end": 251,
"char_start": 250,
"chars": ")"
}
]
},
"commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63",
"file_name": "bracket_utils.py",
"func_name": "get_tournaments_during_month",
"line_changes": {
"added": [
{
"char_end": 238,
"char_start": 116,
"line": " sql = \"select url, date from matches where scene='{scene}' and date like '%{date}%' group by url, date order by date\"\n",
"line_no": 4
},
{
"char_end": 283,
"char_start": 238,
"line": " args = {'scene': scene, 'date': ym_date}\n",
"line_no": 5
},
{
"char_end": 312,
"char_start": 283,
"line": " res = db.exec(sql, args)\n",
"line_no": 6
}
],
"deleted": [
{
"char_end": 252,
"char_start": 116,
"line": " sql = \"select url, date from matches where scene='{}' and date like '%{}%' group by url, date order by date\".format(scene, ym_date)\n",
"line_no": 4
},
{
"char_end": 275,
"char_start": 252,
"line": " res = db.exec(sql)\n",
"line_no": 5
}
]
},
"vul_type": "cwe-089"
} | 262 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def add_input(self,data):\n connection = self.connect()\n try:\n # The following is a flaw",
" query = \"INSERT INTO crimes(description) VALUES ('{}');\".format(data)",
" with connection.cursor() as cursor:",
" cursor.execute(query)",
" connection.commit()\n finally:\n connection.close()"
] | [
1,
0,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 180,
"char_start": 178,
"chars": "%s"
},
{
"char_end": 274,
"char_start": 268,
"chars": ", data"
}
],
"deleted": [
{
"char_end": 182,
"char_start": 178,
"chars": "'{}'"
},
{
"char_end": 198,
"char_start": 185,
"chars": ".format(data)"
}
]
},
"commit_link": "github.com/amrishc/crimemap/commit/51b3d51aa031d7c285295de36f5464d43debf6de",
"file_name": "dbhelper.py",
"func_name": "add_input",
"line_changes": {
"added": [
{
"char_end": 184,
"char_start": 117,
"line": " query = \"INSERT INTO crimes(description) VALUES (%s);\"\n",
"line_no": 5
},
{
"char_end": 276,
"char_start": 232,
"line": " cursor.execute(query, data)\n",
"line_no": 7
}
],
"deleted": [
{
"char_end": 199,
"char_start": 117,
"line": " query = \"INSERT INTO crimes(description) VALUES ('{}');\".format(data)\n",
"line_no": 5
},
{
"char_end": 285,
"char_start": 247,
"line": " cursor.execute(query)\n",
"line_no": 7
}
]
},
"vul_type": "cwe-089"
} | 263 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def add_input(self,data):\n connection = self.connect()\n try:\n # The following is a flaw",
" query = \"INSERT INTO crimes(description) VALUES (%s);\"",
" with connection.cursor() as cursor:",
" cursor.execute(query, data)",
" connection.commit()\n finally:\n connection.close()"
] | [
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 180,
"char_start": 178,
"chars": "%s"
},
{
"char_end": 274,
"char_start": 268,
"chars": ", data"
}
],
"deleted": [
{
"char_end": 182,
"char_start": 178,
"chars": "'{}'"
},
{
"char_end": 198,
"char_start": 185,
"chars": ".format(data)"
}
]
},
"commit_link": "github.com/amrishc/crimemap/commit/51b3d51aa031d7c285295de36f5464d43debf6de",
"file_name": "dbhelper.py",
"func_name": "add_input",
"line_changes": {
"added": [
{
"char_end": 184,
"char_start": 117,
"line": " query = \"INSERT INTO crimes(description) VALUES (%s);\"\n",
"line_no": 5
},
{
"char_end": 276,
"char_start": 232,
"line": " cursor.execute(query, data)\n",
"line_no": 7
}
],
"deleted": [
{
"char_end": 199,
"char_start": 117,
"line": " query = \"INSERT INTO crimes(description) VALUES ('{}');\".format(data)\n",
"line_no": 5
},
{
"char_end": 285,
"char_start": 247,
"line": " cursor.execute(query)\n",
"line_no": 7
}
]
},
"vul_type": "cwe-089"
} | 263 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_error_days(cur, error_percent):\n \"\"\"Fetches the days in which requests led to errors.",
" Fetches the days in which the specified percentage\n of requests led to errors.",
" Args:\n cur(obj): The cursor to execute the query.\n error_percent(int): The percentage of requests that led to errors.",
" Return:\n True if success, False otherwise.\n \"\"\"",
"",
" query = '''SELECT to_char(log_errors.date, 'Mon DD YYYY'),\n round((log_errors.errors * 100\n / log_requests.total::numeric), 2) as percent\n FROM log_errors, log_requests\n WHERE log_errors.date = log_requests.date AND\n log_errors.errors * 100",
" / log_requests.total::numeric > {}\n ORDER BY log_errors.date'''.format(error_percent)\n rows = get_data(cur, query)",
"\n # Write data to txt file.\n if rows is not None:\n file = open(\"error_report.txt\", \"w\")\n for row in rows:\n file.write(\"{} - {}% errors \\n\".format(row[0], row[1]))\n file.close()",
" return True\n else:\n return False"
] | [
1,
1,
1,
1,
0,
1,
0,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 417,
"char_start": 388,
"chars": "data = (error_percent, )\n "
},
{
"char_end": 759,
"char_start": 757,
"chars": "%s"
},
{
"char_end": 836,
"char_start": 830,
"chars": ", data"
}
],
"deleted": [
{
"char_end": 730,
"char_start": 728,
"chars": "{}"
},
{
"char_end": 792,
"char_start": 770,
"chars": ".format(error_percent)"
}
]
},
"commit_link": "github.com/rrbiz662/log-analysis/commit/20fefbde3738088586a3c5679f743493d0a504f6",
"file_name": "news_data_analysis.py",
"func_name": "get_error_days",
"line_changes": {
"added": [
{
"char_end": 413,
"char_start": 384,
"line": " data = (error_percent, )\n",
"line_no": 14
},
{
"char_end": 760,
"char_start": 713,
"line": " / log_requests.total::numeric > %s\n",
"line_no": 21
},
{
"char_end": 800,
"char_start": 760,
"line": " ORDER BY log_errors.date'''\n",
"line_no": 22
},
{
"char_end": 838,
"char_start": 800,
"line": " rows = get_data(cur, query, data)\n",
"line_no": 23
}
],
"deleted": [
{
"char_end": 731,
"char_start": 684,
"line": " / log_requests.total::numeric > {}\n",
"line_no": 20
},
{
"char_end": 793,
"char_start": 731,
"line": " ORDER BY log_errors.date'''.format(error_percent)\n",
"line_no": 21
},
{
"char_end": 825,
"char_start": 793,
"line": " rows = get_data(cur, query)\n",
"line_no": 22
}
]
},
"vul_type": "cwe-089"
} | 264 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_error_days(cur, error_percent):\n \"\"\"Fetches the days in which requests led to errors.",
" Fetches the days in which the specified percentage\n of requests led to errors.",
" Args:\n cur(obj): The cursor to execute the query.\n error_percent(int): The percentage of requests that led to errors.",
" Return:\n True if success, False otherwise.\n \"\"\"",
" data = (error_percent, )",
" query = '''SELECT to_char(log_errors.date, 'Mon DD YYYY'),\n round((log_errors.errors * 100\n / log_requests.total::numeric), 2) as percent\n FROM log_errors, log_requests\n WHERE log_errors.date = log_requests.date AND\n log_errors.errors * 100",
" / log_requests.total::numeric > %s\n ORDER BY log_errors.date'''\n rows = get_data(cur, query, data)",
"\n # Write data to txt file.\n if rows is not None:\n file = open(\"error_report.txt\", \"w\")\n for row in rows:\n file.write(\"{} - {}% errors \\n\".format(row[0], row[1]))\n file.close()",
" return True\n else:\n return False"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 417,
"char_start": 388,
"chars": "data = (error_percent, )\n "
},
{
"char_end": 759,
"char_start": 757,
"chars": "%s"
},
{
"char_end": 836,
"char_start": 830,
"chars": ", data"
}
],
"deleted": [
{
"char_end": 730,
"char_start": 728,
"chars": "{}"
},
{
"char_end": 792,
"char_start": 770,
"chars": ".format(error_percent)"
}
]
},
"commit_link": "github.com/rrbiz662/log-analysis/commit/20fefbde3738088586a3c5679f743493d0a504f6",
"file_name": "news_data_analysis.py",
"func_name": "get_error_days",
"line_changes": {
"added": [
{
"char_end": 413,
"char_start": 384,
"line": " data = (error_percent, )\n",
"line_no": 14
},
{
"char_end": 760,
"char_start": 713,
"line": " / log_requests.total::numeric > %s\n",
"line_no": 21
},
{
"char_end": 800,
"char_start": 760,
"line": " ORDER BY log_errors.date'''\n",
"line_no": 22
},
{
"char_end": 838,
"char_start": 800,
"line": " rows = get_data(cur, query, data)\n",
"line_no": 23
}
],
"deleted": [
{
"char_end": 731,
"char_start": 684,
"line": " / log_requests.total::numeric > {}\n",
"line_no": 20
},
{
"char_end": 793,
"char_start": 731,
"line": " ORDER BY log_errors.date'''.format(error_percent)\n",
"line_no": 21
},
{
"char_end": 825,
"char_start": 793,
"line": " rows = get_data(cur, query)\n",
"line_no": 22
}
]
},
"vul_type": "cwe-089"
} | 264 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def all_deposits(self,coin):",
" sql = \"SELECT * FROM deposits WHERE coin='%s'\" % coin\n self.cursor.execute(sql)",
" return self.cursor.fetchall()"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 128,
"char_start": 119,
"chars": ", (coin,)"
}
],
"deleted": [
{
"char_end": 94,
"char_start": 87,
"chars": " % coin"
}
]
},
"commit_link": "github.com/ktechmidas/garlictipsbot/commit/7c262255f933cb721109ac4be752b5b7599275aa",
"file_name": "deposit.py",
"func_name": "all_deposits",
"line_changes": {
"added": [
{
"char_end": 88,
"char_start": 33,
"line": " sql = \"SELECT * FROM deposits WHERE coin='%s'\"\n",
"line_no": 2
},
{
"char_end": 130,
"char_start": 88,
"line": " self.cursor.execute(sql, (coin,))\n",
"line_no": 3
}
],
"deleted": [
{
"char_end": 95,
"char_start": 33,
"line": " sql = \"SELECT * FROM deposits WHERE coin='%s'\" % coin\n",
"line_no": 2
},
{
"char_end": 128,
"char_start": 95,
"line": " self.cursor.execute(sql)\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 265 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def all_deposits(self,coin):",
" sql = \"SELECT * FROM deposits WHERE coin='%s'\"\n self.cursor.execute(sql, (coin,))",
" return self.cursor.fetchall()"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 128,
"char_start": 119,
"chars": ", (coin,)"
}
],
"deleted": [
{
"char_end": 94,
"char_start": 87,
"chars": " % coin"
}
]
},
"commit_link": "github.com/ktechmidas/garlictipsbot/commit/7c262255f933cb721109ac4be752b5b7599275aa",
"file_name": "deposit.py",
"func_name": "all_deposits",
"line_changes": {
"added": [
{
"char_end": 88,
"char_start": 33,
"line": " sql = \"SELECT * FROM deposits WHERE coin='%s'\"\n",
"line_no": 2
},
{
"char_end": 130,
"char_start": 88,
"line": " self.cursor.execute(sql, (coin,))\n",
"line_no": 3
}
],
"deleted": [
{
"char_end": 95,
"char_start": 33,
"line": " sql = \"SELECT * FROM deposits WHERE coin='%s'\" % coin\n",
"line_no": 2
},
{
"char_end": 128,
"char_start": 95,
"line": " self.cursor.execute(sql)\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 265 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_user(self):\n if not hasattr(self, '_user'):",
" qs = \"select * from account_access where access_token = '%s'\" % self.access_token\n result = self.db.get(qs)",
" if result:\n self._user = result\n else:\n self._user = None\n \n return self._user"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 189,
"char_start": 170,
"chars": ", self.access_token"
}
],
"deleted": [
{
"char_end": 132,
"char_start": 131,
"chars": "'"
},
{
"char_end": 135,
"char_start": 134,
"chars": "'"
},
{
"char_end": 156,
"char_start": 136,
"chars": " % self.access_token"
}
]
},
"commit_link": "github.com/bonbondirac/tsunami/commit/396cc394bd6daaf0ee9c16b1b55a4082eeaac208",
"file_name": "src/auth.py",
"func_name": "get_user",
"line_changes": {
"added": [
{
"char_end": 135,
"char_start": 63,
"line": " qs = \"select * from account_access where access_token = %s\"\n",
"line_no": 3
},
{
"char_end": 191,
"char_start": 135,
"line": " result = self.db.get(qs, self.access_token)\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 157,
"char_start": 63,
"line": " qs = \"select * from account_access where access_token = '%s'\" % self.access_token\n",
"line_no": 3
},
{
"char_end": 194,
"char_start": 157,
"line": " result = self.db.get(qs)\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 266 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_user(self):\n if not hasattr(self, '_user'):",
" qs = \"select * from account_access where access_token = %s\"\n result = self.db.get(qs, self.access_token)",
" if result:\n self._user = result\n else:\n self._user = None\n \n return self._user"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 189,
"char_start": 170,
"chars": ", self.access_token"
}
],
"deleted": [
{
"char_end": 132,
"char_start": 131,
"chars": "'"
},
{
"char_end": 135,
"char_start": 134,
"chars": "'"
},
{
"char_end": 156,
"char_start": 136,
"chars": " % self.access_token"
}
]
},
"commit_link": "github.com/bonbondirac/tsunami/commit/396cc394bd6daaf0ee9c16b1b55a4082eeaac208",
"file_name": "src/auth.py",
"func_name": "get_user",
"line_changes": {
"added": [
{
"char_end": 135,
"char_start": 63,
"line": " qs = \"select * from account_access where access_token = %s\"\n",
"line_no": 3
},
{
"char_end": 191,
"char_start": 135,
"line": " result = self.db.get(qs, self.access_token)\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 157,
"char_start": 63,
"line": " qs = \"select * from account_access where access_token = '%s'\" % self.access_token\n",
"line_no": 3
},
{
"char_end": 194,
"char_start": 157,
"line": " result = self.db.get(qs)\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 266 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@staticmethod\n def compare_and_update(user, message):\n \"\"\"\n This method compare a user object from the bot and his info from\n the Telegram message to check whether a user has changed his bio\n or not. If yes, the user object that represents him in the bot will\n be updated accordingly. Now this function is called only when a user\n asks the bot for showing the most popular cams",
" :param user: user object that represents a Telegram user in this bot\n :param message: object from Telegram that contains info about user's\n message and about himself\n :return: None\n \"\"\"",
" log.info('Checking whether user have changed his info or not...')\n msg = message.from_user\n usr_from_message = User(message.chat.id, msg.first_name, msg.username,\n msg.last_name)",
" if user.chat_id != usr_from_message.chat_id:\n log.error(\"Wrong user to compare!\")\n return",
" if user.first_name != usr_from_message.first_name:\n user.first_name = usr_from_message.first_name",
" elif user.nickname != usr_from_message.nickname:\n user.nickname = usr_from_message.nickname",
" elif user.last_name != usr_from_message.last_name:\n user.last_name = usr_from_message.last_name",
" else:\n log.debug(\"User's info hasn't changed\")\n return",
" log.info(\"User has changed his info\")\n log.debug(\"Updating user's info in the database...\")\n query = (f\"UPDATE users \"",
" f\"SET first_name='{user.first_name}', \"\n f\"nickname='{user.nickname}', \"\n f\"last_name='{user.last_name}' \"\n f\"WHERE chat_id={user.chat_id}\")",
"\n try:",
" db.add(query)",
" except DatabaseError:\n log.error(\"Could not update info about %s in the database\",\n user)\n else:\n log.debug(\"User's info has been updated\")"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1613,
"char_start": 1612,
"chars": "%"
},
{
"char_end": 1647,
"char_start": 1646,
"chars": "%"
},
{
"char_end": 1682,
"char_start": 1681,
"chars": "%"
},
{
"char_end": 1817,
"char_start": 1719,
"chars": "%s\")\n\n parameters = (user.first_name, user.nickname, user.last_name,\n "
},
{
"char_end": 1881,
"char_start": 1869,
"chars": ", parameters"
}
],
"deleted": [
{
"char_end": 1615,
"char_start": 1612,
"chars": "'{u"
},
{
"char_end": 1631,
"char_start": 1616,
"chars": "er.first_name}'"
},
{
"char_end": 1666,
"char_start": 1663,
"chars": "'{u"
},
{
"char_end": 1680,
"char_start": 1667,
"chars": "er.nickname}'"
},
{
"char_end": 1722,
"char_start": 1713,
"chars": "'{user.la"
},
{
"char_end": 1731,
"char_start": 1723,
"chars": "t_name}'"
},
{
"char_end": 1768,
"char_start": 1767,
"chars": "{"
},
{
"char_end": 1782,
"char_start": 1780,
"chars": "}\""
}
]
},
"commit_link": "github.com/RandyRomero/photoGPSbot/commit/0e9f57f13e61863b3672f5730e27f149da00786a",
"file_name": "photogpsbot/users.py",
"func_name": "compare_and_update",
"line_changes": {
"added": [
{
"char_end": 1618,
"char_start": 1578,
"line": " f\"SET first_name=%s, \"\n",
"line_no": 41
},
{
"char_end": 1652,
"char_start": 1618,
"line": " f\"nickname=%s, \"\n",
"line_no": 42
},
{
"char_end": 1686,
"char_start": 1652,
"line": " f\"last_name=%s \"\n",
"line_no": 43
},
{
"char_end": 1724,
"char_start": 1686,
"line": " f\"WHERE chat_id=%s\")\n",
"line_no": 44
},
{
"char_end": 1725,
"char_start": 1724,
"line": "\n",
"line_no": 45
},
{
"char_end": 1795,
"char_start": 1725,
"line": " parameters = (user.first_name, user.nickname, user.last_name,\n",
"line_no": 46
},
{
"char_end": 1831,
"char_start": 1795,
"line": " user.chat_id)\n",
"line_no": 47
},
{
"char_end": 1883,
"char_start": 1845,
"line": " db.add(query, parameters)\n",
"line_no": 50
}
],
"deleted": [
{
"char_end": 1635,
"char_start": 1578,
"line": " f\"SET first_name='{user.first_name}', \"\n",
"line_no": 41
},
{
"char_end": 1684,
"char_start": 1635,
"line": " f\"nickname='{user.nickname}', \"\n",
"line_no": 42
},
{
"char_end": 1734,
"char_start": 1684,
"line": " f\"last_name='{user.last_name}' \"\n",
"line_no": 43
},
{
"char_end": 1784,
"char_start": 1734,
"line": " f\"WHERE chat_id={user.chat_id}\")\n",
"line_no": 44
},
{
"char_end": 1824,
"char_start": 1798,
"line": " db.add(query)\n",
"line_no": 47
}
]
},
"vul_type": "cwe-089"
} | 267 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@staticmethod\n def compare_and_update(user, message):\n \"\"\"\n This method compare a user object from the bot and his info from\n the Telegram message to check whether a user has changed his bio\n or not. If yes, the user object that represents him in the bot will\n be updated accordingly. Now this function is called only when a user\n asks the bot for showing the most popular cams",
" :param user: user object that represents a Telegram user in this bot\n :param message: object from Telegram that contains info about user's\n message and about himself\n :return: None\n \"\"\"",
" log.info('Checking whether user have changed his info or not...')\n msg = message.from_user\n usr_from_message = User(message.chat.id, msg.first_name, msg.username,\n msg.last_name)",
" if user.chat_id != usr_from_message.chat_id:\n log.error(\"Wrong user to compare!\")\n return",
" if user.first_name != usr_from_message.first_name:\n user.first_name = usr_from_message.first_name",
" elif user.nickname != usr_from_message.nickname:\n user.nickname = usr_from_message.nickname",
" elif user.last_name != usr_from_message.last_name:\n user.last_name = usr_from_message.last_name",
" else:\n log.debug(\"User's info hasn't changed\")\n return",
" log.info(\"User has changed his info\")\n log.debug(\"Updating user's info in the database...\")\n query = (f\"UPDATE users \"",
" f\"SET first_name=%s, \"\n f\"nickname=%s, \"\n f\"last_name=%s \"\n f\"WHERE chat_id=%s\")",
" parameters = (user.first_name, user.nickname, user.last_name,\n user.chat_id)",
"\n try:",
" db.add(query, parameters)",
" except DatabaseError:\n log.error(\"Could not update info about %s in the database\",\n user)\n else:\n log.debug(\"User's info has been updated\")"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1613,
"char_start": 1612,
"chars": "%"
},
{
"char_end": 1647,
"char_start": 1646,
"chars": "%"
},
{
"char_end": 1682,
"char_start": 1681,
"chars": "%"
},
{
"char_end": 1817,
"char_start": 1719,
"chars": "%s\")\n\n parameters = (user.first_name, user.nickname, user.last_name,\n "
},
{
"char_end": 1881,
"char_start": 1869,
"chars": ", parameters"
}
],
"deleted": [
{
"char_end": 1615,
"char_start": 1612,
"chars": "'{u"
},
{
"char_end": 1631,
"char_start": 1616,
"chars": "er.first_name}'"
},
{
"char_end": 1666,
"char_start": 1663,
"chars": "'{u"
},
{
"char_end": 1680,
"char_start": 1667,
"chars": "er.nickname}'"
},
{
"char_end": 1722,
"char_start": 1713,
"chars": "'{user.la"
},
{
"char_end": 1731,
"char_start": 1723,
"chars": "t_name}'"
},
{
"char_end": 1768,
"char_start": 1767,
"chars": "{"
},
{
"char_end": 1782,
"char_start": 1780,
"chars": "}\""
}
]
},
"commit_link": "github.com/RandyRomero/photoGPSbot/commit/0e9f57f13e61863b3672f5730e27f149da00786a",
"file_name": "photogpsbot/users.py",
"func_name": "compare_and_update",
"line_changes": {
"added": [
{
"char_end": 1618,
"char_start": 1578,
"line": " f\"SET first_name=%s, \"\n",
"line_no": 41
},
{
"char_end": 1652,
"char_start": 1618,
"line": " f\"nickname=%s, \"\n",
"line_no": 42
},
{
"char_end": 1686,
"char_start": 1652,
"line": " f\"last_name=%s \"\n",
"line_no": 43
},
{
"char_end": 1724,
"char_start": 1686,
"line": " f\"WHERE chat_id=%s\")\n",
"line_no": 44
},
{
"char_end": 1725,
"char_start": 1724,
"line": "\n",
"line_no": 45
},
{
"char_end": 1795,
"char_start": 1725,
"line": " parameters = (user.first_name, user.nickname, user.last_name,\n",
"line_no": 46
},
{
"char_end": 1831,
"char_start": 1795,
"line": " user.chat_id)\n",
"line_no": 47
},
{
"char_end": 1883,
"char_start": 1845,
"line": " db.add(query, parameters)\n",
"line_no": 50
}
],
"deleted": [
{
"char_end": 1635,
"char_start": 1578,
"line": " f\"SET first_name='{user.first_name}', \"\n",
"line_no": 41
},
{
"char_end": 1684,
"char_start": 1635,
"line": " f\"nickname='{user.nickname}', \"\n",
"line_no": 42
},
{
"char_end": 1734,
"char_start": 1684,
"line": " f\"last_name='{user.last_name}' \"\n",
"line_no": 43
},
{
"char_end": 1784,
"char_start": 1734,
"line": " f\"WHERE chat_id={user.chat_id}\")\n",
"line_no": 44
},
{
"char_end": 1824,
"char_start": 1798,
"line": " db.add(query)\n",
"line_no": 47
}
]
},
"vul_type": "cwe-089"
} | 267 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def GameNewPlayed(Played, ID):",
"\tdb.execute(\"UPDATE games set GamesPlayed = %i WHERE ID = %i\" % (Played, ID))",
"\tdatabase.commit()"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 76,
"char_start": 75,
"chars": "?"
},
{
"char_end": 89,
"char_start": 88,
"chars": "?"
},
{
"char_end": 91,
"char_start": 90,
"chars": ","
}
],
"deleted": [
{
"char_end": 77,
"char_start": 75,
"chars": "%i"
},
{
"char_end": 91,
"char_start": 89,
"chars": "%i"
},
{
"char_end": 94,
"char_start": 92,
"chars": " %"
},
{
"char_end": 96,
"char_start": 95,
"chars": "("
},
{
"char_end": 107,
"char_start": 106,
"chars": ")"
}
]
},
"commit_link": "github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2",
"file_name": "plugins/database.py",
"func_name": "GameNewPlayed",
"line_changes": {
"added": [
{
"char_end": 104,
"char_start": 31,
"line": "\tdb.execute(\"UPDATE games set GamesPlayed = ? WHERE ID = ?\", Played, ID)\n",
"line_no": 2
}
],
"deleted": [
{
"char_end": 109,
"char_start": 31,
"line": "\tdb.execute(\"UPDATE games set GamesPlayed = %i WHERE ID = %i\" % (Played, ID))\n",
"line_no": 2
}
]
},
"vul_type": "cwe-089"
} | 268 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def GameNewPlayed(Played, ID):",
"\tdb.execute(\"UPDATE games set GamesPlayed = ? WHERE ID = ?\", Played, ID)",
"\tdatabase.commit()"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 76,
"char_start": 75,
"chars": "?"
},
{
"char_end": 89,
"char_start": 88,
"chars": "?"
},
{
"char_end": 91,
"char_start": 90,
"chars": ","
}
],
"deleted": [
{
"char_end": 77,
"char_start": 75,
"chars": "%i"
},
{
"char_end": 91,
"char_start": 89,
"chars": "%i"
},
{
"char_end": 94,
"char_start": 92,
"chars": " %"
},
{
"char_end": 96,
"char_start": 95,
"chars": "("
},
{
"char_end": 107,
"char_start": 106,
"chars": ")"
}
]
},
"commit_link": "github.com/iScrE4m/XLeague/commit/59cab6e5fd8bd5e47f2418a7c71cb1d4e3cad0d2",
"file_name": "plugins/database.py",
"func_name": "GameNewPlayed",
"line_changes": {
"added": [
{
"char_end": 104,
"char_start": 31,
"line": "\tdb.execute(\"UPDATE games set GamesPlayed = ? WHERE ID = ?\", Played, ID)\n",
"line_no": 2
}
],
"deleted": [
{
"char_end": 109,
"char_start": 31,
"line": "\tdb.execute(\"UPDATE games set GamesPlayed = %i WHERE ID = %i\" % (Played, ID))\n",
"line_no": 2
}
]
},
"vul_type": "cwe-089"
} | 268 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def insertNPC(name, race,classe,sex,level,image,legit):\n\tc, conn = getConnection()\n\tdate = now()",
"\tc.execute(\"INSERT INTO npc VALUES ('\"+date+\"','\"+str(name)+\"','\"+race+\"','\"+classe+\"','\"+sex+\"','\"+str(level)+\"','\"+image+\"','\"+str(legit)+\"')\")",
"\tconn.commit()\n\tconn.close()"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 149,
"char_start": 133,
"chars": "?,?,?,?,?,?,?,?)"
},
{
"char_end": 152,
"char_start": 150,
"chars": ",("
}
],
"deleted": [
{
"char_end": 134,
"char_start": 133,
"chars": "'"
},
{
"char_end": 136,
"char_start": 135,
"chars": "+"
},
{
"char_end": 143,
"char_start": 140,
"chars": "+\"'"
},
{
"char_end": 147,
"char_start": 144,
"chars": "'\"+"
},
{
"char_end": 159,
"char_start": 156,
"chars": "+\"'"
},
{
"char_end": 163,
"char_start": 160,
"chars": "'\"+"
},
{
"char_end": 170,
"char_start": 167,
"chars": "+\"'"
},
{
"char_end": 174,
"char_start": 171,
"chars": "'\"+"
},
{
"char_end": 183,
"char_start": 180,
"chars": "+\"'"
},
{
"char_end": 187,
"char_start": 184,
"chars": "'\"+"
},
{
"char_end": 193,
"char_start": 190,
"chars": "+\"'"
},
{
"char_end": 197,
"char_start": 194,
"chars": "'\"+"
},
{
"char_end": 210,
"char_start": 207,
"chars": "+\"'"
},
{
"char_end": 214,
"char_start": 211,
"chars": "'\"+"
},
{
"char_end": 222,
"char_start": 219,
"chars": "+\"'"
},
{
"char_end": 226,
"char_start": 223,
"chars": "'\"+"
},
{
"char_end": 239,
"char_start": 236,
"chars": "+\"'"
},
{
"char_end": 241,
"char_start": 240,
"chars": "\""
}
]
},
"commit_link": "github.com/DangerBlack/DungeonsAndDragonsMasterBot/commit/63f980c6dff746f5fcf3005d0646b6c24f81cdc0",
"file_name": "database.py",
"func_name": "insertNPC",
"line_changes": {
"added": [
{
"char_end": 213,
"char_start": 97,
"line": "\tc.execute(\"INSERT INTO npc VALUES (?,?,?,?,?,?,?,?)\",(date,str(name),race,classe,sex,str(level),image,str(legit)))\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 243,
"char_start": 97,
"line": "\tc.execute(\"INSERT INTO npc VALUES ('\"+date+\"','\"+str(name)+\"','\"+race+\"','\"+classe+\"','\"+sex+\"','\"+str(level)+\"','\"+image+\"','\"+str(legit)+\"')\")\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 269 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def insertNPC(name, race,classe,sex,level,image,legit):\n\tc, conn = getConnection()\n\tdate = now()",
"\tc.execute(\"INSERT INTO npc VALUES (?,?,?,?,?,?,?,?)\",(date,str(name),race,classe,sex,str(level),image,str(legit)))",
"\tconn.commit()\n\tconn.close()"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 149,
"char_start": 133,
"chars": "?,?,?,?,?,?,?,?)"
},
{
"char_end": 152,
"char_start": 150,
"chars": ",("
}
],
"deleted": [
{
"char_end": 134,
"char_start": 133,
"chars": "'"
},
{
"char_end": 136,
"char_start": 135,
"chars": "+"
},
{
"char_end": 143,
"char_start": 140,
"chars": "+\"'"
},
{
"char_end": 147,
"char_start": 144,
"chars": "'\"+"
},
{
"char_end": 159,
"char_start": 156,
"chars": "+\"'"
},
{
"char_end": 163,
"char_start": 160,
"chars": "'\"+"
},
{
"char_end": 170,
"char_start": 167,
"chars": "+\"'"
},
{
"char_end": 174,
"char_start": 171,
"chars": "'\"+"
},
{
"char_end": 183,
"char_start": 180,
"chars": "+\"'"
},
{
"char_end": 187,
"char_start": 184,
"chars": "'\"+"
},
{
"char_end": 193,
"char_start": 190,
"chars": "+\"'"
},
{
"char_end": 197,
"char_start": 194,
"chars": "'\"+"
},
{
"char_end": 210,
"char_start": 207,
"chars": "+\"'"
},
{
"char_end": 214,
"char_start": 211,
"chars": "'\"+"
},
{
"char_end": 222,
"char_start": 219,
"chars": "+\"'"
},
{
"char_end": 226,
"char_start": 223,
"chars": "'\"+"
},
{
"char_end": 239,
"char_start": 236,
"chars": "+\"'"
},
{
"char_end": 241,
"char_start": 240,
"chars": "\""
}
]
},
"commit_link": "github.com/DangerBlack/DungeonsAndDragonsMasterBot/commit/63f980c6dff746f5fcf3005d0646b6c24f81cdc0",
"file_name": "database.py",
"func_name": "insertNPC",
"line_changes": {
"added": [
{
"char_end": 213,
"char_start": 97,
"line": "\tc.execute(\"INSERT INTO npc VALUES (?,?,?,?,?,?,?,?)\",(date,str(name),race,classe,sex,str(level),image,str(legit)))\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 243,
"char_start": 97,
"line": "\tc.execute(\"INSERT INTO npc VALUES ('\"+date+\"','\"+str(name)+\"','\"+race+\"','\"+classe+\"','\"+sex+\"','\"+str(level)+\"','\"+image+\"','\"+str(legit)+\"')\")\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 269 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get(self, user_id):\n \"\"\" Fetch data for user with corresponding user_id \"\"\"",
" return database_utilities.execute_query(f\"\"\"select * from users where user_id = '{user_id}'\"\"\")"
] | [
1,
0
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 187,
"char_start": 179,
"chars": "%s\"\"\", ("
},
{
"char_end": 197,
"char_start": 194,
"chars": ", )"
}
],
"deleted": [
{
"char_end": 181,
"char_start": 179,
"chars": "'{"
},
{
"char_end": 193,
"char_start": 188,
"chars": "}'\"\"\""
}
]
},
"commit_link": "github.com/sgosal2/tiger-boards-backend/commit/4670109dd613df2f2fe7e8403ebd149df2b55485",
"file_name": "apis/users.py",
"func_name": "get",
"line_changes": {
"added": [
{
"char_end": 198,
"char_start": 91,
"line": " return database_utilities.execute_query(f\"\"\"select * from users where user_id = %s\"\"\", (user_id, ))\n",
"line_no": 3
}
],
"deleted": [
{
"char_end": 194,
"char_start": 91,
"line": " return database_utilities.execute_query(f\"\"\"select * from users where user_id = '{user_id}'\"\"\")\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 270 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get(self, user_id):\n \"\"\" Fetch data for user with corresponding user_id \"\"\"",
" return database_utilities.execute_query(f\"\"\"select * from users where user_id = %s\"\"\", (user_id, ))"
] | [
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 187,
"char_start": 179,
"chars": "%s\"\"\", ("
},
{
"char_end": 197,
"char_start": 194,
"chars": ", )"
}
],
"deleted": [
{
"char_end": 181,
"char_start": 179,
"chars": "'{"
},
{
"char_end": 193,
"char_start": 188,
"chars": "}'\"\"\""
}
]
},
"commit_link": "github.com/sgosal2/tiger-boards-backend/commit/4670109dd613df2f2fe7e8403ebd149df2b55485",
"file_name": "apis/users.py",
"func_name": "get",
"line_changes": {
"added": [
{
"char_end": 198,
"char_start": 91,
"line": " return database_utilities.execute_query(f\"\"\"select * from users where user_id = %s\"\"\", (user_id, ))\n",
"line_no": 3
}
],
"deleted": [
{
"char_end": 194,
"char_start": 91,
"line": " return database_utilities.execute_query(f\"\"\"select * from users where user_id = '{user_id}'\"\"\")\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 270 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@endpoints.route(\"/h2h\")\ndef h2h():\n if db == None:\n init()",
" player1 = request.args.get('tag1', default=\"christmasmike\")\n player2 = request.args.get('tag2', default=\"christmasmike\")",
" sql = \"SELECT * FROM matches WHERE (player1 = '\"+str(player1)+\"' OR \"\\\n +\"player2 = '\"+str(player1)+\"') AND (player1 = '\"+str(player2)+\"' OR \"\\\n +\"player2 = '\"+str(player2)+\"') ORDER BY date DESC;\"\n result = db.exec(sql)",
" return json.dumps(result)"
] | [
1,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 251,
"char_start": 250,
"chars": "{"
},
{
"char_end": 259,
"char_start": 258,
"chars": "}"
},
{
"char_end": 293,
"char_start": 292,
"chars": "{"
},
{
"char_end": 301,
"char_start": 300,
"chars": "}"
},
{
"char_end": 321,
"char_start": 320,
"chars": "{"
},
{
"char_end": 329,
"char_start": 328,
"chars": "}"
},
{
"char_end": 363,
"char_start": 362,
"chars": "{"
},
{
"char_end": 371,
"char_start": 370,
"chars": "}"
},
{
"char_end": 451,
"char_start": 399,
"chars": "args = {'player1': player1, 'player2': player2}\n "
},
{
"char_end": 477,
"char_start": 471,
"chars": ", args"
}
],
"deleted": [
{
"char_end": 256,
"char_start": 250,
"chars": "\"+str("
},
{
"char_end": 266,
"char_start": 263,
"chars": ")+\""
},
{
"char_end": 305,
"char_start": 299,
"chars": "\"+str("
},
{
"char_end": 315,
"char_start": 312,
"chars": ")+\""
},
{
"char_end": 340,
"char_start": 334,
"chars": "\"+str("
},
{
"char_end": 350,
"char_start": 347,
"chars": ")+\""
},
{
"char_end": 389,
"char_start": 383,
"chars": "\"+str("
},
{
"char_end": 399,
"char_start": 396,
"chars": ")+\""
}
]
},
"commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63",
"file_name": "endpoints.py",
"func_name": "h2h",
"line_changes": {
"added": [
{
"char_end": 267,
"char_start": 199,
"line": " sql = \"SELECT * FROM matches WHERE (player1 = '{player1}' OR \"\\\n",
"line_no": 8
},
{
"char_end": 337,
"char_start": 267,
"line": " +\"player2 = '{player1}') AND (player1 = '{player2}' OR \"\\\n",
"line_no": 9
},
{
"char_end": 395,
"char_start": 337,
"line": " +\"player2 = '{player2}') ORDER BY date DESC;\"\n",
"line_no": 10
},
{
"char_end": 447,
"char_start": 395,
"line": " args = {'player1': player1, 'player2': player2}\n",
"line_no": 11
},
{
"char_end": 479,
"char_start": 447,
"line": " result = db.exec(sql, args)\n",
"line_no": 12
}
],
"deleted": [
{
"char_end": 274,
"char_start": 199,
"line": " sql = \"SELECT * FROM matches WHERE (player1 = '\"+str(player1)+\"' OR \"\\\n",
"line_no": 8
},
{
"char_end": 358,
"char_start": 274,
"line": " +\"player2 = '\"+str(player1)+\"') AND (player1 = '\"+str(player2)+\"' OR \"\\\n",
"line_no": 9
},
{
"char_end": 423,
"char_start": 358,
"line": " +\"player2 = '\"+str(player2)+\"') ORDER BY date DESC;\"\n",
"line_no": 10
},
{
"char_end": 449,
"char_start": 423,
"line": " result = db.exec(sql)\n",
"line_no": 11
}
]
},
"vul_type": "cwe-089"
} | 271 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@endpoints.route(\"/h2h\")\ndef h2h():\n if db == None:\n init()",
" player1 = request.args.get('tag1', default=\"christmasmike\")\n player2 = request.args.get('tag2', default=\"christmasmike\")",
" sql = \"SELECT * FROM matches WHERE (player1 = '{player1}' OR \"\\\n +\"player2 = '{player1}') AND (player1 = '{player2}' OR \"\\\n +\"player2 = '{player2}') ORDER BY date DESC;\"\n args = {'player1': player1, 'player2': player2}\n result = db.exec(sql, args)",
" return json.dumps(result)"
] | [
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 251,
"char_start": 250,
"chars": "{"
},
{
"char_end": 259,
"char_start": 258,
"chars": "}"
},
{
"char_end": 293,
"char_start": 292,
"chars": "{"
},
{
"char_end": 301,
"char_start": 300,
"chars": "}"
},
{
"char_end": 321,
"char_start": 320,
"chars": "{"
},
{
"char_end": 329,
"char_start": 328,
"chars": "}"
},
{
"char_end": 363,
"char_start": 362,
"chars": "{"
},
{
"char_end": 371,
"char_start": 370,
"chars": "}"
},
{
"char_end": 451,
"char_start": 399,
"chars": "args = {'player1': player1, 'player2': player2}\n "
},
{
"char_end": 477,
"char_start": 471,
"chars": ", args"
}
],
"deleted": [
{
"char_end": 256,
"char_start": 250,
"chars": "\"+str("
},
{
"char_end": 266,
"char_start": 263,
"chars": ")+\""
},
{
"char_end": 305,
"char_start": 299,
"chars": "\"+str("
},
{
"char_end": 315,
"char_start": 312,
"chars": ")+\""
},
{
"char_end": 340,
"char_start": 334,
"chars": "\"+str("
},
{
"char_end": 350,
"char_start": 347,
"chars": ")+\""
},
{
"char_end": 389,
"char_start": 383,
"chars": "\"+str("
},
{
"char_end": 399,
"char_start": 396,
"chars": ")+\""
}
]
},
"commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63",
"file_name": "endpoints.py",
"func_name": "h2h",
"line_changes": {
"added": [
{
"char_end": 267,
"char_start": 199,
"line": " sql = \"SELECT * FROM matches WHERE (player1 = '{player1}' OR \"\\\n",
"line_no": 8
},
{
"char_end": 337,
"char_start": 267,
"line": " +\"player2 = '{player1}') AND (player1 = '{player2}' OR \"\\\n",
"line_no": 9
},
{
"char_end": 395,
"char_start": 337,
"line": " +\"player2 = '{player2}') ORDER BY date DESC;\"\n",
"line_no": 10
},
{
"char_end": 447,
"char_start": 395,
"line": " args = {'player1': player1, 'player2': player2}\n",
"line_no": 11
},
{
"char_end": 479,
"char_start": 447,
"line": " result = db.exec(sql, args)\n",
"line_no": 12
}
],
"deleted": [
{
"char_end": 274,
"char_start": 199,
"line": " sql = \"SELECT * FROM matches WHERE (player1 = '\"+str(player1)+\"' OR \"\\\n",
"line_no": 8
},
{
"char_end": 358,
"char_start": 274,
"line": " +\"player2 = '\"+str(player1)+\"') AND (player1 = '\"+str(player2)+\"' OR \"\\\n",
"line_no": 9
},
{
"char_end": 423,
"char_start": 358,
"line": " +\"player2 = '\"+str(player2)+\"') ORDER BY date DESC;\"\n",
"line_no": 10
},
{
"char_end": 449,
"char_start": 423,
"line": " result = db.exec(sql)\n",
"line_no": 11
}
]
},
"vul_type": "cwe-089"
} | 271 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def insertData(self,userid,post):\n sqlText=\"insert into post(userid,date,comment) \\",
" values(%d,current_timestamp(0),'%s');\"%(userid,post);\n result=sql.insertDB(self.conn,sqlText)",
" return result;"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 120,
"char_start": 119,
"chars": "s"
},
{
"char_end": 164,
"char_start": 147,
"chars": "\n params=["
},
{
"char_end": 176,
"char_start": 175,
"chars": "]"
},
{
"char_end": 230,
"char_start": 223,
"chars": ",params"
}
],
"deleted": [
{
"char_end": 120,
"char_start": 119,
"chars": "d"
},
{
"char_end": 143,
"char_start": 142,
"chars": "'"
},
{
"char_end": 146,
"char_start": 145,
"chars": "'"
},
{
"char_end": 151,
"char_start": 149,
"chars": "%("
},
{
"char_end": 163,
"char_start": 162,
"chars": ")"
}
]
},
"commit_link": "github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9",
"file_name": "modules/post.py",
"func_name": "insertData",
"line_changes": {
"added": [
{
"char_end": 148,
"char_start": 95,
"line": " values(%s,current_timestamp(0),%s);\"\n",
"line_no": 3
},
{
"char_end": 178,
"char_start": 148,
"line": " params=[userid,post];\n",
"line_no": 4
},
{
"char_end": 232,
"char_start": 178,
"line": " result=sql.insertDB(self.conn,sqlText,params)\n",
"line_no": 5
}
],
"deleted": [
{
"char_end": 165,
"char_start": 95,
"line": " values(%d,current_timestamp(0),'%s');\"%(userid,post);\n",
"line_no": 3
},
{
"char_end": 212,
"char_start": 165,
"line": " result=sql.insertDB(self.conn,sqlText)\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 272 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def insertData(self,userid,post):\n sqlText=\"insert into post(userid,date,comment) \\",
" values(%s,current_timestamp(0),%s);\"\n params=[userid,post];\n result=sql.insertDB(self.conn,sqlText,params)",
" return result;"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 120,
"char_start": 119,
"chars": "s"
},
{
"char_end": 164,
"char_start": 147,
"chars": "\n params=["
},
{
"char_end": 176,
"char_start": 175,
"chars": "]"
},
{
"char_end": 230,
"char_start": 223,
"chars": ",params"
}
],
"deleted": [
{
"char_end": 120,
"char_start": 119,
"chars": "d"
},
{
"char_end": 143,
"char_start": 142,
"chars": "'"
},
{
"char_end": 146,
"char_start": 145,
"chars": "'"
},
{
"char_end": 151,
"char_start": 149,
"chars": "%("
},
{
"char_end": 163,
"char_start": 162,
"chars": ")"
}
]
},
"commit_link": "github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9",
"file_name": "modules/post.py",
"func_name": "insertData",
"line_changes": {
"added": [
{
"char_end": 148,
"char_start": 95,
"line": " values(%s,current_timestamp(0),%s);\"\n",
"line_no": 3
},
{
"char_end": 178,
"char_start": 148,
"line": " params=[userid,post];\n",
"line_no": 4
},
{
"char_end": 232,
"char_start": 178,
"line": " result=sql.insertDB(self.conn,sqlText,params)\n",
"line_no": 5
}
],
"deleted": [
{
"char_end": 165,
"char_start": 95,
"line": " values(%d,current_timestamp(0),'%s');\"%(userid,post);\n",
"line_no": 3
},
{
"char_end": 212,
"char_start": 165,
"line": " result=sql.insertDB(self.conn,sqlText)\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 272 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_requested_month_for_inverter(self, inverter_serial, date):\n data = dict()",
" month_start, month_end = self.get_epoch_month(date)\n data['interval'] = {'from': self.convert_local_ts_to_utc(month_start, self.local_timezone), 'to': self.convert_local_ts_to_utc(month_end, self.local_timezone)}\n month_total = 0",
" query = '''\n SELECT TimeStamp, DayYield AS Power \n FROM MonthData ",
" WHERE TimeStamp BETWEEN %s AND %s AND Serial = %s",
" '''",
" data['data'] = list()",
" for row in self.c.execute(query % (month_start, month_end, inverter_serial)):",
" data['data'].append({'time': self.convert_local_ts_to_utc(row[0], self.local_timezone), 'power': row[1]})\n month_total += row[1]",
" data['total'] = month_total",
" query = '''\n SELECT MIN(TimeStamp) as Min, MAX(TimeStamp) as Max \n FROM MonthData ",
" WHERE Serial = %s;\n ''' % inverter_serial",
"",
" self.c.execute(query)",
" first_data, last_data = self.c.fetchone()",
" if first_data: data['hasPrevious'] = (first_data < month_start)\n else: data['hasPrevious'] = False\n if last_data: data['hasNext'] = (last_data > month_end)\n else: data['hasNext'] = False",
" return data"
] | [
1,
1,
1,
0,
1,
1,
0,
1,
1,
1,
0,
1,
0,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 481,
"char_start": 480,
"chars": "?"
},
{
"char_end": 487,
"char_start": 486,
"chars": "?"
},
{
"char_end": 501,
"char_start": 499,
"chars": "?;"
},
{
"char_end": 589,
"char_start": 588,
"chars": ","
},
{
"char_end": 963,
"char_start": 962,
"chars": "?"
},
{
"char_end": 1030,
"char_start": 1010,
"chars": ", (inverter_serial,)"
}
],
"deleted": [
{
"char_end": 482,
"char_start": 480,
"chars": "%s"
},
{
"char_end": 489,
"char_start": 487,
"chars": "%s"
},
{
"char_end": 501,
"char_start": 500,
"chars": " "
},
{
"char_end": 505,
"char_start": 502,
"chars": " %s"
},
{
"char_end": 594,
"char_start": 592,
"chars": " %"
},
{
"char_end": 967,
"char_start": 966,
"chars": " "
},
{
"char_end": 971,
"char_start": 968,
"chars": " %s"
},
{
"char_end": 1006,
"char_start": 988,
"chars": " % inverter_serial"
}
]
},
"commit_link": "github.com/philipptrenz/sunportal/commit/7eef493a168ed4e6731ff800713bfb8aee99a506",
"file_name": "util/database.py",
"func_name": "get_requested_month_for_inverter",
"line_changes": {
"added": [
{
"char_end": 502,
"char_start": 444,
"line": " WHERE TimeStamp BETWEEN ? AND ? AND Serial=?;\n",
"line_no": 11
},
{
"char_end": 634,
"char_start": 549,
"line": " for row in self.c.execute(query, (month_start, month_end, inverter_serial)):\n",
"line_no": 15
},
{
"char_end": 965,
"char_start": 937,
"line": " WHERE Serial=?;\n",
"line_no": 24
},
{
"char_end": 981,
"char_start": 965,
"line": " '''\n",
"line_no": 25
},
{
"char_end": 1032,
"char_start": 982,
"line": " self.c.execute(query, (inverter_serial,))\n",
"line_no": 27
}
],
"deleted": [
{
"char_end": 506,
"char_start": 444,
"line": " WHERE TimeStamp BETWEEN %s AND %s AND Serial = %s\n",
"line_no": 11
},
{
"char_end": 639,
"char_start": 553,
"line": " for row in self.c.execute(query % (month_start, month_end, inverter_serial)):\n",
"line_no": 15
},
{
"char_end": 973,
"char_start": 942,
"line": " WHERE Serial = %s;\n",
"line_no": 24
},
{
"char_end": 1007,
"char_start": 973,
"line": " ''' % inverter_serial\n",
"line_no": 25
},
{
"char_end": 1038,
"char_start": 1008,
"line": " self.c.execute(query)\n",
"line_no": 27
}
]
},
"vul_type": "cwe-089"
} | 273 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_requested_month_for_inverter(self, inverter_serial, date):\n data = dict()",
" month_start, month_end = self.get_epoch_month(date)\n data['interval'] = {'from': self.convert_local_ts_to_utc(month_start, self.local_timezone), 'to': self.convert_local_ts_to_utc(month_end, self.local_timezone)}\n month_total = 0",
" query = '''\n SELECT TimeStamp, DayYield AS Power \n FROM MonthData ",
" WHERE TimeStamp BETWEEN ? AND ? AND Serial=?;",
" '''",
" data['data'] = list()",
" for row in self.c.execute(query, (month_start, month_end, inverter_serial)):",
" data['data'].append({'time': self.convert_local_ts_to_utc(row[0], self.local_timezone), 'power': row[1]})\n month_total += row[1]",
" data['total'] = month_total",
" query = '''\n SELECT MIN(TimeStamp) as Min, MAX(TimeStamp) as Max \n FROM MonthData ",
" WHERE Serial=?;\n '''",
"",
" self.c.execute(query, (inverter_serial,))",
" first_data, last_data = self.c.fetchone()",
" if first_data: data['hasPrevious'] = (first_data < month_start)\n else: data['hasPrevious'] = False\n if last_data: data['hasNext'] = (last_data > month_end)\n else: data['hasNext'] = False",
" return data"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 481,
"char_start": 480,
"chars": "?"
},
{
"char_end": 487,
"char_start": 486,
"chars": "?"
},
{
"char_end": 501,
"char_start": 499,
"chars": "?;"
},
{
"char_end": 589,
"char_start": 588,
"chars": ","
},
{
"char_end": 963,
"char_start": 962,
"chars": "?"
},
{
"char_end": 1030,
"char_start": 1010,
"chars": ", (inverter_serial,)"
}
],
"deleted": [
{
"char_end": 482,
"char_start": 480,
"chars": "%s"
},
{
"char_end": 489,
"char_start": 487,
"chars": "%s"
},
{
"char_end": 501,
"char_start": 500,
"chars": " "
},
{
"char_end": 505,
"char_start": 502,
"chars": " %s"
},
{
"char_end": 594,
"char_start": 592,
"chars": " %"
},
{
"char_end": 967,
"char_start": 966,
"chars": " "
},
{
"char_end": 971,
"char_start": 968,
"chars": " %s"
},
{
"char_end": 1006,
"char_start": 988,
"chars": " % inverter_serial"
}
]
},
"commit_link": "github.com/philipptrenz/sunportal/commit/7eef493a168ed4e6731ff800713bfb8aee99a506",
"file_name": "util/database.py",
"func_name": "get_requested_month_for_inverter",
"line_changes": {
"added": [
{
"char_end": 502,
"char_start": 444,
"line": " WHERE TimeStamp BETWEEN ? AND ? AND Serial=?;\n",
"line_no": 11
},
{
"char_end": 634,
"char_start": 549,
"line": " for row in self.c.execute(query, (month_start, month_end, inverter_serial)):\n",
"line_no": 15
},
{
"char_end": 965,
"char_start": 937,
"line": " WHERE Serial=?;\n",
"line_no": 24
},
{
"char_end": 981,
"char_start": 965,
"line": " '''\n",
"line_no": 25
},
{
"char_end": 1032,
"char_start": 982,
"line": " self.c.execute(query, (inverter_serial,))\n",
"line_no": 27
}
],
"deleted": [
{
"char_end": 506,
"char_start": 444,
"line": " WHERE TimeStamp BETWEEN %s AND %s AND Serial = %s\n",
"line_no": 11
},
{
"char_end": 639,
"char_start": 553,
"line": " for row in self.c.execute(query % (month_start, month_end, inverter_serial)):\n",
"line_no": 15
},
{
"char_end": 973,
"char_start": 942,
"line": " WHERE Serial = %s;\n",
"line_no": 24
},
{
"char_end": 1007,
"char_start": 973,
"line": " ''' % inverter_serial\n",
"line_no": 25
},
{
"char_end": 1038,
"char_start": 1008,
"line": " self.c.execute(query)\n",
"line_no": 27
}
]
},
"vul_type": "cwe-089"
} | 273 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"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)",
" query = \"DELETE FROM %s WHERE identifier = '%s';\" % (self.table, sid)\n self._query(query)"
] | [
1,
0
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 266,
"char_start": 264,
"chars": "$1"
},
{
"char_end": 314,
"char_start": 309,
"chars": ", sid"
}
],
"deleted": [
{
"char_end": 268,
"char_start": 264,
"chars": "'%s'"
},
{
"char_end": 289,
"char_start": 284,
"chars": ", sid"
}
]
},
"commit_link": "github.com/cheshire3/cheshire3/commit/d350363b4ea10f102c24c8f26d7b76b006323e8e",
"file_name": "cheshire3/sql/resultSetStore.py",
"func_name": "delete_resultSet",
"line_changes": {
"added": [
{
"char_end": 284,
"char_start": 213,
"line": " query = \"DELETE FROM %s WHERE identifier = $1;\" % (self.table)\n",
"line_no": 6
},
{
"char_end": 315,
"char_start": 284,
"line": " self._query(query, sid)",
"line_no": 7
}
],
"deleted": [
{
"char_end": 291,
"char_start": 213,
"line": " query = \"DELETE FROM %s WHERE identifier = '%s';\" % (self.table, sid)\n",
"line_no": 6
},
{
"char_end": 317,
"char_start": 291,
"line": " self._query(query)\n",
"line_no": 7
}
]
},
"vul_type": "cwe-089"
} | 274 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"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)",
" query = \"DELETE FROM %s WHERE identifier = $1;\" % (self.table)\n self._query(query, sid)"
] | [
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 266,
"char_start": 264,
"chars": "$1"
},
{
"char_end": 314,
"char_start": 309,
"chars": ", sid"
}
],
"deleted": [
{
"char_end": 268,
"char_start": 264,
"chars": "'%s'"
},
{
"char_end": 289,
"char_start": 284,
"chars": ", sid"
}
]
},
"commit_link": "github.com/cheshire3/cheshire3/commit/d350363b4ea10f102c24c8f26d7b76b006323e8e",
"file_name": "cheshire3/sql/resultSetStore.py",
"func_name": "delete_resultSet",
"line_changes": {
"added": [
{
"char_end": 284,
"char_start": 213,
"line": " query = \"DELETE FROM %s WHERE identifier = $1;\" % (self.table)\n",
"line_no": 6
},
{
"char_end": 315,
"char_start": 284,
"line": " self._query(query, sid)",
"line_no": 7
}
],
"deleted": [
{
"char_end": 291,
"char_start": 213,
"line": " query = \"DELETE FROM %s WHERE identifier = '%s';\" % (self.table, sid)\n",
"line_no": 6
},
{
"char_end": 317,
"char_start": 291,
"line": " self._query(query)\n",
"line_no": 7
}
]
},
"vul_type": "cwe-089"
} | 274 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def getSeriesDateFromDatabase(submission):\n database = sqlite3.connect('database.db')\n cursor = database.cursor()",
" return cursor.execute(\"SELECT StartDate FROM SeriesTracking WHERE SeriesTitle = '\" + str(getTitle(submission)) + \"'\").fetchone()[0]",
" database.close()"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 205,
"char_start": 204,
"chars": "?"
},
{
"char_end": 207,
"char_start": 206,
"chars": ","
},
{
"char_end": 209,
"char_start": 208,
"chars": "["
},
{
"char_end": 230,
"char_start": 229,
"chars": "]"
}
],
"deleted": [
{
"char_end": 205,
"char_start": 204,
"chars": "'"
},
{
"char_end": 208,
"char_start": 206,
"chars": " +"
},
{
"char_end": 213,
"char_start": 209,
"chars": "str("
},
{
"char_end": 240,
"char_start": 233,
"chars": ") + \"'\""
}
]
},
"commit_link": "github.com/LiquidFun/Reddit-GeoGuessr-Tracking-Bot/commit/0cad2d52e24b05da32789fbc8face7a9999a71f9",
"file_name": "CheckAndPostForSeriesSubmissions.py",
"func_name": "getSeriesDateFromDatabase",
"line_changes": {
"added": [
{
"char_end": 246,
"char_start": 120,
"line": " return cursor.execute(\"SELECT StartDate FROM SeriesTracking WHERE SeriesTitle = ?\", [getTitle(submission)]).fetchone()[0]\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 256,
"char_start": 120,
"line": " return cursor.execute(\"SELECT StartDate FROM SeriesTracking WHERE SeriesTitle = '\" + str(getTitle(submission)) + \"'\").fetchone()[0]\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 275 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def getSeriesDateFromDatabase(submission):\n database = sqlite3.connect('database.db')\n cursor = database.cursor()",
" return cursor.execute(\"SELECT StartDate FROM SeriesTracking WHERE SeriesTitle = ?\", [getTitle(submission)]).fetchone()[0]",
" database.close()"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 205,
"char_start": 204,
"chars": "?"
},
{
"char_end": 207,
"char_start": 206,
"chars": ","
},
{
"char_end": 209,
"char_start": 208,
"chars": "["
},
{
"char_end": 230,
"char_start": 229,
"chars": "]"
}
],
"deleted": [
{
"char_end": 205,
"char_start": 204,
"chars": "'"
},
{
"char_end": 208,
"char_start": 206,
"chars": " +"
},
{
"char_end": 213,
"char_start": 209,
"chars": "str("
},
{
"char_end": 240,
"char_start": 233,
"chars": ") + \"'\""
}
]
},
"commit_link": "github.com/LiquidFun/Reddit-GeoGuessr-Tracking-Bot/commit/0cad2d52e24b05da32789fbc8face7a9999a71f9",
"file_name": "CheckAndPostForSeriesSubmissions.py",
"func_name": "getSeriesDateFromDatabase",
"line_changes": {
"added": [
{
"char_end": 246,
"char_start": 120,
"line": " return cursor.execute(\"SELECT StartDate FROM SeriesTracking WHERE SeriesTitle = ?\", [getTitle(submission)]).fetchone()[0]\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 256,
"char_start": 120,
"line": " return cursor.execute(\"SELECT StartDate FROM SeriesTracking WHERE SeriesTitle = '\" + str(getTitle(submission)) + \"'\").fetchone()[0]\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 275 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def karma_add(name):\n karma = karma_ask(name)\n db = db_connect()\n cursor = db.cursor()\n if karma is None:\n try:\n cursor.execute('''",
" INSERT INTO people(name,karma,shame) VALUES('{}',1,0)\n '''.format(name))",
" db.commit()\n logger.debug('Inserted into karmadb 1 karma for {}'.format(name))\n return 1\n except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise\n else:\n karma = karma + 1\n try:\n cursor.execute('''",
" UPDATE people SET karma = {0} WHERE name = '{1}'\n '''.format(karma, name))",
" db.commit()\n logger.debug('Inserted into karmadb {} karma for {}'.format(",
" karma, name))",
" return karma",
" except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise\n db.close()"
] | [
1,
0,
1,
0,
1,
0,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 230,
"char_start": 222,
"chars": "%(name)s"
},
{
"char_end": 257,
"char_start": 255,
"chars": ", "
},
{
"char_end": 636,
"char_start": 627,
"chars": "%(karma)s"
},
{
"char_end": 658,
"char_start": 650,
"chars": "%(name)s"
},
{
"char_end": 680,
"char_start": 678,
"chars": ", "
},
{
"char_end": 830,
"char_start": 814,
"chars": "\n "
},
{
"char_end": 849,
"char_start": 835,
"chars": ",\n "
}
],
"deleted": [
{
"char_end": 226,
"char_start": 222,
"chars": "'{}'"
},
{
"char_end": 259,
"char_start": 251,
"chars": ".format("
},
{
"char_end": 264,
"char_start": 263,
"chars": ")"
},
{
"char_end": 633,
"char_start": 630,
"chars": "{0}"
},
{
"char_end": 652,
"char_start": 647,
"chars": "'{1}'"
},
{
"char_end": 679,
"char_start": 672,
"chars": ".format"
}
]
},
"commit_link": "github.com/tylarb/KarmaBoi-PCF/commit/c1d00a27d7f6b7eb6f15a3dacd4269654a32c10a",
"file_name": "KarmaBoi/dbopts.py",
"func_name": "karma_add",
"line_changes": {
"added": [
{
"char_end": 236,
"char_start": 162,
"line": " INSERT INTO people(name,karma,shame) VALUES(%(name)s,1,0)\n",
"line_no": 8
},
{
"char_end": 263,
"char_start": 236,
"line": " ''', name)\n",
"line_no": 9
},
{
"char_end": 659,
"char_start": 585,
"line": " UPDATE people SET karma = %(karma)s WHERE name = %(name)s\n",
"line_no": 20
},
{
"char_end": 695,
"char_start": 659,
"line": " ''', (karma, name))\n",
"line_no": 21
},
{
"char_end": 815,
"char_start": 792,
"line": " karma,\n",
"line_no": 24
},
{
"char_end": 837,
"char_start": 815,
"line": " name,\n",
"line_no": 25
},
{
"char_end": 852,
"char_start": 837,
"line": " ))\n",
"line_no": 26
}
],
"deleted": [
{
"char_end": 232,
"char_start": 162,
"line": " INSERT INTO people(name,karma,shame) VALUES('{}',1,0)\n",
"line_no": 8
},
{
"char_end": 266,
"char_start": 232,
"line": " '''.format(name))\n",
"line_no": 9
},
{
"char_end": 653,
"char_start": 588,
"line": " UPDATE people SET karma = {0} WHERE name = '{1}'\n",
"line_no": 20
},
{
"char_end": 694,
"char_start": 653,
"line": " '''.format(karma, name))\n",
"line_no": 21
},
{
"char_end": 821,
"char_start": 791,
"line": " karma, name))\n",
"line_no": 24
}
]
},
"vul_type": "cwe-089"
} | 276 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def karma_add(name):\n karma = karma_ask(name)\n db = db_connect()\n cursor = db.cursor()\n if karma is None:\n try:\n cursor.execute('''",
" INSERT INTO people(name,karma,shame) VALUES(%(name)s,1,0)\n ''', name)",
" db.commit()\n logger.debug('Inserted into karmadb 1 karma for {}'.format(name))\n return 1\n except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise\n else:\n karma = karma + 1\n try:\n cursor.execute('''",
" UPDATE people SET karma = %(karma)s WHERE name = %(name)s\n ''', (karma, name))",
" db.commit()\n logger.debug('Inserted into karmadb {} karma for {}'.format(",
" karma,\n name,\n ))",
" return karma",
" except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise\n db.close()"
] | [
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 230,
"char_start": 222,
"chars": "%(name)s"
},
{
"char_end": 257,
"char_start": 255,
"chars": ", "
},
{
"char_end": 636,
"char_start": 627,
"chars": "%(karma)s"
},
{
"char_end": 658,
"char_start": 650,
"chars": "%(name)s"
},
{
"char_end": 680,
"char_start": 678,
"chars": ", "
},
{
"char_end": 830,
"char_start": 814,
"chars": "\n "
},
{
"char_end": 849,
"char_start": 835,
"chars": ",\n "
}
],
"deleted": [
{
"char_end": 226,
"char_start": 222,
"chars": "'{}'"
},
{
"char_end": 259,
"char_start": 251,
"chars": ".format("
},
{
"char_end": 264,
"char_start": 263,
"chars": ")"
},
{
"char_end": 633,
"char_start": 630,
"chars": "{0}"
},
{
"char_end": 652,
"char_start": 647,
"chars": "'{1}'"
},
{
"char_end": 679,
"char_start": 672,
"chars": ".format"
}
]
},
"commit_link": "github.com/tylarb/KarmaBoi-PCF/commit/c1d00a27d7f6b7eb6f15a3dacd4269654a32c10a",
"file_name": "KarmaBoi/dbopts.py",
"func_name": "karma_add",
"line_changes": {
"added": [
{
"char_end": 236,
"char_start": 162,
"line": " INSERT INTO people(name,karma,shame) VALUES(%(name)s,1,0)\n",
"line_no": 8
},
{
"char_end": 263,
"char_start": 236,
"line": " ''', name)\n",
"line_no": 9
},
{
"char_end": 659,
"char_start": 585,
"line": " UPDATE people SET karma = %(karma)s WHERE name = %(name)s\n",
"line_no": 20
},
{
"char_end": 695,
"char_start": 659,
"line": " ''', (karma, name))\n",
"line_no": 21
},
{
"char_end": 815,
"char_start": 792,
"line": " karma,\n",
"line_no": 24
},
{
"char_end": 837,
"char_start": 815,
"line": " name,\n",
"line_no": 25
},
{
"char_end": 852,
"char_start": 837,
"line": " ))\n",
"line_no": 26
}
],
"deleted": [
{
"char_end": 232,
"char_start": 162,
"line": " INSERT INTO people(name,karma,shame) VALUES('{}',1,0)\n",
"line_no": 8
},
{
"char_end": 266,
"char_start": 232,
"line": " '''.format(name))\n",
"line_no": 9
},
{
"char_end": 653,
"char_start": 588,
"line": " UPDATE people SET karma = {0} WHERE name = '{1}'\n",
"line_no": 20
},
{
"char_end": 694,
"char_start": 653,
"line": " '''.format(karma, name))\n",
"line_no": 21
},
{
"char_end": 821,
"char_start": 791,
"line": " karma, name))\n",
"line_no": 24
}
]
},
"vul_type": "cwe-089"
} | 276 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def update_date_modified(self):",
"",
" sql = \"UPDATE jdk_entries \" + \\",
" \"SET date_last_modified = \" + CURRENT_DATESTAMP + \" \" + \\\n \"WHERE jdk_entries.id = '\" + self.entry_id + \"';\"",
" ",
" db_execute(sql)",
"\n return None"
] | [
1,
0,
1,
0,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 90,
"char_start": 38,
"chars": "quote_tuple = CURRENT_DATESTAMP, self.entry_id\n\n "
},
{
"char_end": 155,
"char_start": 154,
"chars": "?"
},
{
"char_end": 193,
"char_start": 192,
"chars": "?"
},
{
"char_end": 232,
"char_start": 219,
"chars": ", quote_tuple"
}
],
"deleted": [
{
"char_end": 127,
"char_start": 102,
"chars": "\" + CURRENT_DATESTAMP + \""
},
{
"char_end": 187,
"char_start": 164,
"chars": "'\" + self.entry_id + \"'"
}
]
},
"commit_link": "github.com/peterlebrun/jdk/commit/000238566fbe55ba09676c3d57af04ae207235ae",
"file_name": "entry.py",
"func_name": "update_date_modified",
"line_changes": {
"added": [
{
"char_end": 85,
"char_start": 34,
"line": " quote_tuple = CURRENT_DATESTAMP, self.entry_id\n",
"line_no": 2
},
{
"char_end": 86,
"char_start": 85,
"line": "\n",
"line_no": 3
},
{
"char_end": 162,
"char_start": 122,
"line": " \"SET date_last_modified = ? \" + \\\n",
"line_no": 5
},
{
"char_end": 196,
"char_start": 162,
"line": " \"WHERE jdk_entries.id = ?;\"\n",
"line_no": 6
},
{
"char_end": 234,
"char_start": 201,
"line": " db_execute(sql, quote_tuple)\n",
"line_no": 8
}
],
"deleted": [
{
"char_end": 134,
"char_start": 70,
"line": " \"SET date_last_modified = \" + CURRENT_DATESTAMP + \" \" + \\\n",
"line_no": 3
},
{
"char_end": 190,
"char_start": 134,
"line": " \"WHERE jdk_entries.id = '\" + self.entry_id + \"';\"\n",
"line_no": 4
},
{
"char_end": 215,
"char_start": 195,
"line": " db_execute(sql)\n",
"line_no": 6
}
]
},
"vul_type": "cwe-089"
} | 277 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def update_date_modified(self):",
" quote_tuple = CURRENT_DATESTAMP, self.entry_id\n",
" sql = \"UPDATE jdk_entries \" + \\",
" \"SET date_last_modified = ? \" + \\\n \"WHERE jdk_entries.id = ?;\"",
" ",
" db_execute(sql, quote_tuple)",
"\n return None"
] | [
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 90,
"char_start": 38,
"chars": "quote_tuple = CURRENT_DATESTAMP, self.entry_id\n\n "
},
{
"char_end": 155,
"char_start": 154,
"chars": "?"
},
{
"char_end": 193,
"char_start": 192,
"chars": "?"
},
{
"char_end": 232,
"char_start": 219,
"chars": ", quote_tuple"
}
],
"deleted": [
{
"char_end": 127,
"char_start": 102,
"chars": "\" + CURRENT_DATESTAMP + \""
},
{
"char_end": 187,
"char_start": 164,
"chars": "'\" + self.entry_id + \"'"
}
]
},
"commit_link": "github.com/peterlebrun/jdk/commit/000238566fbe55ba09676c3d57af04ae207235ae",
"file_name": "entry.py",
"func_name": "update_date_modified",
"line_changes": {
"added": [
{
"char_end": 85,
"char_start": 34,
"line": " quote_tuple = CURRENT_DATESTAMP, self.entry_id\n",
"line_no": 2
},
{
"char_end": 86,
"char_start": 85,
"line": "\n",
"line_no": 3
},
{
"char_end": 162,
"char_start": 122,
"line": " \"SET date_last_modified = ? \" + \\\n",
"line_no": 5
},
{
"char_end": 196,
"char_start": 162,
"line": " \"WHERE jdk_entries.id = ?;\"\n",
"line_no": 6
},
{
"char_end": 234,
"char_start": 201,
"line": " db_execute(sql, quote_tuple)\n",
"line_no": 8
}
],
"deleted": [
{
"char_end": 134,
"char_start": 70,
"line": " \"SET date_last_modified = \" + CURRENT_DATESTAMP + \" \" + \\\n",
"line_no": 3
},
{
"char_end": 190,
"char_start": 134,
"line": " \"WHERE jdk_entries.id = '\" + self.entry_id + \"';\"\n",
"line_no": 4
},
{
"char_end": 215,
"char_start": 195,
"line": " db_execute(sql)\n",
"line_no": 6
}
]
},
"vul_type": "cwe-089"
} | 277 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def system_search(self, search):\r\n search = search.lower()\r\n conn = sqlite3.connect('data/ed.db').cursor()\r",
" table = conn.execute(f\"select * from populated where lower(name) = '{search}'\")\r",
" results = table.fetchone()\r\n if not results:\r",
" table = conn.execute(f\"select * from systems where lower(name) = '{search}'\")\r",
" results = table.fetchone()\r\n if results:\r\n keys = tuple(i[0] for i in table.description) \r\n return '\\n'.join(f'{key.replace(\"_\", \" \").title()}: {field}'\r\n for key, field in zip(keys[1:], results[1:]) if field)\r\n else:\r\n return 'No systems found.'"
] | [
1,
0,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 156,
"char_start": 155,
"chars": "'"
},
{
"char_end": 201,
"char_start": 200,
"chars": "?"
},
{
"char_end": 205,
"char_start": 202,
"chars": ", ("
},
{
"char_end": 213,
"char_start": 211,
"chars": ",)"
},
{
"char_end": 311,
"char_start": 310,
"chars": "'"
},
{
"char_end": 354,
"char_start": 353,
"chars": "?"
},
{
"char_end": 358,
"char_start": 355,
"chars": ", ("
},
{
"char_end": 366,
"char_start": 364,
"chars": ",)"
}
],
"deleted": [
{
"char_end": 157,
"char_start": 155,
"chars": "f\""
},
{
"char_end": 203,
"char_start": 202,
"chars": "{"
},
{
"char_end": 212,
"char_start": 209,
"chars": "}'\""
},
{
"char_end": 311,
"char_start": 309,
"chars": "f\""
},
{
"char_end": 355,
"char_start": 354,
"chars": "{"
},
{
"char_end": 364,
"char_start": 361,
"chars": "}'\""
}
]
},
"commit_link": "github.com/BeatButton/beattie/commit/ab36b2053ee09faf4cc9a279cf7a4c010864cb29",
"file_name": "eddb.py",
"func_name": "system_search",
"line_changes": {
"added": [
{
"char_end": 216,
"char_start": 126,
"line": " table = conn.execute('select * from populated where lower(name) = ?', (search,))\r\n",
"line_no": 4
},
{
"char_end": 369,
"char_start": 277,
"line": " table = conn.execute('select * from systems where lower(name) = ?', (search,))\r\n",
"line_no": 7
}
],
"deleted": [
{
"char_end": 215,
"char_start": 126,
"line": " table = conn.execute(f\"select * from populated where lower(name) = '{search}'\")\r\n",
"line_no": 4
},
{
"char_end": 367,
"char_start": 276,
"line": " table = conn.execute(f\"select * from systems where lower(name) = '{search}'\")\r\n",
"line_no": 7
}
]
},
"vul_type": "cwe-089"
} | 278 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def system_search(self, search):\r\n search = search.lower()\r\n conn = sqlite3.connect('data/ed.db').cursor()\r",
" table = conn.execute('select * from populated where lower(name) = ?', (search,))\r",
" results = table.fetchone()\r\n if not results:\r",
" table = conn.execute('select * from systems where lower(name) = ?', (search,))\r",
" results = table.fetchone()\r\n if results:\r\n keys = tuple(i[0] for i in table.description) \r\n return '\\n'.join(f'{key.replace(\"_\", \" \").title()}: {field}'\r\n for key, field in zip(keys[1:], results[1:]) if field)\r\n else:\r\n return 'No systems found.'"
] | [
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 156,
"char_start": 155,
"chars": "'"
},
{
"char_end": 201,
"char_start": 200,
"chars": "?"
},
{
"char_end": 205,
"char_start": 202,
"chars": ", ("
},
{
"char_end": 213,
"char_start": 211,
"chars": ",)"
},
{
"char_end": 311,
"char_start": 310,
"chars": "'"
},
{
"char_end": 354,
"char_start": 353,
"chars": "?"
},
{
"char_end": 358,
"char_start": 355,
"chars": ", ("
},
{
"char_end": 366,
"char_start": 364,
"chars": ",)"
}
],
"deleted": [
{
"char_end": 157,
"char_start": 155,
"chars": "f\""
},
{
"char_end": 203,
"char_start": 202,
"chars": "{"
},
{
"char_end": 212,
"char_start": 209,
"chars": "}'\""
},
{
"char_end": 311,
"char_start": 309,
"chars": "f\""
},
{
"char_end": 355,
"char_start": 354,
"chars": "{"
},
{
"char_end": 364,
"char_start": 361,
"chars": "}'\""
}
]
},
"commit_link": "github.com/BeatButton/beattie/commit/ab36b2053ee09faf4cc9a279cf7a4c010864cb29",
"file_name": "eddb.py",
"func_name": "system_search",
"line_changes": {
"added": [
{
"char_end": 216,
"char_start": 126,
"line": " table = conn.execute('select * from populated where lower(name) = ?', (search,))\r\n",
"line_no": 4
},
{
"char_end": 369,
"char_start": 277,
"line": " table = conn.execute('select * from systems where lower(name) = ?', (search,))\r\n",
"line_no": 7
}
],
"deleted": [
{
"char_end": 215,
"char_start": 126,
"line": " table = conn.execute(f\"select * from populated where lower(name) = '{search}'\")\r\n",
"line_no": 4
},
{
"char_end": 367,
"char_start": 276,
"line": " table = conn.execute(f\"select * from systems where lower(name) = '{search}'\")\r\n",
"line_no": 7
}
]
},
"vul_type": "cwe-089"
} | 278 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def add_input(self, data):\n connection = self.connect()\n try:\n # The following introduces a deliberate security flaw - SQL Injection",
" query = \"INSERT INTO crimes (description) VALUES ('{}');\".format(data)",
" with connection.cursor() as cursor:",
" cursor.execute(query)",
" connection.commit()\n finally:\n connection.close()"
] | [
1,
0,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 226,
"char_start": 224,
"chars": "%s"
},
{
"char_end": 320,
"char_start": 314,
"chars": ", data"
}
],
"deleted": [
{
"char_end": 228,
"char_start": 224,
"chars": "'{}'"
},
{
"char_end": 244,
"char_start": 231,
"chars": ".format(data)"
}
]
},
"commit_link": "github.com/rwolf527/crimemap/commit/50b0695e0b4c46165e6146f6fac4cd6871d9fdf6",
"file_name": "dbhelper.py",
"func_name": "add_input",
"line_changes": {
"added": [
{
"char_end": 230,
"char_start": 162,
"line": " query = \"INSERT INTO crimes (description) VALUES (%s);\"\n",
"line_no": 5
},
{
"char_end": 322,
"char_start": 278,
"line": " cursor.execute(query, data)\n",
"line_no": 7
}
],
"deleted": [
{
"char_end": 245,
"char_start": 162,
"line": " query = \"INSERT INTO crimes (description) VALUES ('{}');\".format(data)\n",
"line_no": 5
},
{
"char_end": 331,
"char_start": 293,
"line": " cursor.execute(query)\n",
"line_no": 7
}
]
},
"vul_type": "cwe-089"
} | 279 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def add_input(self, data):\n connection = self.connect()\n try:\n # The following introduces a deliberate security flaw - SQL Injection",
" query = \"INSERT INTO crimes (description) VALUES (%s);\"",
" with connection.cursor() as cursor:",
" cursor.execute(query, data)",
" connection.commit()\n finally:\n connection.close()"
] | [
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 226,
"char_start": 224,
"chars": "%s"
},
{
"char_end": 320,
"char_start": 314,
"chars": ", data"
}
],
"deleted": [
{
"char_end": 228,
"char_start": 224,
"chars": "'{}'"
},
{
"char_end": 244,
"char_start": 231,
"chars": ".format(data)"
}
]
},
"commit_link": "github.com/rwolf527/crimemap/commit/50b0695e0b4c46165e6146f6fac4cd6871d9fdf6",
"file_name": "dbhelper.py",
"func_name": "add_input",
"line_changes": {
"added": [
{
"char_end": 230,
"char_start": 162,
"line": " query = \"INSERT INTO crimes (description) VALUES (%s);\"\n",
"line_no": 5
},
{
"char_end": 322,
"char_start": 278,
"line": " cursor.execute(query, data)\n",
"line_no": 7
}
],
"deleted": [
{
"char_end": 245,
"char_start": 162,
"line": " query = \"INSERT INTO crimes (description) VALUES ('{}');\".format(data)\n",
"line_no": 5
},
{
"char_end": 331,
"char_start": 293,
"line": " cursor.execute(query)\n",
"line_no": 7
}
]
},
"vul_type": "cwe-089"
} | 279 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@bot.message_handler(commands =['login'])\ndef get_login(message):\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\bases\\\\settings.db\")\n conn = settings.cursor()",
" conn.execute(\"select * from users where chat_id = '\" + str(message.chat.id) + \"'\")",
" name = conn.fetchone()\n if name != None:\n bot.send_message(message.chat.id, \"Previous handle: \" + str(name[1]))\n else:\n bot.send_message(message.chat.id, \"Previous handle: None\")\n settings.close()\n bot.send_message(message.chat.id, \"Type new handle: \")\n set_state(message.chat.id, config.States.S_LOGIN.value)"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 250,
"char_start": 249,
"chars": "?"
},
{
"char_end": 252,
"char_start": 251,
"chars": ","
},
{
"char_end": 254,
"char_start": 253,
"chars": "("
},
{
"char_end": 276,
"char_start": 274,
"chars": ",)"
}
],
"deleted": [
{
"char_end": 250,
"char_start": 249,
"chars": "'"
},
{
"char_end": 253,
"char_start": 251,
"chars": " +"
},
{
"char_end": 280,
"char_start": 274,
"chars": " + \"'\""
}
]
},
"commit_link": "github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90",
"file_name": "bot.py",
"func_name": "get_login",
"line_changes": {
"added": [
{
"char_end": 278,
"char_start": 195,
"line": " conn.execute(\"select * from users where chat_id = ?\", (str(message.chat.id),))\n",
"line_no": 5
}
],
"deleted": [
{
"char_end": 282,
"char_start": 195,
"line": " conn.execute(\"select * from users where chat_id = '\" + str(message.chat.id) + \"'\")\n",
"line_no": 5
}
]
},
"vul_type": "cwe-089"
} | 280 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@bot.message_handler(commands =['login'])\ndef get_login(message):\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\bases\\\\settings.db\")\n conn = settings.cursor()",
" conn.execute(\"select * from users where chat_id = ?\", (str(message.chat.id),))",
" name = conn.fetchone()\n if name != None:\n bot.send_message(message.chat.id, \"Previous handle: \" + str(name[1]))\n else:\n bot.send_message(message.chat.id, \"Previous handle: None\")\n settings.close()\n bot.send_message(message.chat.id, \"Type new handle: \")\n set_state(message.chat.id, config.States.S_LOGIN.value)"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 250,
"char_start": 249,
"chars": "?"
},
{
"char_end": 252,
"char_start": 251,
"chars": ","
},
{
"char_end": 254,
"char_start": 253,
"chars": "("
},
{
"char_end": 276,
"char_start": 274,
"chars": ",)"
}
],
"deleted": [
{
"char_end": 250,
"char_start": 249,
"chars": "'"
},
{
"char_end": 253,
"char_start": 251,
"chars": " +"
},
{
"char_end": 280,
"char_start": 274,
"chars": " + \"'\""
}
]
},
"commit_link": "github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90",
"file_name": "bot.py",
"func_name": "get_login",
"line_changes": {
"added": [
{
"char_end": 278,
"char_start": 195,
"line": " conn.execute(\"select * from users where chat_id = ?\", (str(message.chat.id),))\n",
"line_no": 5
}
],
"deleted": [
{
"char_end": 282,
"char_start": 195,
"line": " conn.execute(\"select * from users where chat_id = '\" + str(message.chat.id) + \"'\")\n",
"line_no": 5
}
]
},
"vul_type": "cwe-089"
} | 280 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def login(self, username, password):\n select_query = \"\"\"\n SELECT client_id, username, balance, message\n FROM Clients",
" WHERE username = '{}' AND password = '{}'",
" LIMIT 1",
" \"\"\".format(username, password)",
"\n cursor = self.__conn.cursor()\n",
" cursor.execute(select_query)",
" user = cursor.fetchone()",
" if(user):\n return Client(user[0], user[1], user[2], user[3])\n else:\n return False"
] | [
1,
0,
1,
0,
1,
0,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 180,
"char_start": 179,
"chars": "?"
},
{
"char_end": 197,
"char_start": 196,
"chars": "?"
},
{
"char_end": 327,
"char_start": 305,
"chars": ", (username, password)"
}
],
"deleted": [
{
"char_end": 183,
"char_start": 179,
"chars": "'{}'"
},
{
"char_end": 203,
"char_start": 199,
"chars": "'{}'"
},
{
"char_end": 262,
"char_start": 235,
"chars": ".format(username, password)"
}
]
},
"commit_link": "github.com/AnetaStoycheva/Programming101_HackBulgaria/commit/c0d6f4b8fe83a375832845a45952b5153e4c34f3",
"file_name": "Week_9/sql_manager.py",
"func_name": "login",
"line_changes": {
"added": [
{
"char_end": 198,
"char_start": 150,
"line": " WHERE username = ? AND password = ?\n",
"line_no": 5
},
{
"char_end": 230,
"char_start": 218,
"line": " \"\"\"\n",
"line_no": 7
},
{
"char_end": 329,
"char_start": 270,
"line": " cursor.execute(select_query, (username, password))\n",
"line_no": 11
}
],
"deleted": [
{
"char_end": 204,
"char_start": 150,
"line": " WHERE username = '{}' AND password = '{}'\n",
"line_no": 5
},
{
"char_end": 263,
"char_start": 224,
"line": " \"\"\".format(username, password)\n",
"line_no": 7
},
{
"char_end": 340,
"char_start": 303,
"line": " cursor.execute(select_query)\n",
"line_no": 11
}
]
},
"vul_type": "cwe-089"
} | 281 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def login(self, username, password):\n select_query = \"\"\"\n SELECT client_id, username, balance, message\n FROM Clients",
" WHERE username = ? AND password = ?",
" LIMIT 1",
" \"\"\"",
"\n cursor = self.__conn.cursor()\n",
" cursor.execute(select_query, (username, password))",
" user = cursor.fetchone()",
" if(user):\n return Client(user[0], user[1], user[2], user[3])\n else:\n return False"
] | [
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 180,
"char_start": 179,
"chars": "?"
},
{
"char_end": 197,
"char_start": 196,
"chars": "?"
},
{
"char_end": 327,
"char_start": 305,
"chars": ", (username, password)"
}
],
"deleted": [
{
"char_end": 183,
"char_start": 179,
"chars": "'{}'"
},
{
"char_end": 203,
"char_start": 199,
"chars": "'{}'"
},
{
"char_end": 262,
"char_start": 235,
"chars": ".format(username, password)"
}
]
},
"commit_link": "github.com/AnetaStoycheva/Programming101_HackBulgaria/commit/c0d6f4b8fe83a375832845a45952b5153e4c34f3",
"file_name": "Week_9/sql_manager.py",
"func_name": "login",
"line_changes": {
"added": [
{
"char_end": 198,
"char_start": 150,
"line": " WHERE username = ? AND password = ?\n",
"line_no": 5
},
{
"char_end": 230,
"char_start": 218,
"line": " \"\"\"\n",
"line_no": 7
},
{
"char_end": 329,
"char_start": 270,
"line": " cursor.execute(select_query, (username, password))\n",
"line_no": 11
}
],
"deleted": [
{
"char_end": 204,
"char_start": 150,
"line": " WHERE username = '{}' AND password = '{}'\n",
"line_no": 5
},
{
"char_end": 263,
"char_start": 224,
"line": " \"\"\".format(username, password)\n",
"line_no": 7
},
{
"char_end": 340,
"char_start": 303,
"line": " cursor.execute(select_query)\n",
"line_no": 11
}
]
},
"vul_type": "cwe-089"
} | 281 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_current_state(chat_id):\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__))+\"\\\\bases\\\\settings.db\")\n conn = settings.cursor()",
" conn.execute(\"select * from users where chat_id = '\" + str(chat_id) + \"'\")",
" name = conn.fetchone()\n if name != None:\n return name[4]\n else:\n return False\n settings.close()"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 214,
"char_start": 213,
"chars": "?"
},
{
"char_end": 216,
"char_start": 215,
"chars": ","
},
{
"char_end": 218,
"char_start": 217,
"chars": "("
},
{
"char_end": 232,
"char_start": 230,
"chars": ",)"
}
],
"deleted": [
{
"char_end": 214,
"char_start": 213,
"chars": "'"
},
{
"char_end": 217,
"char_start": 215,
"chars": " +"
},
{
"char_end": 236,
"char_start": 230,
"chars": " + \"'\""
}
]
},
"commit_link": "github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90",
"file_name": "bot.py",
"func_name": "get_current_state",
"line_changes": {
"added": [
{
"char_end": 234,
"char_start": 159,
"line": " conn.execute(\"select * from users where chat_id = ?\", (str(chat_id),))\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 238,
"char_start": 159,
"line": " conn.execute(\"select * from users where chat_id = '\" + str(chat_id) + \"'\")\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 282 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_current_state(chat_id):\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__))+\"\\\\bases\\\\settings.db\")\n conn = settings.cursor()",
" conn.execute(\"select * from users where chat_id = ?\", (str(chat_id),))",
" name = conn.fetchone()\n if name != None:\n return name[4]\n else:\n return False\n settings.close()"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 214,
"char_start": 213,
"chars": "?"
},
{
"char_end": 216,
"char_start": 215,
"chars": ","
},
{
"char_end": 218,
"char_start": 217,
"chars": "("
},
{
"char_end": 232,
"char_start": 230,
"chars": ",)"
}
],
"deleted": [
{
"char_end": 214,
"char_start": 213,
"chars": "'"
},
{
"char_end": 217,
"char_start": 215,
"chars": " +"
},
{
"char_end": 236,
"char_start": 230,
"chars": " + \"'\""
}
]
},
"commit_link": "github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90",
"file_name": "bot.py",
"func_name": "get_current_state",
"line_changes": {
"added": [
{
"char_end": 234,
"char_start": 159,
"line": " conn.execute(\"select * from users where chat_id = ?\", (str(chat_id),))\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 238,
"char_start": 159,
"line": " conn.execute(\"select * from users where chat_id = '\" + str(chat_id) + \"'\")\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 282 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def fetch_page_name(self, page_id):\n '''\n Returns the page name corresponding to the provided page ID.",
" Args:\n page_id: The page ID whose ID to fetch.",
" Returns:\n str: The page name corresponding to the provided page ID.",
" Raises:\n ValueError: If the provided page ID is invalid or does not exist.\n '''\n helpers.validate_page_id(page_id)\n",
" query = 'SELECT name FROM pages WHERE id=\"{0}\"'.format(page_id)\n self.cursor.execute(query)",
"\n page_name = self.cursor.fetchone()",
" if not page_name:\n raise ValueError('Invalid page ID \"{0}\" provided. Page ID does not exist.'.format(page_id))",
" return page_name[0].encode('utf-8').replace('_', ' ')"
] | [
1,
1,
1,
1,
0,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 423,
"char_start": 422,
"chars": " "
},
{
"char_end": 427,
"char_start": 424,
"chars": " ?;"
},
{
"char_end": 436,
"char_start": 428,
"chars": "\n que"
},
{
"char_end": 450,
"char_start": 437,
"chars": "y_bindings = "
},
{
"char_end": 459,
"char_start": 458,
"chars": ","
},
{
"char_end": 506,
"char_start": 490,
"chars": ", query_bindings"
}
],
"deleted": [
{
"char_end": 428,
"char_start": 423,
"chars": "\"{0}\""
},
{
"char_end": 432,
"char_start": 429,
"chars": ".fo"
},
{
"char_end": 436,
"char_start": 433,
"chars": "mat"
}
]
},
"commit_link": "github.com/jwngr/sdow/commit/4db98f3521592f17550d2b723336f33fec5e112a",
"file_name": "sdow/database.py",
"func_name": "fetch_page_name",
"line_changes": {
"added": [
{
"char_end": 429,
"char_start": 378,
"line": " query = 'SELECT name FROM pages WHERE id = ?;'\n",
"line_no": 16
},
{
"char_end": 461,
"char_start": 429,
"line": " query_bindings = (page_id,)\n",
"line_no": 17
},
{
"char_end": 508,
"char_start": 461,
"line": " self.cursor.execute(query, query_bindings)\n",
"line_no": 18
}
],
"deleted": [
{
"char_end": 446,
"char_start": 378,
"line": " query = 'SELECT name FROM pages WHERE id=\"{0}\"'.format(page_id)\n",
"line_no": 16
},
{
"char_end": 477,
"char_start": 446,
"line": " self.cursor.execute(query)\n",
"line_no": 17
}
]
},
"vul_type": "cwe-089"
} | 283 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def fetch_page_name(self, page_id):\n '''\n Returns the page name corresponding to the provided page ID.",
" Args:\n page_id: The page ID whose ID to fetch.",
" Returns:\n str: The page name corresponding to the provided page ID.",
" Raises:\n ValueError: If the provided page ID is invalid or does not exist.\n '''\n helpers.validate_page_id(page_id)\n",
" query = 'SELECT name FROM pages WHERE id = ?;'\n query_bindings = (page_id,)\n self.cursor.execute(query, query_bindings)",
"\n page_name = self.cursor.fetchone()",
" if not page_name:\n raise ValueError('Invalid page ID \"{0}\" provided. Page ID does not exist.'.format(page_id))",
" return page_name[0].encode('utf-8').replace('_', ' ')"
] | [
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 423,
"char_start": 422,
"chars": " "
},
{
"char_end": 427,
"char_start": 424,
"chars": " ?;"
},
{
"char_end": 436,
"char_start": 428,
"chars": "\n que"
},
{
"char_end": 450,
"char_start": 437,
"chars": "y_bindings = "
},
{
"char_end": 459,
"char_start": 458,
"chars": ","
},
{
"char_end": 506,
"char_start": 490,
"chars": ", query_bindings"
}
],
"deleted": [
{
"char_end": 428,
"char_start": 423,
"chars": "\"{0}\""
},
{
"char_end": 432,
"char_start": 429,
"chars": ".fo"
},
{
"char_end": 436,
"char_start": 433,
"chars": "mat"
}
]
},
"commit_link": "github.com/jwngr/sdow/commit/4db98f3521592f17550d2b723336f33fec5e112a",
"file_name": "sdow/database.py",
"func_name": "fetch_page_name",
"line_changes": {
"added": [
{
"char_end": 429,
"char_start": 378,
"line": " query = 'SELECT name FROM pages WHERE id = ?;'\n",
"line_no": 16
},
{
"char_end": 461,
"char_start": 429,
"line": " query_bindings = (page_id,)\n",
"line_no": 17
},
{
"char_end": 508,
"char_start": 461,
"line": " self.cursor.execute(query, query_bindings)\n",
"line_no": 18
}
],
"deleted": [
{
"char_end": 446,
"char_start": 378,
"line": " query = 'SELECT name FROM pages WHERE id=\"{0}\"'.format(page_id)\n",
"line_no": 16
},
{
"char_end": 477,
"char_start": 446,
"line": " self.cursor.execute(query)\n",
"line_no": 17
}
]
},
"vul_type": "cwe-089"
} | 283 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route('/<page_name>/save', methods=['POST'])\ndef save_page_edit(page_name):\n # grab the new content from the user\n content = request.form.get('content')\n # check if 'page_name' exists in the database",
" query = db.query(\"select page_content.content, page.id as page_id, page_content.id as content_id from 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)",
" result = query.namedresult()\n # if it doesn't exist, create a new page in the database\n if len(result) < 1:\n db.insert(\n 'page', {\n 'page_name': page_name\n }\n )\n else:\n pass\n # now that we're certain that the page exists in the database, we again grab the query\n # and insert new content in the database\n query = db.query(\"select id from page where page_name = '%s'\" % page_name)\n page_id = query.namedresult()[0].id\n db.insert(\n 'page_content', {\n 'page_id': page_id,\n 'content': content,\n 'timestamp': time.strftime(\"%Y-%m-%d %H:%M:%S\", localtime())\n }\n )\n return redirect(\"/%s\" % page_name)"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 399,
"char_start": 397,
"chars": "$1"
},
{
"char_end": 439,
"char_start": 438,
"chars": ","
}
],
"deleted": [
{
"char_end": 401,
"char_start": 397,
"chars": "'%s'"
},
{
"char_end": 442,
"char_start": 440,
"chars": " %"
}
]
},
"commit_link": "github.com/Pumala/python_wiki_app_redo/commit/65d60747cd8efb05970304234d3bd949d2088e8b",
"file_name": "server.py",
"func_name": "save_page_edit",
"line_changes": {
"added": [
{
"char_end": 451,
"char_start": 214,
"line": " query = db.query(\"select page_content.content, page.id as page_id, page_content.id as content_id from page, page_content where page.id = page_content.page_id and page.page_name = $1 order by page_content.id desc limit 1\", page_name)\n",
"line_no": 6
}
],
"deleted": [
{
"char_end": 454,
"char_start": 214,
"line": " query = db.query(\"select page_content.content, page.id as page_id, page_content.id as content_id from page, page_content where page.id = page_content.page_id and page.page_name = '%s' order by page_content.id desc limit 1\" % page_name)\n",
"line_no": 6
}
]
},
"vul_type": "cwe-089"
} | 284 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route('/<page_name>/save', methods=['POST'])\ndef save_page_edit(page_name):\n # grab the new content from the user\n content = request.form.get('content')\n # check if 'page_name' exists in the database",
" query = db.query(\"select page_content.content, page.id as page_id, page_content.id as content_id from 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)",
" result = query.namedresult()\n # if it doesn't exist, create a new page in the database\n if len(result) < 1:\n db.insert(\n 'page', {\n 'page_name': page_name\n }\n )\n else:\n pass\n # now that we're certain that the page exists in the database, we again grab the query\n # and insert new content in the database\n query = db.query(\"select id from page where page_name = '%s'\" % page_name)\n page_id = query.namedresult()[0].id\n db.insert(\n 'page_content', {\n 'page_id': page_id,\n 'content': content,\n 'timestamp': time.strftime(\"%Y-%m-%d %H:%M:%S\", localtime())\n }\n )\n return redirect(\"/%s\" % page_name)"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 399,
"char_start": 397,
"chars": "$1"
},
{
"char_end": 439,
"char_start": 438,
"chars": ","
}
],
"deleted": [
{
"char_end": 401,
"char_start": 397,
"chars": "'%s'"
},
{
"char_end": 442,
"char_start": 440,
"chars": " %"
}
]
},
"commit_link": "github.com/Pumala/python_wiki_app_redo/commit/65d60747cd8efb05970304234d3bd949d2088e8b",
"file_name": "server.py",
"func_name": "save_page_edit",
"line_changes": {
"added": [
{
"char_end": 451,
"char_start": 214,
"line": " query = db.query(\"select page_content.content, page.id as page_id, page_content.id as content_id from page, page_content where page.id = page_content.page_id and page.page_name = $1 order by page_content.id desc limit 1\", page_name)\n",
"line_no": 6
}
],
"deleted": [
{
"char_end": 454,
"char_start": 214,
"line": " query = db.query(\"select page_content.content, page.id as page_id, page_content.id as content_id from page, page_content where page.id = page_content.page_id and page.page_name = '%s' order by page_content.id desc limit 1\" % page_name)\n",
"line_no": 6
}
]
},
"vul_type": "cwe-089"
} | 284 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"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",
" LIMIT {}\"\"\".format(top_num)\r\n return execute_query(cmd)"
] | [
1,
0
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 431,
"char_start": 429,
"chars": "%s"
},
{
"char_end": 441,
"char_start": 434,
"chars": "\r\n d"
},
{
"char_end": 448,
"char_start": 443,
"chars": "a = ["
},
{
"char_end": 458,
"char_start": 455,
"chars": ", ]"
},
{
"char_end": 494,
"char_start": 488,
"chars": ", data"
}
],
"deleted": [
{
"char_end": 431,
"char_start": 429,
"chars": "{}"
},
{
"char_end": 439,
"char_start": 434,
"chars": ".form"
},
{
"char_end": 442,
"char_start": 441,
"chars": "("
},
{
"char_end": 450,
"char_start": 449,
"chars": ")"
}
]
},
"commit_link": "github.com/thugasin/udacity-homework-logAnalyzer/commit/506f25f9a1caee7f17034adf7c75e0efbc88082b",
"file_name": "logAnalyzerDb.py",
"func_name": "get_top_popular",
"line_changes": {
"added": [
{
"char_end": 436,
"char_start": 410,
"line": " LIMIT %s\"\"\"\r\n",
"line_no": 12
},
{
"char_end": 460,
"char_start": 436,
"line": " data = [top_num, ]\r\n",
"line_no": 13
},
{
"char_end": 495,
"char_start": 460,
"line": " return execute_query(cmd, data)\r\n",
"line_no": 14
}
],
"deleted": [
{
"char_end": 452,
"char_start": 410,
"line": " LIMIT {}\"\"\".format(top_num)\r\n",
"line_no": 12
},
{
"char_end": 481,
"char_start": 452,
"line": " return execute_query(cmd)\r\n",
"line_no": 13
}
]
},
"vul_type": "cwe-089"
} | 285 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"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",
" LIMIT %s\"\"\"\r\n data = [top_num, ]\r\n return execute_query(cmd, data)"
] | [
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 431,
"char_start": 429,
"chars": "%s"
},
{
"char_end": 441,
"char_start": 434,
"chars": "\r\n d"
},
{
"char_end": 448,
"char_start": 443,
"chars": "a = ["
},
{
"char_end": 458,
"char_start": 455,
"chars": ", ]"
},
{
"char_end": 494,
"char_start": 488,
"chars": ", data"
}
],
"deleted": [
{
"char_end": 431,
"char_start": 429,
"chars": "{}"
},
{
"char_end": 439,
"char_start": 434,
"chars": ".form"
},
{
"char_end": 442,
"char_start": 441,
"chars": "("
},
{
"char_end": 450,
"char_start": 449,
"chars": ")"
}
]
},
"commit_link": "github.com/thugasin/udacity-homework-logAnalyzer/commit/506f25f9a1caee7f17034adf7c75e0efbc88082b",
"file_name": "logAnalyzerDb.py",
"func_name": "get_top_popular",
"line_changes": {
"added": [
{
"char_end": 436,
"char_start": 410,
"line": " LIMIT %s\"\"\"\r\n",
"line_no": 12
},
{
"char_end": 460,
"char_start": 436,
"line": " data = [top_num, ]\r\n",
"line_no": 13
},
{
"char_end": 495,
"char_start": 460,
"line": " return execute_query(cmd, data)\r\n",
"line_no": 14
}
],
"deleted": [
{
"char_end": 452,
"char_start": 410,
"line": " LIMIT {}\"\"\".format(top_num)\r\n",
"line_no": 12
},
{
"char_end": 481,
"char_start": 452,
"line": " return execute_query(cmd)\r\n",
"line_no": 13
}
]
},
"vul_type": "cwe-089"
} | 285 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route('/<page_name>/edit')\ndef render_page_edit(page_name):",
" query = db.query(\"select page_content.content from page, page_content where page.id = page_content.page_id and page.page_name = '%s' order by page_content.id desc limit 1\" % page_name)",
" wiki_page = query.namedresult()\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 )"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 199,
"char_start": 197,
"chars": "$1"
},
{
"char_end": 239,
"char_start": 238,
"chars": ","
}
],
"deleted": [
{
"char_end": 201,
"char_start": 197,
"chars": "'%s'"
},
{
"char_end": 242,
"char_start": 240,
"chars": " %"
}
]
},
"commit_link": "github.com/Pumala/python_wiki_app_redo/commit/65d60747cd8efb05970304234d3bd949d2088e8b",
"file_name": "server.py",
"func_name": "render_page_edit",
"line_changes": {
"added": [
{
"char_end": 251,
"char_start": 65,
"line": " 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",
"line_no": 3
}
],
"deleted": [
{
"char_end": 254,
"char_start": 65,
"line": " query = db.query(\"select page_content.content from page, page_content where page.id = page_content.page_id and page.page_name = '%s' order by page_content.id desc limit 1\" % page_name)\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 286 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route('/<page_name>/edit')\ndef render_page_edit(page_name):",
" query = db.query(\"select page_content.content from page, page_content where page.id = page_content.page_id and page.page_name = $1 order by page_content.id desc limit 1\", page_name)",
" wiki_page = query.namedresult()\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 )"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 199,
"char_start": 197,
"chars": "$1"
},
{
"char_end": 239,
"char_start": 238,
"chars": ","
}
],
"deleted": [
{
"char_end": 201,
"char_start": 197,
"chars": "'%s'"
},
{
"char_end": 242,
"char_start": 240,
"chars": " %"
}
]
},
"commit_link": "github.com/Pumala/python_wiki_app_redo/commit/65d60747cd8efb05970304234d3bd949d2088e8b",
"file_name": "server.py",
"func_name": "render_page_edit",
"line_changes": {
"added": [
{
"char_end": 251,
"char_start": 65,
"line": " 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",
"line_no": 3
}
],
"deleted": [
{
"char_end": 254,
"char_start": 65,
"line": " query = db.query(\"select page_content.content from page, page_content where page.id = page_content.page_id and page.page_name = '%s' order by page_content.id desc limit 1\" % page_name)\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 286 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_monthly_ranks_for_scene(db, scene, tag):\n",
" sql = \"SELECT date, rank FROM ranks WHERE scene='{}' AND player='{}'\".format(scene, tag)\n res = db.exec(sql)",
"\n res = [r for r in res if played_during_month(db, scene, tag, get_previous_month(r[0]))]",
" # Build up a dict of {date: rank}\n ranks = {}\n for r in res:\n ranks[r[0]] = r[1]",
" return ranks"
] | [
1,
0,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 109,
"char_start": 104,
"chars": "scene"
},
{
"char_end": 128,
"char_start": 125,
"chars": "tag"
},
{
"char_end": 136,
"char_start": 131,
"chars": "\n "
},
{
"char_end": 153,
"char_start": 137,
"chars": "rgs = {'scene': "
},
{
"char_end": 161,
"char_start": 160,
"chars": "'"
},
{
"char_end": 171,
"char_start": 164,
"chars": "': tag}"
},
{
"char_end": 199,
"char_start": 193,
"chars": ", args"
}
],
"deleted": [
{
"char_end": 126,
"char_start": 123,
"chars": ".fo"
},
{
"char_end": 131,
"char_start": 127,
"chars": "mat("
},
{
"char_end": 142,
"char_start": 141,
"chars": ")"
}
]
},
"commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63",
"file_name": "bracket_utils.py",
"func_name": "get_monthly_ranks_for_scene",
"line_changes": {
"added": [
{
"char_end": 132,
"char_start": 50,
"line": " sql = \"SELECT date, rank FROM ranks WHERE scene='{scene}' AND player='{tag}'\"\n",
"line_no": 3
},
{
"char_end": 172,
"char_start": 132,
"line": " args = {'scene': scene, 'tag': tag}\n",
"line_no": 4
},
{
"char_end": 201,
"char_start": 172,
"line": " res = db.exec(sql, args)\n",
"line_no": 5
}
],
"deleted": [
{
"char_end": 143,
"char_start": 50,
"line": " sql = \"SELECT date, rank FROM ranks WHERE scene='{}' AND player='{}'\".format(scene, tag)\n",
"line_no": 3
},
{
"char_end": 166,
"char_start": 143,
"line": " res = db.exec(sql)\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 287 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def get_monthly_ranks_for_scene(db, scene, tag):\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 res = [r for r in res if played_during_month(db, scene, tag, get_previous_month(r[0]))]",
" # Build up a dict of {date: rank}\n ranks = {}\n for r in res:\n ranks[r[0]] = r[1]",
" return ranks"
] | [
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 109,
"char_start": 104,
"chars": "scene"
},
{
"char_end": 128,
"char_start": 125,
"chars": "tag"
},
{
"char_end": 136,
"char_start": 131,
"chars": "\n "
},
{
"char_end": 153,
"char_start": 137,
"chars": "rgs = {'scene': "
},
{
"char_end": 161,
"char_start": 160,
"chars": "'"
},
{
"char_end": 171,
"char_start": 164,
"chars": "': tag}"
},
{
"char_end": 199,
"char_start": 193,
"chars": ", args"
}
],
"deleted": [
{
"char_end": 126,
"char_start": 123,
"chars": ".fo"
},
{
"char_end": 131,
"char_start": 127,
"chars": "mat("
},
{
"char_end": 142,
"char_start": 141,
"chars": ")"
}
]
},
"commit_link": "github.com/DKelle/Smash_stats/commit/4bb83f3f6ce7d6bebbeb512cd015f9e72cf36d63",
"file_name": "bracket_utils.py",
"func_name": "get_monthly_ranks_for_scene",
"line_changes": {
"added": [
{
"char_end": 132,
"char_start": 50,
"line": " sql = \"SELECT date, rank FROM ranks WHERE scene='{scene}' AND player='{tag}'\"\n",
"line_no": 3
},
{
"char_end": 172,
"char_start": 132,
"line": " args = {'scene': scene, 'tag': tag}\n",
"line_no": 4
},
{
"char_end": 201,
"char_start": 172,
"line": " res = db.exec(sql, args)\n",
"line_no": 5
}
],
"deleted": [
{
"char_end": 143,
"char_start": 50,
"line": " sql = \"SELECT date, rank FROM ranks WHERE scene='{}' AND player='{}'\".format(scene, tag)\n",
"line_no": 3
},
{
"char_end": 166,
"char_start": 143,
"line": " res = db.exec(sql)\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 287 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@staticmethod\n def auto_unlock_tasks(project_id: int):\n \"\"\"Unlock all tasks locked for longer than the auto-unlock delta\"\"\"\n expiry_delta = Task.auto_unlock_delta()\n lock_duration = (datetime.datetime.min + expiry_delta).time().isoformat()\n expiry_date = datetime.datetime.utcnow() - expiry_delta\n old_locks_query = '''SELECT t.id\n FROM tasks t, task_history th\n WHERE t.id = th.task_id\n AND t.project_id = th.project_id\n AND t.task_status IN (1,3)\n AND th.action IN ( 'LOCKED_FOR_VALIDATION','LOCKED_FOR_MAPPING' )\n AND th.action_text IS NULL",
" AND t.project_id = {0}\n AND th.action_date <= '{1}'\n '''.format(project_id, str(expiry_date))",
"",
" old_tasks = db.engine.execute(old_locks_query)",
"\n if old_tasks.rowcount == 0:\n # no tasks older than the delta found, return without further processing\n return",
" for old_task in old_tasks:\n task = Task.get(old_task[0], project_id)\n task.auto_unlock_expired_tasks(expiry_date, lock_duration)"
] | [
1,
0,
1,
0,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 694,
"char_start": 683,
"chars": ":project_id"
},
{
"char_end": 741,
"char_start": 729,
"chars": ":expiry_date"
},
{
"char_end": 802,
"char_start": 797,
"chars": "text("
},
{
"char_end": 871,
"char_start": 817,
"chars": "), project_id=project_id, expiry_date=str(expiry_date)"
}
],
"deleted": [
{
"char_end": 686,
"char_start": 683,
"chars": "{0}"
},
{
"char_end": 726,
"char_start": 721,
"chars": "'{1}'"
},
{
"char_end": 779,
"char_start": 742,
"chars": ".format(project_id, str(expiry_date))"
}
]
},
"commit_link": "github.com/hotosm/tasking-manager/commit/dee040a2d22b3c4d5e38e2dbf8c6b651ad4c241a",
"file_name": "server/models/postgis/task.py",
"func_name": "auto_unlock_tasks",
"line_changes": {
"added": [
{
"char_end": 695,
"char_start": 652,
"line": " AND t.project_id = :project_id\n",
"line_no": 14
},
{
"char_end": 742,
"char_start": 695,
"line": " AND th.action_date <= :expiry_date\n",
"line_no": 15
},
{
"char_end": 758,
"char_start": 742,
"line": " '''\n",
"line_no": 16
},
{
"char_end": 873,
"char_start": 759,
"line": " old_tasks = db.engine.execute(text(old_locks_query), project_id=project_id, expiry_date=str(expiry_date))\n",
"line_no": 18
}
],
"deleted": [
{
"char_end": 687,
"char_start": 652,
"line": " AND t.project_id = {0}\n",
"line_no": 14
},
{
"char_end": 727,
"char_start": 687,
"line": " AND th.action_date <= '{1}'\n",
"line_no": 15
},
{
"char_end": 780,
"char_start": 727,
"line": " '''.format(project_id, str(expiry_date))\n",
"line_no": 16
},
{
"char_end": 836,
"char_start": 781,
"line": " old_tasks = db.engine.execute(old_locks_query)\n",
"line_no": 18
}
]
},
"vul_type": "cwe-089"
} | 288 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@staticmethod\n def auto_unlock_tasks(project_id: int):\n \"\"\"Unlock all tasks locked for longer than the auto-unlock delta\"\"\"\n expiry_delta = Task.auto_unlock_delta()\n lock_duration = (datetime.datetime.min + expiry_delta).time().isoformat()\n expiry_date = datetime.datetime.utcnow() - expiry_delta\n old_locks_query = '''SELECT t.id\n FROM tasks t, task_history th\n WHERE t.id = th.task_id\n AND t.project_id = th.project_id\n AND t.task_status IN (1,3)\n AND th.action IN ( 'LOCKED_FOR_VALIDATION','LOCKED_FOR_MAPPING' )\n AND th.action_text IS NULL",
" AND t.project_id = :project_id\n AND th.action_date <= :expiry_date\n '''",
"",
" old_tasks = db.engine.execute(text(old_locks_query), project_id=project_id, expiry_date=str(expiry_date))",
"\n if old_tasks.rowcount == 0:\n # no tasks older than the delta found, return without further processing\n return",
" for old_task in old_tasks:\n task = Task.get(old_task[0], project_id)\n task.auto_unlock_expired_tasks(expiry_date, lock_duration)"
] | [
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 694,
"char_start": 683,
"chars": ":project_id"
},
{
"char_end": 741,
"char_start": 729,
"chars": ":expiry_date"
},
{
"char_end": 802,
"char_start": 797,
"chars": "text("
},
{
"char_end": 871,
"char_start": 817,
"chars": "), project_id=project_id, expiry_date=str(expiry_date)"
}
],
"deleted": [
{
"char_end": 686,
"char_start": 683,
"chars": "{0}"
},
{
"char_end": 726,
"char_start": 721,
"chars": "'{1}'"
},
{
"char_end": 779,
"char_start": 742,
"chars": ".format(project_id, str(expiry_date))"
}
]
},
"commit_link": "github.com/hotosm/tasking-manager/commit/dee040a2d22b3c4d5e38e2dbf8c6b651ad4c241a",
"file_name": "server/models/postgis/task.py",
"func_name": "auto_unlock_tasks",
"line_changes": {
"added": [
{
"char_end": 695,
"char_start": 652,
"line": " AND t.project_id = :project_id\n",
"line_no": 14
},
{
"char_end": 742,
"char_start": 695,
"line": " AND th.action_date <= :expiry_date\n",
"line_no": 15
},
{
"char_end": 758,
"char_start": 742,
"line": " '''\n",
"line_no": 16
},
{
"char_end": 873,
"char_start": 759,
"line": " old_tasks = db.engine.execute(text(old_locks_query), project_id=project_id, expiry_date=str(expiry_date))\n",
"line_no": 18
}
],
"deleted": [
{
"char_end": 687,
"char_start": 652,
"line": " AND t.project_id = {0}\n",
"line_no": 14
},
{
"char_end": 727,
"char_start": 687,
"line": " AND th.action_date <= '{1}'\n",
"line_no": 15
},
{
"char_end": 780,
"char_start": 727,
"line": " '''.format(project_id, str(expiry_date))\n",
"line_no": 16
},
{
"char_end": 836,
"char_start": 781,
"line": " old_tasks = db.engine.execute(old_locks_query)\n",
"line_no": 18
}
]
},
"vul_type": "cwe-089"
} | 288 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"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",
" query = \"INSERT INTO crimes (description) VALUES('{}');\".format(data)",
" with connection.cursor() as cursor:",
" cursor.execute(query)",
" connection.commit()\n finally:\n connection.close()"
] | [
1,
0,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 260,
"char_start": 258,
"chars": "%s"
},
{
"char_end": 354,
"char_start": 348,
"chars": ", data"
}
],
"deleted": [
{
"char_end": 262,
"char_start": 258,
"chars": "'{}'"
},
{
"char_end": 278,
"char_start": 265,
"chars": ".format(data)"
}
]
},
"commit_link": "github.com/mudspringhiker/crimemap/commit/35e78962e7288c643cdde0f886ff7aa5ac77cb8c",
"file_name": "dbhelper.py",
"func_name": "add_input",
"line_changes": {
"added": [
{
"char_end": 264,
"char_start": 197,
"line": " query = \"INSERT INTO crimes (description) VALUES(%s);\"\n",
"line_no": 6
},
{
"char_end": 356,
"char_start": 312,
"line": " cursor.execute(query, data)\n",
"line_no": 8
}
],
"deleted": [
{
"char_end": 279,
"char_start": 197,
"line": " query = \"INSERT INTO crimes (description) VALUES('{}');\".format(data)\n",
"line_no": 6
},
{
"char_end": 365,
"char_start": 327,
"line": " cursor.execute(query)\n",
"line_no": 8
}
]
},
"vul_type": "cwe-089"
} | 289 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"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",
" query = \"INSERT INTO crimes (description) VALUES(%s);\"",
" with connection.cursor() as cursor:",
" cursor.execute(query, data)",
" connection.commit()\n finally:\n connection.close()"
] | [
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 260,
"char_start": 258,
"chars": "%s"
},
{
"char_end": 354,
"char_start": 348,
"chars": ", data"
}
],
"deleted": [
{
"char_end": 262,
"char_start": 258,
"chars": "'{}'"
},
{
"char_end": 278,
"char_start": 265,
"chars": ".format(data)"
}
]
},
"commit_link": "github.com/mudspringhiker/crimemap/commit/35e78962e7288c643cdde0f886ff7aa5ac77cb8c",
"file_name": "dbhelper.py",
"func_name": "add_input",
"line_changes": {
"added": [
{
"char_end": 264,
"char_start": 197,
"line": " query = \"INSERT INTO crimes (description) VALUES(%s);\"\n",
"line_no": 6
},
{
"char_end": 356,
"char_start": 312,
"line": " cursor.execute(query, data)\n",
"line_no": 8
}
],
"deleted": [
{
"char_end": 279,
"char_start": 197,
"line": " query = \"INSERT INTO crimes (description) VALUES('{}');\".format(data)\n",
"line_no": 6
},
{
"char_end": 365,
"char_start": 327,
"line": " cursor.execute(query)\n",
"line_no": 8
}
]
},
"vul_type": "cwe-089"
} | 289 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def getAllComments(self):",
" sqlText=\"select comment from comments where userid=%d order by date;\"\n allposts=sql.queryDB(self.conn,sqlText)",
" return allposts;"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 91,
"char_start": 90,
"chars": "s"
},
{
"char_end": 147,
"char_start": 116,
"chars": "params = [self.userid]\n "
},
{
"char_end": 192,
"char_start": 185,
"chars": ",params"
}
],
"deleted": [
{
"char_end": 91,
"char_start": 90,
"chars": "d"
}
]
},
"commit_link": "github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9",
"file_name": "modules/users.py",
"func_name": "getAllComments",
"line_changes": {
"added": [
{
"char_end": 108,
"char_start": 30,
"line": " sqlText=\"select comment from comments where userid=%s order by date;\"\n",
"line_no": 2
},
{
"char_end": 139,
"char_start": 108,
"line": " params = [self.userid]\n",
"line_no": 3
},
{
"char_end": 194,
"char_start": 139,
"line": " allposts=sql.queryDB(self.conn,sqlText,params)\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 108,
"char_start": 30,
"line": " sqlText=\"select comment from comments where userid=%d order by date;\"\n",
"line_no": 2
},
{
"char_end": 156,
"char_start": 108,
"line": " allposts=sql.queryDB(self.conn,sqlText)\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 290 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def getAllComments(self):",
" sqlText=\"select comment from comments where userid=%s order by date;\"\n params = [self.userid]\n allposts=sql.queryDB(self.conn,sqlText,params)",
" return allposts;"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 91,
"char_start": 90,
"chars": "s"
},
{
"char_end": 147,
"char_start": 116,
"chars": "params = [self.userid]\n "
},
{
"char_end": 192,
"char_start": 185,
"chars": ",params"
}
],
"deleted": [
{
"char_end": 91,
"char_start": 90,
"chars": "d"
}
]
},
"commit_link": "github.com/ShaominLi/Twitter_project/commit/5329d91f9e569c95184053c8e7ef596949c33ce9",
"file_name": "modules/users.py",
"func_name": "getAllComments",
"line_changes": {
"added": [
{
"char_end": 108,
"char_start": 30,
"line": " sqlText=\"select comment from comments where userid=%s order by date;\"\n",
"line_no": 2
},
{
"char_end": 139,
"char_start": 108,
"line": " params = [self.userid]\n",
"line_no": 3
},
{
"char_end": 194,
"char_start": 139,
"line": " allposts=sql.queryDB(self.conn,sqlText,params)\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 108,
"char_start": 30,
"line": " sqlText=\"select comment from comments where userid=%d order by date;\"\n",
"line_no": 2
},
{
"char_end": 156,
"char_start": 108,
"line": " allposts=sql.queryDB(self.conn,sqlText)\n",
"line_no": 3
}
]
},
"vul_type": "cwe-089"
} | 290 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def update_user(username, chat_id, last_update):\n conn = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\users\\\\\" + username + '.db')\n conn2 = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + '\\\\cf.db')\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\settings.db\")\n cursor = conn.cursor()\n cursor2 = conn2.cursor()\n cursor_settings = settings.cursor()",
" cursor_settings.execute(\"select last_problem from users where chat_id = '\" + str(chat_id) + \"'\")",
" update_eq = cursor_settings.fetchone()\n cursor_settings.execute(\"select * from last_update_problemset\")\n update_base = cursor_settings.fetchone()\n last_problem = update_base[0]\n if update_eq[0] != update_base[0]:\n cursor2.execute(\"SELECT * FROM problems\")\n x = cursor2.fetchone()\n while x != None:",
" cursor.execute(\"select * from result where problem = '\" + str(x[0]) + \"' and diff = '\" + str(x[1]) + \"'\")",
" x2 = cursor.fetchone()\n if x2 == None:\n cursor.execute(\"insert into result values (?, ?, ? )\", (x[0], x[1], \"NULL\"))\n last_problem = x\n x = cursor2.fetchone()\n conn2.close()\n settings.close()\n if len(last_problem) == 2:\n last_problem = last_problem[0] + last_problem[1]",
" url = 'http://codeforces.com/submissions/' + username\n r = requests.get(url)\n max_page = 1\n soup = BeautifulSoup(r.text, \"lxml\")",
" for link in soup.find_all(attrs={\"class\": \"page-index\"}):\n s = link.find('a')\n s2 = s.get(\"href\").split('/')\n max_page = max(max_page, int(s2[4]))",
" v = False\n r = requests.get('http://codeforces.com/submissions/' + username + '/page/0')\n soup = BeautifulSoup(r.text, \"lxml\")\n last_try_new = soup.find(attrs={\"class\": \"status-small\"})\n last_try_new = str(last_try_new).split()\n last_try_new = str(last_try_new[2]) + str(last_try_new[3])\n for i in range(1, max_page + 1):\n r = requests.get('http://codeforces.com/submissions/' + username + '/page/' + str(i))\n soup = BeautifulSoup(r.text, \"lxml\")\n count = 0\n j = 0\n ver = soup.find_all(attrs={\"class\": \"submissionVerdictWrapper\"})\n last_try = soup.find_all(attrs={\"class\": \"status-small\"})\n for link in soup.find_all('a'):\n last_try_date = str(last_try[j]).split()\n last_try_date = str(last_try_date[2]) + str(last_try_date[3])\n if last_try_date == last_update:\n v = True\n break\n s = link.get('href')\n if s != None and s.find('/problemset') != -1:\n s = s.split('/')\n if len(s) == 5:\n s2 = str(ver[count]).split()\n s2 = s2[5].split('\\\"')\n count += 1\n j += 1",
" cursor.execute(\"select * from result where problem = '\" + s[3] + \"'and diff = '\" + s[4] + \"'\")",
" x = cursor.fetchone()\n if s2[1] == 'OK' and x != None:",
" cursor.execute(\n \"update result set verdict = '\" + s2[1] + \"' where problem = '\" + s[3] + \"' and diff = '\" +\n s[4] + \"'\")",
" if x[2] != 'OK':",
" cursor.execute(\n \"update result set verdict = '\" + s2[1] + \"' where problem = '\" + s[3] + \"' and diff = '\" +\n s[4] + \"'\")",
" if v:\n break",
" conn.commit()\n conn.close()",
" settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\settings.db\")\n conn = settings.cursor()",
" conn.execute(\"update users set username = '\" + str(username) + \"' where chat_id = '\" + str(chat_id) + \"'\")\n conn.execute(\"update users set last_update = '\" + str(last_try_new) + \"' where chat_id = '\" + str(chat_id) + \"'\")\n conn.execute(\"update users set last_problem = '\" + str(last_problem) + \"' where chat_id = '\" + str(chat_id) + \"'\")",
"\n settings.commit()\n settings.close()"
] | [
1,
0,
1,
0,
1,
1,
1,
1,
0,
1,
0,
1,
0,
1,
1,
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 503,
"char_start": 502,
"chars": "?"
},
{
"char_end": 505,
"char_start": 504,
"chars": ","
},
{
"char_end": 507,
"char_start": 506,
"chars": "("
},
{
"char_end": 520,
"char_start": 519,
"chars": ","
},
{
"char_end": 522,
"char_start": 521,
"chars": ")"
},
{
"char_end": 925,
"char_start": 924,
"chars": "?"
},
{
"char_end": 938,
"char_start": 937,
"chars": "?"
},
{
"char_end": 940,
"char_start": 939,
"chars": ","
},
{
"char_end": 952,
"char_start": 941,
"chars": "(str(x[0]),"
},
{
"char_end": 963,
"char_start": 962,
"chars": ")"
},
{
"char_end": 2929,
"char_start": 2928,
"chars": "?"
},
{
"char_end": 2942,
"char_start": 2941,
"chars": "?"
},
{
"char_end": 2944,
"char_start": 2943,
"chars": ","
},
{
"char_end": 2951,
"char_start": 2945,
"chars": "(s[3],"
},
{
"char_end": 2957,
"char_start": 2956,
"chars": ")"
},
{
"char_end": 3122,
"char_start": 3121,
"chars": "?"
},
{
"char_end": 3140,
"char_start": 3139,
"chars": "?"
},
{
"char_end": 3153,
"char_start": 3152,
"chars": "?"
},
{
"char_end": 3155,
"char_start": 3154,
"chars": ","
},
{
"char_end": 3163,
"char_start": 3156,
"chars": "(s2[1],"
},
{
"char_end": 3169,
"char_start": 3164,
"chars": "s[3],"
},
{
"char_end": 3175,
"char_start": 3174,
"chars": ")"
},
{
"char_end": 3283,
"char_start": 3282,
"chars": "?"
},
{
"char_end": 3301,
"char_start": 3300,
"chars": "?"
},
{
"char_end": 3314,
"char_start": 3313,
"chars": "?"
},
{
"char_end": 3316,
"char_start": 3315,
"chars": ","
},
{
"char_end": 3324,
"char_start": 3317,
"chars": "(s2[1],"
},
{
"char_end": 3330,
"char_start": 3325,
"chars": "s[3],"
},
{
"char_end": 3336,
"char_start": 3335,
"chars": ")"
},
{
"char_end": 3576,
"char_start": 3575,
"chars": "?"
},
{
"char_end": 3594,
"char_start": 3593,
"chars": "?"
},
{
"char_end": 3596,
"char_start": 3595,
"chars": ","
},
{
"char_end": 3612,
"char_start": 3597,
"chars": "(str(username),"
},
{
"char_end": 3626,
"char_start": 3625,
"chars": ")"
},
{
"char_end": 3678,
"char_start": 3677,
"chars": "?"
},
{
"char_end": 3696,
"char_start": 3695,
"chars": "?"
},
{
"char_end": 3698,
"char_start": 3697,
"chars": ","
},
{
"char_end": 3718,
"char_start": 3699,
"chars": "(str(last_try_new),"
},
{
"char_end": 3732,
"char_start": 3731,
"chars": ")"
},
{
"char_end": 3801,
"char_start": 3784,
"chars": "? where chat_id ="
},
{
"char_end": 3805,
"char_start": 3802,
"chars": "?\","
},
{
"char_end": 3807,
"char_start": 3806,
"chars": "("
},
{
"char_end": 3825,
"char_start": 3824,
"chars": ","
},
{
"char_end": 3839,
"char_start": 3838,
"chars": ")"
}
],
"deleted": [
{
"char_end": 503,
"char_start": 502,
"chars": "'"
},
{
"char_end": 506,
"char_start": 504,
"chars": " +"
},
{
"char_end": 521,
"char_start": 519,
"chars": " +"
},
{
"char_end": 525,
"char_start": 522,
"chars": "\"'\""
},
{
"char_end": 946,
"char_start": 927,
"chars": "'\" + str(x[0]) + \"'"
},
{
"char_end": 959,
"char_start": 958,
"chars": "'"
},
{
"char_end": 962,
"char_start": 961,
"chars": "+"
},
{
"char_end": 978,
"char_start": 972,
"chars": " + \"'\""
},
{
"char_end": 2954,
"char_start": 2943,
"chars": "'\" + s[3] +"
},
{
"char_end": 2957,
"char_start": 2955,
"chars": "\"'"
},
{
"char_end": 2969,
"char_start": 2968,
"chars": "'"
},
{
"char_end": 2972,
"char_start": 2971,
"chars": "+"
},
{
"char_end": 2983,
"char_start": 2977,
"chars": " + \"'\""
},
{
"char_end": 3147,
"char_start": 3118,
"chars": "\n "
},
{
"char_end": 3191,
"char_start": 3176,
"chars": "'\" + s2[1] + \"'"
},
{
"char_end": 3222,
"char_start": 3208,
"chars": "'\" + s[3] + \"'"
},
{
"char_end": 3235,
"char_start": 3234,
"chars": "'"
},
{
"char_end": 3258,
"char_start": 3236,
"chars": " +\n "
},
{
"char_end": 3266,
"char_start": 3260,
"chars": " "
},
{
"char_end": 3277,
"char_start": 3271,
"chars": " + \"'\""
},
{
"char_end": 3384,
"char_start": 3355,
"chars": "\n "
},
{
"char_end": 3428,
"char_start": 3413,
"chars": "'\" + s2[1] + \"'"
},
{
"char_end": 3459,
"char_start": 3445,
"chars": "'\" + s[3] + \"'"
},
{
"char_end": 3472,
"char_start": 3471,
"chars": "'"
},
{
"char_end": 3494,
"char_start": 3473,
"chars": " +\n "
},
{
"char_end": 3496,
"char_start": 3495,
"chars": " "
},
{
"char_end": 3503,
"char_start": 3497,
"chars": " "
},
{
"char_end": 3514,
"char_start": 3508,
"chars": " + \"'\""
},
{
"char_end": 3776,
"char_start": 3753,
"chars": "'\" + str(username) + \"'"
},
{
"char_end": 3794,
"char_start": 3793,
"chars": "'"
},
{
"char_end": 3797,
"char_start": 3796,
"chars": "+"
},
{
"char_end": 3816,
"char_start": 3810,
"chars": " + \"'\""
},
{
"char_end": 3868,
"char_start": 3867,
"chars": "'"
},
{
"char_end": 3871,
"char_start": 3869,
"chars": " +"
},
{
"char_end": 3915,
"char_start": 3889,
"chars": " + \"' where chat_id = '\" +"
},
{
"char_end": 3934,
"char_start": 3928,
"chars": " + \"'\""
},
{
"char_end": 4013,
"char_start": 3986,
"chars": "'\" + str(last_problem) + \"'"
},
{
"char_end": 4031,
"char_start": 4030,
"chars": "'"
},
{
"char_end": 4034,
"char_start": 4033,
"chars": "+"
},
{
"char_end": 4053,
"char_start": 4047,
"chars": " + \"'\""
}
]
},
"commit_link": "github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90",
"file_name": "bases/update.py",
"func_name": "update_user",
"line_changes": {
"added": [
{
"char_end": 524,
"char_start": 426,
"line": " cursor_settings.execute(\"select last_problem from users where chat_id = ?\", (str(chat_id), ))\n",
"line_no": 8
},
{
"char_end": 965,
"char_start": 859,
"line": " cursor.execute(\"select * from result where problem = ? and diff = ?\", (str(x[0]), str(x[1])))\n",
"line_no": 17
},
{
"char_end": 2959,
"char_start": 2855,
"line": " cursor.execute(\"select * from result where problem = ? and diff = ?\", (s[3], s[4]))\n",
"line_no": 65
},
{
"char_end": 3177,
"char_start": 3053,
"line": " cursor.execute(\"update result set verdict = ? where problem = ? and diff = ?\", (s2[1], s[3], s[4]))\n",
"line_no": 68
},
{
"char_end": 3338,
"char_start": 3214,
"line": " cursor.execute(\"update result set verdict = ? where problem = ? and diff = ?\", (s2[1], s[3], s[4]))\n",
"line_no": 70
},
{
"char_end": 3628,
"char_start": 3529,
"line": " conn.execute(\"update users set username = ? where chat_id = ?\", (str(username), str(chat_id)))\n",
"line_no": 79
},
{
"char_end": 3734,
"char_start": 3628,
"line": " conn.execute(\"update users set last_update = ? where chat_id = ?\", (str(last_try_new), str(chat_id)))\n",
"line_no": 80
},
{
"char_end": 3841,
"char_start": 3734,
"line": " conn.execute(\"update users set last_problem = ? where chat_id = ?\", (str(last_problem), str(chat_id)))\n",
"line_no": 81
}
],
"deleted": [
{
"char_end": 527,
"char_start": 426,
"line": " cursor_settings.execute(\"select last_problem from users where chat_id = '\" + str(chat_id) + \"'\")\n",
"line_no": 8
},
{
"char_end": 980,
"char_start": 862,
"line": " cursor.execute(\"select * from result where problem = '\" + str(x[0]) + \"' and diff = '\" + str(x[1]) + \"'\")\n",
"line_no": 17
},
{
"char_end": 2985,
"char_start": 2870,
"line": " cursor.execute(\"select * from result where problem = '\" + s[3] + \"'and diff = '\" + s[4] + \"'\")\n",
"line_no": 65
},
{
"char_end": 3119,
"char_start": 3079,
"line": " cursor.execute(\n",
"line_no": 68
},
{
"char_end": 3239,
"char_start": 3119,
"line": " \"update result set verdict = '\" + s2[1] + \"' where problem = '\" + s[3] + \"' and diff = '\" +\n",
"line_no": 69
},
{
"char_end": 3279,
"char_start": 3239,
"line": " s[4] + \"'\")\n",
"line_no": 70
},
{
"char_end": 3356,
"char_start": 3316,
"line": " cursor.execute(\n",
"line_no": 72
},
{
"char_end": 3476,
"char_start": 3356,
"line": " \"update result set verdict = '\" + s2[1] + \"' where problem = '\" + s[3] + \"' and diff = '\" +\n",
"line_no": 73
},
{
"char_end": 3516,
"char_start": 3476,
"line": " s[4] + \"'\")\n",
"line_no": 74
},
{
"char_end": 3818,
"char_start": 3707,
"line": " conn.execute(\"update users set username = '\" + str(username) + \"' where chat_id = '\" + str(chat_id) + \"'\")\n",
"line_no": 83
},
{
"char_end": 3936,
"char_start": 3818,
"line": " conn.execute(\"update users set last_update = '\" + str(last_try_new) + \"' where chat_id = '\" + str(chat_id) + \"'\")\n",
"line_no": 84
},
{
"char_end": 4055,
"char_start": 3936,
"line": " conn.execute(\"update users set last_problem = '\" + str(last_problem) + \"' where chat_id = '\" + str(chat_id) + \"'\")\n",
"line_no": 85
}
]
},
"vul_type": "cwe-089"
} | 291 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def update_user(username, chat_id, last_update):\n conn = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\users\\\\\" + username + '.db')\n conn2 = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + '\\\\cf.db')\n settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\settings.db\")\n cursor = conn.cursor()\n cursor2 = conn2.cursor()\n cursor_settings = settings.cursor()",
" cursor_settings.execute(\"select last_problem from users where chat_id = ?\", (str(chat_id), ))",
" update_eq = cursor_settings.fetchone()\n cursor_settings.execute(\"select * from last_update_problemset\")\n update_base = cursor_settings.fetchone()\n last_problem = update_base[0]\n if update_eq[0] != update_base[0]:\n cursor2.execute(\"SELECT * FROM problems\")\n x = cursor2.fetchone()\n while x != None:",
" cursor.execute(\"select * from result where problem = ? and diff = ?\", (str(x[0]), str(x[1])))",
" x2 = cursor.fetchone()\n if x2 == None:\n cursor.execute(\"insert into result values (?, ?, ? )\", (x[0], x[1], \"NULL\"))\n last_problem = x\n x = cursor2.fetchone()\n conn2.close()\n settings.close()\n if len(last_problem) == 2:\n last_problem = last_problem[0] + last_problem[1]",
" url = 'http://codeforces.com/submissions/' + username\n r = requests.get(url)\n max_page = 1\n soup = BeautifulSoup(r.text, \"lxml\")",
" for link in soup.find_all(attrs={\"class\": \"page-index\"}):\n s = link.find('a')\n s2 = s.get(\"href\").split('/')\n max_page = max(max_page, int(s2[4]))",
" v = False\n r = requests.get('http://codeforces.com/submissions/' + username + '/page/0')\n soup = BeautifulSoup(r.text, \"lxml\")\n last_try_new = soup.find(attrs={\"class\": \"status-small\"})\n last_try_new = str(last_try_new).split()\n last_try_new = str(last_try_new[2]) + str(last_try_new[3])\n for i in range(1, max_page + 1):\n r = requests.get('http://codeforces.com/submissions/' + username + '/page/' + str(i))\n soup = BeautifulSoup(r.text, \"lxml\")\n count = 0\n j = 0\n ver = soup.find_all(attrs={\"class\": \"submissionVerdictWrapper\"})\n last_try = soup.find_all(attrs={\"class\": \"status-small\"})\n for link in soup.find_all('a'):\n last_try_date = str(last_try[j]).split()\n last_try_date = str(last_try_date[2]) + str(last_try_date[3])\n if last_try_date == last_update:\n v = True\n break\n s = link.get('href')\n if s != None and s.find('/problemset') != -1:\n s = s.split('/')\n if len(s) == 5:\n s2 = str(ver[count]).split()\n s2 = s2[5].split('\\\"')\n count += 1\n j += 1",
" cursor.execute(\"select * from result where problem = ? and diff = ?\", (s[3], s[4]))",
" x = cursor.fetchone()\n if s2[1] == 'OK' and x != None:",
" cursor.execute(\"update result set verdict = ? where problem = ? and diff = ?\", (s2[1], s[3], s[4]))",
" if x[2] != 'OK':",
" cursor.execute(\"update result set verdict = ? where problem = ? and diff = ?\", (s2[1], s[3], s[4]))",
" if v:\n break",
" conn.commit()\n conn.close()",
" settings = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + \"\\\\settings.db\")\n conn = settings.cursor()",
" conn.execute(\"update users set username = ? where chat_id = ?\", (str(username), str(chat_id)))\n conn.execute(\"update users set last_update = ? where chat_id = ?\", (str(last_try_new), str(chat_id)))\n conn.execute(\"update users set last_problem = ? where chat_id = ?\", (str(last_problem), str(chat_id)))",
"\n settings.commit()\n settings.close()"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 503,
"char_start": 502,
"chars": "?"
},
{
"char_end": 505,
"char_start": 504,
"chars": ","
},
{
"char_end": 507,
"char_start": 506,
"chars": "("
},
{
"char_end": 520,
"char_start": 519,
"chars": ","
},
{
"char_end": 522,
"char_start": 521,
"chars": ")"
},
{
"char_end": 925,
"char_start": 924,
"chars": "?"
},
{
"char_end": 938,
"char_start": 937,
"chars": "?"
},
{
"char_end": 940,
"char_start": 939,
"chars": ","
},
{
"char_end": 952,
"char_start": 941,
"chars": "(str(x[0]),"
},
{
"char_end": 963,
"char_start": 962,
"chars": ")"
},
{
"char_end": 2929,
"char_start": 2928,
"chars": "?"
},
{
"char_end": 2942,
"char_start": 2941,
"chars": "?"
},
{
"char_end": 2944,
"char_start": 2943,
"chars": ","
},
{
"char_end": 2951,
"char_start": 2945,
"chars": "(s[3],"
},
{
"char_end": 2957,
"char_start": 2956,
"chars": ")"
},
{
"char_end": 3122,
"char_start": 3121,
"chars": "?"
},
{
"char_end": 3140,
"char_start": 3139,
"chars": "?"
},
{
"char_end": 3153,
"char_start": 3152,
"chars": "?"
},
{
"char_end": 3155,
"char_start": 3154,
"chars": ","
},
{
"char_end": 3163,
"char_start": 3156,
"chars": "(s2[1],"
},
{
"char_end": 3169,
"char_start": 3164,
"chars": "s[3],"
},
{
"char_end": 3175,
"char_start": 3174,
"chars": ")"
},
{
"char_end": 3283,
"char_start": 3282,
"chars": "?"
},
{
"char_end": 3301,
"char_start": 3300,
"chars": "?"
},
{
"char_end": 3314,
"char_start": 3313,
"chars": "?"
},
{
"char_end": 3316,
"char_start": 3315,
"chars": ","
},
{
"char_end": 3324,
"char_start": 3317,
"chars": "(s2[1],"
},
{
"char_end": 3330,
"char_start": 3325,
"chars": "s[3],"
},
{
"char_end": 3336,
"char_start": 3335,
"chars": ")"
},
{
"char_end": 3576,
"char_start": 3575,
"chars": "?"
},
{
"char_end": 3594,
"char_start": 3593,
"chars": "?"
},
{
"char_end": 3596,
"char_start": 3595,
"chars": ","
},
{
"char_end": 3612,
"char_start": 3597,
"chars": "(str(username),"
},
{
"char_end": 3626,
"char_start": 3625,
"chars": ")"
},
{
"char_end": 3678,
"char_start": 3677,
"chars": "?"
},
{
"char_end": 3696,
"char_start": 3695,
"chars": "?"
},
{
"char_end": 3698,
"char_start": 3697,
"chars": ","
},
{
"char_end": 3718,
"char_start": 3699,
"chars": "(str(last_try_new),"
},
{
"char_end": 3732,
"char_start": 3731,
"chars": ")"
},
{
"char_end": 3801,
"char_start": 3784,
"chars": "? where chat_id ="
},
{
"char_end": 3805,
"char_start": 3802,
"chars": "?\","
},
{
"char_end": 3807,
"char_start": 3806,
"chars": "("
},
{
"char_end": 3825,
"char_start": 3824,
"chars": ","
},
{
"char_end": 3839,
"char_start": 3838,
"chars": ")"
}
],
"deleted": [
{
"char_end": 503,
"char_start": 502,
"chars": "'"
},
{
"char_end": 506,
"char_start": 504,
"chars": " +"
},
{
"char_end": 521,
"char_start": 519,
"chars": " +"
},
{
"char_end": 525,
"char_start": 522,
"chars": "\"'\""
},
{
"char_end": 946,
"char_start": 927,
"chars": "'\" + str(x[0]) + \"'"
},
{
"char_end": 959,
"char_start": 958,
"chars": "'"
},
{
"char_end": 962,
"char_start": 961,
"chars": "+"
},
{
"char_end": 978,
"char_start": 972,
"chars": " + \"'\""
},
{
"char_end": 2954,
"char_start": 2943,
"chars": "'\" + s[3] +"
},
{
"char_end": 2957,
"char_start": 2955,
"chars": "\"'"
},
{
"char_end": 2969,
"char_start": 2968,
"chars": "'"
},
{
"char_end": 2972,
"char_start": 2971,
"chars": "+"
},
{
"char_end": 2983,
"char_start": 2977,
"chars": " + \"'\""
},
{
"char_end": 3147,
"char_start": 3118,
"chars": "\n "
},
{
"char_end": 3191,
"char_start": 3176,
"chars": "'\" + s2[1] + \"'"
},
{
"char_end": 3222,
"char_start": 3208,
"chars": "'\" + s[3] + \"'"
},
{
"char_end": 3235,
"char_start": 3234,
"chars": "'"
},
{
"char_end": 3258,
"char_start": 3236,
"chars": " +\n "
},
{
"char_end": 3266,
"char_start": 3260,
"chars": " "
},
{
"char_end": 3277,
"char_start": 3271,
"chars": " + \"'\""
},
{
"char_end": 3384,
"char_start": 3355,
"chars": "\n "
},
{
"char_end": 3428,
"char_start": 3413,
"chars": "'\" + s2[1] + \"'"
},
{
"char_end": 3459,
"char_start": 3445,
"chars": "'\" + s[3] + \"'"
},
{
"char_end": 3472,
"char_start": 3471,
"chars": "'"
},
{
"char_end": 3494,
"char_start": 3473,
"chars": " +\n "
},
{
"char_end": 3496,
"char_start": 3495,
"chars": " "
},
{
"char_end": 3503,
"char_start": 3497,
"chars": " "
},
{
"char_end": 3514,
"char_start": 3508,
"chars": " + \"'\""
},
{
"char_end": 3776,
"char_start": 3753,
"chars": "'\" + str(username) + \"'"
},
{
"char_end": 3794,
"char_start": 3793,
"chars": "'"
},
{
"char_end": 3797,
"char_start": 3796,
"chars": "+"
},
{
"char_end": 3816,
"char_start": 3810,
"chars": " + \"'\""
},
{
"char_end": 3868,
"char_start": 3867,
"chars": "'"
},
{
"char_end": 3871,
"char_start": 3869,
"chars": " +"
},
{
"char_end": 3915,
"char_start": 3889,
"chars": " + \"' where chat_id = '\" +"
},
{
"char_end": 3934,
"char_start": 3928,
"chars": " + \"'\""
},
{
"char_end": 4013,
"char_start": 3986,
"chars": "'\" + str(last_problem) + \"'"
},
{
"char_end": 4031,
"char_start": 4030,
"chars": "'"
},
{
"char_end": 4034,
"char_start": 4033,
"chars": "+"
},
{
"char_end": 4053,
"char_start": 4047,
"chars": " + \"'\""
}
]
},
"commit_link": "github.com/lissrbay/codeforces_bot/commit/cc7f5143445a0030b1149ac60a65b1b1b9c92a90",
"file_name": "bases/update.py",
"func_name": "update_user",
"line_changes": {
"added": [
{
"char_end": 524,
"char_start": 426,
"line": " cursor_settings.execute(\"select last_problem from users where chat_id = ?\", (str(chat_id), ))\n",
"line_no": 8
},
{
"char_end": 965,
"char_start": 859,
"line": " cursor.execute(\"select * from result where problem = ? and diff = ?\", (str(x[0]), str(x[1])))\n",
"line_no": 17
},
{
"char_end": 2959,
"char_start": 2855,
"line": " cursor.execute(\"select * from result where problem = ? and diff = ?\", (s[3], s[4]))\n",
"line_no": 65
},
{
"char_end": 3177,
"char_start": 3053,
"line": " cursor.execute(\"update result set verdict = ? where problem = ? and diff = ?\", (s2[1], s[3], s[4]))\n",
"line_no": 68
},
{
"char_end": 3338,
"char_start": 3214,
"line": " cursor.execute(\"update result set verdict = ? where problem = ? and diff = ?\", (s2[1], s[3], s[4]))\n",
"line_no": 70
},
{
"char_end": 3628,
"char_start": 3529,
"line": " conn.execute(\"update users set username = ? where chat_id = ?\", (str(username), str(chat_id)))\n",
"line_no": 79
},
{
"char_end": 3734,
"char_start": 3628,
"line": " conn.execute(\"update users set last_update = ? where chat_id = ?\", (str(last_try_new), str(chat_id)))\n",
"line_no": 80
},
{
"char_end": 3841,
"char_start": 3734,
"line": " conn.execute(\"update users set last_problem = ? where chat_id = ?\", (str(last_problem), str(chat_id)))\n",
"line_no": 81
}
],
"deleted": [
{
"char_end": 527,
"char_start": 426,
"line": " cursor_settings.execute(\"select last_problem from users where chat_id = '\" + str(chat_id) + \"'\")\n",
"line_no": 8
},
{
"char_end": 980,
"char_start": 862,
"line": " cursor.execute(\"select * from result where problem = '\" + str(x[0]) + \"' and diff = '\" + str(x[1]) + \"'\")\n",
"line_no": 17
},
{
"char_end": 2985,
"char_start": 2870,
"line": " cursor.execute(\"select * from result where problem = '\" + s[3] + \"'and diff = '\" + s[4] + \"'\")\n",
"line_no": 65
},
{
"char_end": 3119,
"char_start": 3079,
"line": " cursor.execute(\n",
"line_no": 68
},
{
"char_end": 3239,
"char_start": 3119,
"line": " \"update result set verdict = '\" + s2[1] + \"' where problem = '\" + s[3] + \"' and diff = '\" +\n",
"line_no": 69
},
{
"char_end": 3279,
"char_start": 3239,
"line": " s[4] + \"'\")\n",
"line_no": 70
},
{
"char_end": 3356,
"char_start": 3316,
"line": " cursor.execute(\n",
"line_no": 72
},
{
"char_end": 3476,
"char_start": 3356,
"line": " \"update result set verdict = '\" + s2[1] + \"' where problem = '\" + s[3] + \"' and diff = '\" +\n",
"line_no": 73
},
{
"char_end": 3516,
"char_start": 3476,
"line": " s[4] + \"'\")\n",
"line_no": 74
},
{
"char_end": 3818,
"char_start": 3707,
"line": " conn.execute(\"update users set username = '\" + str(username) + \"' where chat_id = '\" + str(chat_id) + \"'\")\n",
"line_no": 83
},
{
"char_end": 3936,
"char_start": 3818,
"line": " conn.execute(\"update users set last_update = '\" + str(last_try_new) + \"' where chat_id = '\" + str(chat_id) + \"'\")\n",
"line_no": 84
},
{
"char_end": 4055,
"char_start": 3936,
"line": " conn.execute(\"update users set last_problem = '\" + str(last_problem) + \"' where chat_id = '\" + str(chat_id) + \"'\")\n",
"line_no": 85
}
]
},
"vul_type": "cwe-089"
} | 291 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def save_accepted_transaction(self, user_id, project_id, money):",
" self.cursor.execute(\"update users set money = money - %s where id = %s\"%(money, user_id))\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))",
" self.db.commit()"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 150,
"char_start": 148,
"chars": ", "
},
{
"char_end": 251,
"char_start": 250,
"chars": ","
},
{
"char_end": 421,
"char_start": 390,
"chars": "\"\n \""
},
{
"char_end": 446,
"char_start": 445,
"chars": ","
}
],
"deleted": [
{
"char_end": 149,
"char_start": 148,
"chars": "%"
},
{
"char_end": 251,
"char_start": 249,
"chars": " %"
},
{
"char_end": 416,
"char_start": 414,
"chars": " %"
}
]
},
"commit_link": "github.com/JLucka/kickstarter-dev/commit/e2ffa062697e060fdfbd2eccbb89a8c53a569e0b",
"file_name": "backend/transactions/TransactionConnector.py",
"func_name": "save_accepted_transaction",
"line_changes": {
"added": [
{
"char_end": 168,
"char_start": 69,
"line": " self.cursor.execute(\"update users set money = money - %s where id = %s\", (money, user_id))\n",
"line_no": 2
},
{
"char_end": 273,
"char_start": 168,
"line": " self.cursor.execute(\"update projects set money = money + %s where id = %s\", (money, project_id))\n",
"line_no": 3
},
{
"char_end": 392,
"char_start": 273,
"line": " self.cursor.execute(\"insert into transactions (project_id, user_id, money, timestamp, state) values (%s, %s, \"\n",
"line_no": 4
},
{
"char_end": 477,
"char_start": 392,
"line": " \"%s, now(), 'accepted' )\", (project_id, user_id, money))\n",
"line_no": 5
}
],
"deleted": [
{
"char_end": 167,
"char_start": 69,
"line": " self.cursor.execute(\"update users set money = money - %s where id = %s\"%(money, user_id))\n",
"line_no": 2
},
{
"char_end": 273,
"char_start": 167,
"line": " self.cursor.execute(\"update projects set money = money + %s where id = %s\" % (money, project_id))\n",
"line_no": 3
},
{
"char_end": 447,
"char_start": 273,
"line": " 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",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 292 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def save_accepted_transaction(self, user_id, project_id, money):",
" self.cursor.execute(\"update users set money = money - %s where id = %s\", (money, user_id))\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))",
" self.db.commit()"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 150,
"char_start": 148,
"chars": ", "
},
{
"char_end": 251,
"char_start": 250,
"chars": ","
},
{
"char_end": 421,
"char_start": 390,
"chars": "\"\n \""
},
{
"char_end": 446,
"char_start": 445,
"chars": ","
}
],
"deleted": [
{
"char_end": 149,
"char_start": 148,
"chars": "%"
},
{
"char_end": 251,
"char_start": 249,
"chars": " %"
},
{
"char_end": 416,
"char_start": 414,
"chars": " %"
}
]
},
"commit_link": "github.com/JLucka/kickstarter-dev/commit/e2ffa062697e060fdfbd2eccbb89a8c53a569e0b",
"file_name": "backend/transactions/TransactionConnector.py",
"func_name": "save_accepted_transaction",
"line_changes": {
"added": [
{
"char_end": 168,
"char_start": 69,
"line": " self.cursor.execute(\"update users set money = money - %s where id = %s\", (money, user_id))\n",
"line_no": 2
},
{
"char_end": 273,
"char_start": 168,
"line": " self.cursor.execute(\"update projects set money = money + %s where id = %s\", (money, project_id))\n",
"line_no": 3
},
{
"char_end": 392,
"char_start": 273,
"line": " self.cursor.execute(\"insert into transactions (project_id, user_id, money, timestamp, state) values (%s, %s, \"\n",
"line_no": 4
},
{
"char_end": 477,
"char_start": 392,
"line": " \"%s, now(), 'accepted' )\", (project_id, user_id, money))\n",
"line_no": 5
}
],
"deleted": [
{
"char_end": 167,
"char_start": 69,
"line": " self.cursor.execute(\"update users set money = money - %s where id = %s\"%(money, user_id))\n",
"line_no": 2
},
{
"char_end": 273,
"char_start": 167,
"line": " self.cursor.execute(\"update projects set money = money + %s where id = %s\" % (money, project_id))\n",
"line_no": 3
},
{
"char_end": 447,
"char_start": 273,
"line": " 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",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 292 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def shame_ask(name):\n db = db_connect()\n cursor = db.cursor()\n try:\n cursor.execute('''",
" SELECT shame FROM people WHERE name='{}'\n '''.format(name))",
" shame = cursor.fetchone()\n db.close()\n if shame is None:\n logger.debug('No shame found for name {}'.format(name))\n return shame\n else:\n shame = shame[0]\n logger.debug('shame of {} found for name {}'.format(shame, name))\n return shame\n except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise"
] | [
1,
0,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 160,
"char_start": 152,
"chars": "%(name)s"
},
{
"char_end": 178,
"char_start": 176,
"chars": ", "
},
{
"char_end": 185,
"char_start": 183,
"chars": ", "
}
],
"deleted": [
{
"char_end": 156,
"char_start": 152,
"chars": "'{}'"
},
{
"char_end": 179,
"char_start": 172,
"chars": ".format"
}
]
},
"commit_link": "github.com/tylarb/KarmaBoi-PCF/commit/c1d00a27d7f6b7eb6f15a3dacd4269654a32c10a",
"file_name": "KarmaBoi/dbopts.py",
"func_name": "shame_ask",
"line_changes": {
"added": [
{
"char_end": 161,
"char_start": 104,
"line": " SELECT shame FROM people WHERE name=%(name)s\n",
"line_no": 6
},
{
"char_end": 188,
"char_start": 161,
"line": " ''', (name, ))\n",
"line_no": 7
}
],
"deleted": [
{
"char_end": 157,
"char_start": 104,
"line": " SELECT shame FROM people WHERE name='{}'\n",
"line_no": 6
},
{
"char_end": 187,
"char_start": 157,
"line": " '''.format(name))\n",
"line_no": 7
}
]
},
"vul_type": "cwe-089"
} | 293 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def shame_ask(name):\n db = db_connect()\n cursor = db.cursor()\n try:\n cursor.execute('''",
" SELECT shame FROM people WHERE name=%(name)s\n ''', (name, ))",
" shame = cursor.fetchone()\n db.close()\n if shame is None:\n logger.debug('No shame found for name {}'.format(name))\n return shame\n else:\n shame = shame[0]\n logger.debug('shame of {} found for name {}'.format(shame, name))\n return shame\n except Exception as e:\n logger.error('Execution failed with error: {}'.format(e))\n raise"
] | [
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 160,
"char_start": 152,
"chars": "%(name)s"
},
{
"char_end": 178,
"char_start": 176,
"chars": ", "
},
{
"char_end": 185,
"char_start": 183,
"chars": ", "
}
],
"deleted": [
{
"char_end": 156,
"char_start": 152,
"chars": "'{}'"
},
{
"char_end": 179,
"char_start": 172,
"chars": ".format"
}
]
},
"commit_link": "github.com/tylarb/KarmaBoi-PCF/commit/c1d00a27d7f6b7eb6f15a3dacd4269654a32c10a",
"file_name": "KarmaBoi/dbopts.py",
"func_name": "shame_ask",
"line_changes": {
"added": [
{
"char_end": 161,
"char_start": 104,
"line": " SELECT shame FROM people WHERE name=%(name)s\n",
"line_no": 6
},
{
"char_end": 188,
"char_start": 161,
"line": " ''', (name, ))\n",
"line_no": 7
}
],
"deleted": [
{
"char_end": 157,
"char_start": 104,
"line": " SELECT shame FROM people WHERE name='{}'\n",
"line_no": 6
},
{
"char_end": 187,
"char_start": 157,
"line": " '''.format(name))\n",
"line_no": 7
}
]
},
"vul_type": "cwe-089"
} | 293 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def incrementOption(cursor, poll_name, option):\n key = poll_name+\"-\"+option",
" req = \"UPDATE {} SET count=count+1 WHERE name_option = '{}';\".format(CFG(\"options_table_name\"), key)\n cursor.execute(req)"
] | [
1,
0
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 137,
"char_start": 136,
"chars": "?"
},
{
"char_end": 203,
"char_start": 195,
"chars": ", (key,)"
}
],
"deleted": [
{
"char_end": 136,
"char_start": 135,
"chars": " "
},
{
"char_end": 143,
"char_start": 137,
"chars": " '{}';"
},
{
"char_end": 182,
"char_start": 177,
"chars": ", key"
}
]
},
"commit_link": "github.com/FAUSheppy/simple-python-poll/commit/186c5ff5cdf58272e253a1bb432419ee50d93109",
"file_name": "database.py",
"func_name": "incrementOption",
"line_changes": {
"added": [
{
"char_end": 173,
"char_start": 79,
"line": " req = \"UPDATE {} SET count=count+1 WHERE name_option=?\".format(CFG(\"options_table_name\"))\n",
"line_no": 3
},
{
"char_end": 204,
"char_start": 173,
"line": " cursor.execute(req, (key,))\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 184,
"char_start": 79,
"line": " req = \"UPDATE {} SET count=count+1 WHERE name_option = '{}';\".format(CFG(\"options_table_name\"), key)\n",
"line_no": 3
},
{
"char_end": 207,
"char_start": 184,
"line": " cursor.execute(req)\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 294 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def incrementOption(cursor, poll_name, option):\n key = poll_name+\"-\"+option",
" req = \"UPDATE {} SET count=count+1 WHERE name_option=?\".format(CFG(\"options_table_name\"))\n cursor.execute(req, (key,))"
] | [
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 137,
"char_start": 136,
"chars": "?"
},
{
"char_end": 203,
"char_start": 195,
"chars": ", (key,)"
}
],
"deleted": [
{
"char_end": 136,
"char_start": 135,
"chars": " "
},
{
"char_end": 143,
"char_start": 137,
"chars": " '{}';"
},
{
"char_end": 182,
"char_start": 177,
"chars": ", key"
}
]
},
"commit_link": "github.com/FAUSheppy/simple-python-poll/commit/186c5ff5cdf58272e253a1bb432419ee50d93109",
"file_name": "database.py",
"func_name": "incrementOption",
"line_changes": {
"added": [
{
"char_end": 173,
"char_start": 79,
"line": " req = \"UPDATE {} SET count=count+1 WHERE name_option=?\".format(CFG(\"options_table_name\"))\n",
"line_no": 3
},
{
"char_end": 204,
"char_start": 173,
"line": " cursor.execute(req, (key,))\n",
"line_no": 4
}
],
"deleted": [
{
"char_end": 184,
"char_start": 79,
"line": " req = \"UPDATE {} SET count=count+1 WHERE name_option = '{}';\".format(CFG(\"options_table_name\"), key)\n",
"line_no": 3
},
{
"char_end": 207,
"char_start": 184,
"line": " cursor.execute(req)\n",
"line_no": 4
}
]
},
"vul_type": "cwe-089"
} | 294 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route('/overview/<classNum>')\ndef overview(classNum):\n\tif 'username' in session:\n\t\tclassNoSpace = classNum.split(' ')[0]+classNum.split(' ')[1]",
"\t\t#Save the current course as a session variable.\n\t\tsession['currentCourse'] = classNoSpace",
"\t\tconn = mysql.connect()\n\t\tcursor = conn.cursor()\n",
"\t\tcursor.execute(\"SELECT courseName,courseOverview from courses where courseAbbreviation='\" + classNoSpace + \"'\")",
"\t\tdata = cursor.fetchone()",
"\t\treturn render_template('overview.html', className = classNum, courseTitle = data[0], courseOverview = data[1])",
"\treturn redirect(url_for('index'))"
] | [
1,
1,
1,
0,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 385,
"char_start": 383,
"chars": "%s"
},
{
"char_end": 387,
"char_start": 386,
"chars": ","
},
{
"char_end": 389,
"char_start": 388,
"chars": "("
},
{
"char_end": 402,
"char_start": 401,
"chars": ")"
}
],
"deleted": [
{
"char_end": 384,
"char_start": 383,
"chars": "'"
},
{
"char_end": 388,
"char_start": 386,
"chars": "+ "
},
{
"char_end": 406,
"char_start": 400,
"chars": " + \"'\""
}
]
},
"commit_link": "github.com/CaitlinKennedy/Tech-Track/commit/20ef2d4010f9497b8221524edd0c706e2c6a4147",
"file_name": "src/tech_track.py",
"func_name": "overview",
"line_changes": {
"added": [
{
"char_end": 404,
"char_start": 294,
"line": "\t\tcursor.execute(\"SELECT courseName,courseOverview from courses where courseAbbreviation=%s\", (classNoSpace))\n",
"line_no": 12
}
],
"deleted": [
{
"char_end": 408,
"char_start": 294,
"line": "\t\tcursor.execute(\"SELECT courseName,courseOverview from courses where courseAbbreviation='\" + classNoSpace + \"'\")\n",
"line_no": 12
}
]
},
"vul_type": "cwe-089"
} | 295 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@app.route('/overview/<classNum>')\ndef overview(classNum):\n\tif 'username' in session:\n\t\tclassNoSpace = classNum.split(' ')[0]+classNum.split(' ')[1]",
"\t\t#Save the current course as a session variable.\n\t\tsession['currentCourse'] = classNoSpace",
"\t\tconn = mysql.connect()\n\t\tcursor = conn.cursor()\n",
"\t\tcursor.execute(\"SELECT courseName,courseOverview from courses where courseAbbreviation=%s\", (classNoSpace))",
"\t\tdata = cursor.fetchone()",
"\t\treturn render_template('overview.html', className = classNum, courseTitle = data[0], courseOverview = data[1])",
"\treturn redirect(url_for('index'))"
] | [
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 385,
"char_start": 383,
"chars": "%s"
},
{
"char_end": 387,
"char_start": 386,
"chars": ","
},
{
"char_end": 389,
"char_start": 388,
"chars": "("
},
{
"char_end": 402,
"char_start": 401,
"chars": ")"
}
],
"deleted": [
{
"char_end": 384,
"char_start": 383,
"chars": "'"
},
{
"char_end": 388,
"char_start": 386,
"chars": "+ "
},
{
"char_end": 406,
"char_start": 400,
"chars": " + \"'\""
}
]
},
"commit_link": "github.com/CaitlinKennedy/Tech-Track/commit/20ef2d4010f9497b8221524edd0c706e2c6a4147",
"file_name": "src/tech_track.py",
"func_name": "overview",
"line_changes": {
"added": [
{
"char_end": 404,
"char_start": 294,
"line": "\t\tcursor.execute(\"SELECT courseName,courseOverview from courses where courseAbbreviation=%s\", (classNoSpace))\n",
"line_no": 12
}
],
"deleted": [
{
"char_end": 408,
"char_start": 294,
"line": "\t\tcursor.execute(\"SELECT courseName,courseOverview from courses where courseAbbreviation='\" + classNoSpace + \"'\")\n",
"line_no": 12
}
]
},
"vul_type": "cwe-089"
} | 295 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"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:",
" sql = \"INSERT INTO {} VALUES {}\".format(listing_tags_table_name, str((listing_id, x)))\n cur.execute(sql)"
] | [
1,
0
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 212,
"char_start": 210,
"chars": "%s"
},
{
"char_end": 227,
"char_start": 220,
"chars": "(%s %s)"
},
{
"char_end": 239,
"char_start": 228,
"chars": "\n cu"
},
{
"char_end": 246,
"char_start": 240,
"chars": ".execu"
},
{
"char_end": 254,
"char_start": 247,
"chars": "e(sql, "
}
],
"deleted": [
{
"char_end": 212,
"char_start": 210,
"chars": "{}"
},
{
"char_end": 222,
"char_start": 220,
"chars": "{}"
},
{
"char_end": 226,
"char_start": 223,
"chars": ".fo"
},
{
"char_end": 229,
"char_start": 227,
"chars": "ma"
},
{
"char_end": 261,
"char_start": 256,
"chars": "str(("
},
{
"char_end": 302,
"char_start": 276,
"chars": ")\n cur.execute(sql)"
}
]
},
"commit_link": "github.com/tasbir49/BreadWinner/commit/332a9f2c619be399ae94244bb8bd0977fc62bc16",
"file_name": "backend-api/backend-api.py",
"func_name": "addTags",
"line_changes": {
"added": [
{
"char_end": 229,
"char_start": 183,
"line": " sql = \"INSERT INTO %s VALUES (%s %s)\"\n",
"line_no": 7
},
{
"char_end": 295,
"char_start": 229,
"line": " cur.execute(sql, (listing_tags_table_name, listing_id, x))\n",
"line_no": 8
}
],
"deleted": [
{
"char_end": 278,
"char_start": 183,
"line": " sql = \"INSERT INTO {} VALUES {}\".format(listing_tags_table_name, str((listing_id, x)))\n",
"line_no": 7
},
{
"char_end": 302,
"char_start": 278,
"line": " cur.execute(sql)\n",
"line_no": 8
}
]
},
"vul_type": "cwe-089"
} | 296 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"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:",
" sql = \"INSERT INTO %s VALUES (%s %s)\"\n cur.execute(sql, (listing_tags_table_name, listing_id, x))"
] | [
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 212,
"char_start": 210,
"chars": "%s"
},
{
"char_end": 227,
"char_start": 220,
"chars": "(%s %s)"
},
{
"char_end": 239,
"char_start": 228,
"chars": "\n cu"
},
{
"char_end": 246,
"char_start": 240,
"chars": ".execu"
},
{
"char_end": 254,
"char_start": 247,
"chars": "e(sql, "
}
],
"deleted": [
{
"char_end": 212,
"char_start": 210,
"chars": "{}"
},
{
"char_end": 222,
"char_start": 220,
"chars": "{}"
},
{
"char_end": 226,
"char_start": 223,
"chars": ".fo"
},
{
"char_end": 229,
"char_start": 227,
"chars": "ma"
},
{
"char_end": 261,
"char_start": 256,
"chars": "str(("
},
{
"char_end": 302,
"char_start": 276,
"chars": ")\n cur.execute(sql)"
}
]
},
"commit_link": "github.com/tasbir49/BreadWinner/commit/332a9f2c619be399ae94244bb8bd0977fc62bc16",
"file_name": "backend-api/backend-api.py",
"func_name": "addTags",
"line_changes": {
"added": [
{
"char_end": 229,
"char_start": 183,
"line": " sql = \"INSERT INTO %s VALUES (%s %s)\"\n",
"line_no": 7
},
{
"char_end": 295,
"char_start": 229,
"line": " cur.execute(sql, (listing_tags_table_name, listing_id, x))\n",
"line_no": 8
}
],
"deleted": [
{
"char_end": 278,
"char_start": 183,
"line": " sql = \"INSERT INTO {} VALUES {}\".format(listing_tags_table_name, str((listing_id, x)))\n",
"line_no": 7
},
{
"char_end": 302,
"char_start": 278,
"line": " cur.execute(sql)\n",
"line_no": 8
}
]
},
"vul_type": "cwe-089"
} | 296 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@mod.route('/edit/<int:cmt_id>', methods=['GET', 'POST'])\ndef edit(cmt_id):\n m = None\n if request.method == 'GET':",
" sql = \"SELECT * FROM comment where cmt_id = %d;\" % (cmt_id)\n cursor.execute(sql)",
" m = cursor.fetchone()\n return render_template('comment/edit.html', m=m, cmt_id=cmt_id)",
" if request.method == 'POST':\n content = request.form['content']",
" sql = \"UPDATE comment SET content = '%s' where cmt_id = '%d';\" \\\n % (content, cmt_id)\n cursor.execute(sql)",
" conn.commit()",
" sql = \"SELECT msg_id FROM comment where cmt_id = %d;\" % (cmt_id)\n cursor.execute(sql)",
" m = cursor.fetchone()\n flash('Edit Success!')\n return redirect(url_for('comment.show', msg_id=m[0]))",
" return render_template('comment/edit.html', m=m, cmt_id=cmt_id)"
] | [
1,
0,
1,
1,
0,
1,
0,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 132,
"char_start": 129,
"chars": "cur"
},
{
"char_end": 144,
"char_start": 133,
"chars": "or.execute("
},
{
"char_end": 184,
"char_start": 183,
"chars": "s"
},
{
"char_end": 187,
"char_start": 186,
"chars": ","
},
{
"char_end": 196,
"char_start": 195,
"chars": ","
},
{
"char_end": 388,
"char_start": 385,
"chars": "cur"
},
{
"char_end": 400,
"char_start": 389,
"chars": "or.execute("
},
{
"char_end": 450,
"char_start": 449,
"chars": "s"
},
{
"char_end": 453,
"char_start": 452,
"chars": ","
},
{
"char_end": 506,
"char_start": 503,
"chars": "cur"
},
{
"char_end": 518,
"char_start": 507,
"chars": "or.execute("
},
{
"char_end": 563,
"char_start": 562,
"chars": "s"
},
{
"char_end": 566,
"char_start": 565,
"chars": ","
},
{
"char_end": 575,
"char_start": 574,
"chars": ","
}
],
"deleted": [
{
"char_end": 135,
"char_start": 130,
"chars": "ql = "
},
{
"char_end": 175,
"char_start": 174,
"chars": "d"
},
{
"char_end": 179,
"char_start": 177,
"chars": " %"
},
{
"char_end": 215,
"char_start": 188,
"chars": "\n cursor.execute(sql"
},
{
"char_end": 409,
"char_start": 404,
"chars": "ql = "
},
{
"char_end": 440,
"char_start": 439,
"chars": "'"
},
{
"char_end": 443,
"char_start": 442,
"chars": "'"
},
{
"char_end": 460,
"char_start": 459,
"chars": "'"
},
{
"char_end": 463,
"char_start": 461,
"chars": "d'"
},
{
"char_end": 481,
"char_start": 465,
"chars": " \\\n %"
},
{
"char_end": 526,
"char_start": 499,
"chars": "\n cursor.execute(sql"
},
{
"char_end": 564,
"char_start": 559,
"chars": "ql = "
},
{
"char_end": 609,
"char_start": 608,
"chars": "d"
},
{
"char_end": 613,
"char_start": 611,
"chars": " %"
},
{
"char_end": 649,
"char_start": 622,
"chars": "\n cursor.execute(sql"
}
]
},
"commit_link": "github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9",
"file_name": "flaskr/flaskr/views/comment.py",
"func_name": "edit",
"line_changes": {
"added": [
{
"char_end": 199,
"char_start": 121,
"line": " cursor.execute(\"SELECT * FROM comment where cmt_id = %s;\", (cmt_id,))\n",
"line_no": 5
},
{
"char_end": 473,
"char_start": 377,
"line": " cursor.execute(\"UPDATE comment SET content = %s where cmt_id = %s;\", (content, cmt_id))\n",
"line_no": 11
},
{
"char_end": 578,
"char_start": 495,
"line": " cursor.execute(\"SELECT msg_id FROM comment where cmt_id = %s;\", (cmt_id,))\n",
"line_no": 13
}
],
"deleted": [
{
"char_end": 189,
"char_start": 121,
"line": " sql = \"SELECT * FROM comment where cmt_id = %d;\" % (cmt_id)\n",
"line_no": 5
},
{
"char_end": 217,
"char_start": 189,
"line": " cursor.execute(sql)\n",
"line_no": 6
},
{
"char_end": 468,
"char_start": 395,
"line": " sql = \"UPDATE comment SET content = '%s' where cmt_id = '%d';\" \\\n",
"line_no": 12
},
{
"char_end": 500,
"char_start": 468,
"line": " % (content, cmt_id)\n",
"line_no": 13
},
{
"char_end": 528,
"char_start": 500,
"line": " cursor.execute(sql)\n",
"line_no": 14
},
{
"char_end": 623,
"char_start": 550,
"line": " sql = \"SELECT msg_id FROM comment where cmt_id = %d;\" % (cmt_id)\n",
"line_no": 16
},
{
"char_end": 651,
"char_start": 623,
"line": " cursor.execute(sql)\n",
"line_no": 17
}
]
},
"vul_type": "cwe-089"
} | 297 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"@mod.route('/edit/<int:cmt_id>', methods=['GET', 'POST'])\ndef edit(cmt_id):\n m = None\n if request.method == 'GET':",
" cursor.execute(\"SELECT * FROM comment where cmt_id = %s;\", (cmt_id,))",
" m = cursor.fetchone()\n return render_template('comment/edit.html', m=m, cmt_id=cmt_id)",
" if request.method == 'POST':\n content = request.form['content']",
" cursor.execute(\"UPDATE comment SET content = %s where cmt_id = %s;\", (content, cmt_id))",
" conn.commit()",
" cursor.execute(\"SELECT msg_id FROM comment where cmt_id = %s;\", (cmt_id,))",
" m = cursor.fetchone()\n flash('Edit Success!')\n return redirect(url_for('comment.show', msg_id=m[0]))",
" return render_template('comment/edit.html', m=m, cmt_id=cmt_id)"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 132,
"char_start": 129,
"chars": "cur"
},
{
"char_end": 144,
"char_start": 133,
"chars": "or.execute("
},
{
"char_end": 184,
"char_start": 183,
"chars": "s"
},
{
"char_end": 187,
"char_start": 186,
"chars": ","
},
{
"char_end": 196,
"char_start": 195,
"chars": ","
},
{
"char_end": 388,
"char_start": 385,
"chars": "cur"
},
{
"char_end": 400,
"char_start": 389,
"chars": "or.execute("
},
{
"char_end": 450,
"char_start": 449,
"chars": "s"
},
{
"char_end": 453,
"char_start": 452,
"chars": ","
},
{
"char_end": 506,
"char_start": 503,
"chars": "cur"
},
{
"char_end": 518,
"char_start": 507,
"chars": "or.execute("
},
{
"char_end": 563,
"char_start": 562,
"chars": "s"
},
{
"char_end": 566,
"char_start": 565,
"chars": ","
},
{
"char_end": 575,
"char_start": 574,
"chars": ","
}
],
"deleted": [
{
"char_end": 135,
"char_start": 130,
"chars": "ql = "
},
{
"char_end": 175,
"char_start": 174,
"chars": "d"
},
{
"char_end": 179,
"char_start": 177,
"chars": " %"
},
{
"char_end": 215,
"char_start": 188,
"chars": "\n cursor.execute(sql"
},
{
"char_end": 409,
"char_start": 404,
"chars": "ql = "
},
{
"char_end": 440,
"char_start": 439,
"chars": "'"
},
{
"char_end": 443,
"char_start": 442,
"chars": "'"
},
{
"char_end": 460,
"char_start": 459,
"chars": "'"
},
{
"char_end": 463,
"char_start": 461,
"chars": "d'"
},
{
"char_end": 481,
"char_start": 465,
"chars": " \\\n %"
},
{
"char_end": 526,
"char_start": 499,
"chars": "\n cursor.execute(sql"
},
{
"char_end": 564,
"char_start": 559,
"chars": "ql = "
},
{
"char_end": 609,
"char_start": 608,
"chars": "d"
},
{
"char_end": 613,
"char_start": 611,
"chars": " %"
},
{
"char_end": 649,
"char_start": 622,
"chars": "\n cursor.execute(sql"
}
]
},
"commit_link": "github.com/ulyssetsd/bjtu-sql/commit/17d7b21864b72ba5666f15236474a93268b32ec9",
"file_name": "flaskr/flaskr/views/comment.py",
"func_name": "edit",
"line_changes": {
"added": [
{
"char_end": 199,
"char_start": 121,
"line": " cursor.execute(\"SELECT * FROM comment where cmt_id = %s;\", (cmt_id,))\n",
"line_no": 5
},
{
"char_end": 473,
"char_start": 377,
"line": " cursor.execute(\"UPDATE comment SET content = %s where cmt_id = %s;\", (content, cmt_id))\n",
"line_no": 11
},
{
"char_end": 578,
"char_start": 495,
"line": " cursor.execute(\"SELECT msg_id FROM comment where cmt_id = %s;\", (cmt_id,))\n",
"line_no": 13
}
],
"deleted": [
{
"char_end": 189,
"char_start": 121,
"line": " sql = \"SELECT * FROM comment where cmt_id = %d;\" % (cmt_id)\n",
"line_no": 5
},
{
"char_end": 217,
"char_start": 189,
"line": " cursor.execute(sql)\n",
"line_no": 6
},
{
"char_end": 468,
"char_start": 395,
"line": " sql = \"UPDATE comment SET content = '%s' where cmt_id = '%d';\" \\\n",
"line_no": 12
},
{
"char_end": 500,
"char_start": 468,
"line": " % (content, cmt_id)\n",
"line_no": 13
},
{
"char_end": 528,
"char_start": 500,
"line": " cursor.execute(sql)\n",
"line_no": 14
},
{
"char_end": 623,
"char_start": 550,
"line": " sql = \"SELECT msg_id FROM comment where cmt_id = %d;\" % (cmt_id)\n",
"line_no": 16
},
{
"char_end": 651,
"char_start": 623,
"line": " cursor.execute(sql)\n",
"line_no": 17
}
]
},
"vul_type": "cwe-089"
} | 297 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def process_form():\n # see https://docs.python.org/3.4/library/cgi.html for the basic usage\n # here.\n form = cgi.FieldStorage()",
"\n if \"player1\" not in form or \"player2\" not in form or \"size\" not in form:\n raise FormError(\"Invalid parameters.\")",
" player1 = form[\"player1\"].value\n player2 = form[\"player2\"].value\n for c in player1+player2:\n if c not in \"_-\" and not c.isdigit() and not c.isalpha():\n raise FormError(\"Invalid parameters: The player names can only contains upper and lowercase characters, digits, underscores, and hypens\")\n return",
" try:\n size = int(form[\"size\"].value)\n except:\n raise FormError(\"Invalid parameters: 'size' is not an integer.\")\n return",
" if size < 2 or size > 9:\n raise FormError(\"The 'size' must be in the range 2-9, inclusive.\")",
"\n # connect to the database\n conn = MySQLdb.connect(host = pnsdp.SQL_HOST,\n user = pnsdp.SQL_USER,\n passwd = pnsdp.SQL_PASSWD,\n db = pnsdp.SQL_DB)\n cursor = conn.cursor()",
" # insert the new row",
" cursor.execute(\"\"\"INSERT INTO games(player1,player2,size) VALUES(\"%s\",\"%s\",%d);\"\"\" % (player1,player2,size))",
"\n gameID = cursor.lastrowid",
"\n # MySQLdb has been building a transaction as we run. Commit them now, and\n # also clean up the other resources we've allocated.\n conn.commit()\n cursor.close()\n conn.close()",
" return gameID"
] | [
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1235,
"char_start": 1234,
"chars": ","
}
],
"deleted": [
{
"char_end": 1236,
"char_start": 1234,
"chars": " %"
}
]
},
"commit_link": "github.com/russ-lewis/ttt_-_python_cgi/commit/6096f43fd4b2d91211eec4614b7960c0816900da",
"file_name": "cgi/create_game.py",
"func_name": "process_form",
"line_changes": {
"added": [
{
"char_end": 1260,
"char_start": 1148,
"line": " cursor.execute(\"\"\"INSERT INTO games(player1,player2,size) VALUES(\"%s\",\"%s\",%d);\"\"\", (player1,player2,size))\n",
"line_no": 35
}
],
"deleted": [
{
"char_end": 1261,
"char_start": 1148,
"line": " cursor.execute(\"\"\"INSERT INTO games(player1,player2,size) VALUES(\"%s\",\"%s\",%d);\"\"\" % (player1,player2,size))\n",
"line_no": 35
}
]
},
"vul_type": "cwe-089"
} | 298 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def process_form():\n # see https://docs.python.org/3.4/library/cgi.html for the basic usage\n # here.\n form = cgi.FieldStorage()",
"\n if \"player1\" not in form or \"player2\" not in form or \"size\" not in form:\n raise FormError(\"Invalid parameters.\")",
" player1 = form[\"player1\"].value\n player2 = form[\"player2\"].value\n for c in player1+player2:\n if c not in \"_-\" and not c.isdigit() and not c.isalpha():\n raise FormError(\"Invalid parameters: The player names can only contains upper and lowercase characters, digits, underscores, and hypens\")\n return",
" try:\n size = int(form[\"size\"].value)\n except:\n raise FormError(\"Invalid parameters: 'size' is not an integer.\")\n return",
" if size < 2 or size > 9:\n raise FormError(\"The 'size' must be in the range 2-9, inclusive.\")",
"\n # connect to the database\n conn = MySQLdb.connect(host = pnsdp.SQL_HOST,\n user = pnsdp.SQL_USER,\n passwd = pnsdp.SQL_PASSWD,\n db = pnsdp.SQL_DB)\n cursor = conn.cursor()",
" # insert the new row",
" cursor.execute(\"\"\"INSERT INTO games(player1,player2,size) VALUES(\"%s\",\"%s\",%d);\"\"\", (player1,player2,size))",
"\n gameID = cursor.lastrowid",
"\n # MySQLdb has been building a transaction as we run. Commit them now, and\n # also clean up the other resources we've allocated.\n conn.commit()\n cursor.close()\n conn.close()",
" return gameID"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 1235,
"char_start": 1234,
"chars": ","
}
],
"deleted": [
{
"char_end": 1236,
"char_start": 1234,
"chars": " %"
}
]
},
"commit_link": "github.com/russ-lewis/ttt_-_python_cgi/commit/6096f43fd4b2d91211eec4614b7960c0816900da",
"file_name": "cgi/create_game.py",
"func_name": "process_form",
"line_changes": {
"added": [
{
"char_end": 1260,
"char_start": 1148,
"line": " cursor.execute(\"\"\"INSERT INTO games(player1,player2,size) VALUES(\"%s\",\"%s\",%d);\"\"\", (player1,player2,size))\n",
"line_no": 35
}
],
"deleted": [
{
"char_end": 1261,
"char_start": 1148,
"line": " cursor.execute(\"\"\"INSERT INTO games(player1,player2,size) VALUES(\"%s\",\"%s\",%d);\"\"\" % (player1,player2,size))\n",
"line_no": 35
}
]
},
"vul_type": "cwe-089"
} | 298 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def clean_cache(self, limit):\n \"\"\"\n Method that remove several User objects from cache - the least \n active users\n :param limit: number of the users that the method should remove\n from cache\n :return: None\n \"\"\"",
" log.info('Figuring out the least active users...')\n # Select users that the least active recently\n user_ids = tuple(self.users.keys())\n query = ('SELECT chat_id '\n 'FROM photo_queries_table2 '\n f'WHERE chat_id in {user_ids} '\n 'GROUP BY chat_id '\n 'ORDER BY MAX(time) '",
" f'LIMIT {limit}')",
"\n try:",
" cursor = db.execute_query(query)",
" except DatabaseConnectionError:\n log.error(\"Can't figure out the least active users...\")\n return",
" if not cursor.rowcount:\n log.warning(\"There are no users in the db\")\n return",
" # Make list out of tuple of tuples that is returned by MySQL\n least_active_users = [chat_id[0] for chat_id in cursor.fetchall()]\n log.info('Removing %d least active users from cache...', limit)\n num_deleted_entries = 0\n for entry in least_active_users:\n log.debug('Deleting %s...', entry)\n deleted_entry = self.users.pop(entry, None)\n if deleted_entry:\n num_deleted_entries += 1\n log.debug(\"%d users were removed from cache.\", num_deleted_entries)"
] | [
1,
1,
0,
1,
0,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 680,
"char_start": 653,
"chars": "%s')\n\n parameters = "
},
{
"char_end": 686,
"char_start": 685,
"chars": ","
},
{
"char_end": 756,
"char_start": 744,
"chars": ", parameters"
}
],
"deleted": [
{
"char_end": 654,
"char_start": 653,
"chars": "{"
},
{
"char_end": 662,
"char_start": 659,
"chars": "}')"
}
]
},
"commit_link": "github.com/RandyRomero/photoGPSbot/commit/0e9f57f13e61863b3672f5730e27f149da00786a",
"file_name": "photogpsbot/users.py",
"func_name": "clean_cache",
"line_changes": {
"added": [
{
"char_end": 658,
"char_start": 628,
"line": " f'LIMIT %s')\n",
"line_no": 18
},
{
"char_end": 659,
"char_start": 658,
"line": "\n",
"line_no": 19
},
{
"char_end": 687,
"char_start": 659,
"line": " parameters = limit,\n",
"line_no": 20
},
{
"char_end": 758,
"char_start": 701,
"line": " cursor = db.execute_query(query, parameters)\n",
"line_no": 23
}
],
"deleted": [
{
"char_end": 663,
"char_start": 628,
"line": " f'LIMIT {limit}')\n",
"line_no": 18
},
{
"char_end": 722,
"char_start": 677,
"line": " cursor = db.execute_query(query)\n",
"line_no": 21
}
]
},
"vul_type": "cwe-089"
} | 299 | cwe-089 | py |
Determine whether the {function_name} code is vulnerable or not. | [
"def clean_cache(self, limit):\n \"\"\"\n Method that remove several User objects from cache - the least \n active users\n :param limit: number of the users that the method should remove\n from cache\n :return: None\n \"\"\"",
" log.info('Figuring out the least active users...')\n # Select users that the least active recently\n user_ids = tuple(self.users.keys())\n query = ('SELECT chat_id '\n 'FROM photo_queries_table2 '\n f'WHERE chat_id in {user_ids} '\n 'GROUP BY chat_id '\n 'ORDER BY MAX(time) '",
" f'LIMIT %s')",
" parameters = limit,",
"\n try:",
" cursor = db.execute_query(query, parameters)",
" except DatabaseConnectionError:\n log.error(\"Can't figure out the least active users...\")\n return",
" if not cursor.rowcount:\n log.warning(\"There are no users in the db\")\n return",
" # Make list out of tuple of tuples that is returned by MySQL\n least_active_users = [chat_id[0] for chat_id in cursor.fetchall()]\n log.info('Removing %d least active users from cache...', limit)\n num_deleted_entries = 0\n for entry in least_active_users:\n log.debug('Deleting %s...', entry)\n deleted_entry = self.users.pop(entry, None)\n if deleted_entry:\n num_deleted_entries += 1\n log.debug(\"%d users were removed from cache.\", num_deleted_entries)"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1
] | SVEN | {
"char_changes": {
"added": [
{
"char_end": 680,
"char_start": 653,
"chars": "%s')\n\n parameters = "
},
{
"char_end": 686,
"char_start": 685,
"chars": ","
},
{
"char_end": 756,
"char_start": 744,
"chars": ", parameters"
}
],
"deleted": [
{
"char_end": 654,
"char_start": 653,
"chars": "{"
},
{
"char_end": 662,
"char_start": 659,
"chars": "}')"
}
]
},
"commit_link": "github.com/RandyRomero/photoGPSbot/commit/0e9f57f13e61863b3672f5730e27f149da00786a",
"file_name": "photogpsbot/users.py",
"func_name": "clean_cache",
"line_changes": {
"added": [
{
"char_end": 658,
"char_start": 628,
"line": " f'LIMIT %s')\n",
"line_no": 18
},
{
"char_end": 659,
"char_start": 658,
"line": "\n",
"line_no": 19
},
{
"char_end": 687,
"char_start": 659,
"line": " parameters = limit,\n",
"line_no": 20
},
{
"char_end": 758,
"char_start": 701,
"line": " cursor = db.execute_query(query, parameters)\n",
"line_no": 23
}
],
"deleted": [
{
"char_end": 663,
"char_start": 628,
"line": " f'LIMIT {limit}')\n",
"line_no": 18
},
{
"char_end": 722,
"char_start": 677,
"line": " cursor = db.execute_query(query)\n",
"line_no": 21
}
]
},
"vul_type": "cwe-089"
} | 299 | cwe-089 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.