Spaces:
Sleeping
Sleeping
File size: 9,095 Bytes
09ec238 0fb8bd2 09ec238 8684af9 09ec238 0fb8bd2 09ec238 0fb8bd2 09ec238 8684af9 09ec238 0fb8bd2 09ec238 0fb8bd2 09ec238 0fb8bd2 09ec238 8684af9 09ec238 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | [
{
"task_type": "easy",
"pr": {
"id": "2",
"title": "Missing import",
"description": "Forgot to import module",
"language": "python",
"diffs": [
{
"file_name": "main.py",
"diff": "print(datetime.now())"
}
]
},
"ground_truth": {
"issues": ["missing import datetime"],
"decision": "reject",
"fix": "from datetime import datetime\nprint(datetime.now())"
}
},
{
"task_type": "easy",
"pr": {
"id": "9",
"title": "Missing return statement",
"description": "Function does not return value",
"language": "python",
"diffs": [
{
"file_name": "utils.py",
"diff": "def add(a, b):\n result = a + b"
}
]
},
"ground_truth": {
"issues": ["missing return statement"],
"decision": "reject",
"fix": "def add(a, b):\n result = a + b\n return result"
}
},
{
"task_type": "easy",
"pr": {
"id": "10",
"title": "Wrong comparison operator",
"description": "Fix equality check",
"language": "python",
"diffs": [
{
"file_name": "check.py",
"diff": "if x = 10:\n print('ten')"
}
]
},
"ground_truth": {
"issues": ["assignment instead of comparison"],
"decision": "reject",
"fix": "if x == 10:\n print('ten')"
}
},
{
"task_type": "easy",
"pr": {
"id": "11",
"title": "Undefined variable",
"description": "Variable used before assignment",
"language": "python",
"diffs": [
{
"file_name": "app.py",
"diff": "def greet():\n print(message)\n message = 'Hello'"
}
]
},
"ground_truth": {
"issues": ["undefined variable", "variable used before assignment"],
"decision": "reject",
"fix": "def greet():\n message = 'Hello'\n print(message)"
}
},
{
"task_type": "easy",
"pr": {
"id": "12",
"title": "Clean utility function",
"description": "Simple string helper",
"language": "python",
"diffs": [
{
"file_name": "utils.py",
"diff": "def to_upper(s):\n return s.upper()"
}
]
},
"ground_truth": {
"issues": [],
"decision": "approve",
"fix": ""
}
},
{
"task_type": "medium",
"pr": {
"id": "3",
"title": "Division function",
"description": "Handles division",
"language": "python",
"diffs": [
{
"file_name": "math.py",
"diff": "def divide(a,b): return a/b"
}
]
},
"ground_truth": {
"issues": ["division by zero"],
"decision": "reject",
"fix": "def divide(a, b):\n if b == 0:\n return None\n return a / b"
}
},
{
"task_type": "medium",
"pr": {
"id": "4",
"title": "Inefficient loop",
"description": "Optimizing search",
"language": "python",
"diffs": [
{
"file_name": "search.py",
"diff": "for i in range(len(arr)):\n if arr[i] == target:\n return True"
}
]
},
"ground_truth": {
"issues": ["inefficient loop"],
"decision": "approve",
"fix": "return target in arr"
}
},
{
"task_type": "medium",
"pr": {
"id": "13",
"title": "Mutable default argument",
"description": "Function with default list argument",
"language": "python",
"diffs": [
{
"file_name": "helper.py",
"diff": "def append_item(item, lst=[]):\n lst.append(item)\n return lst"
}
]
},
"ground_truth": {
"issues": ["mutable default argument"],
"decision": "reject",
"fix": "def append_item(item, lst=None):\n if lst is None:\n lst = []\n lst.append(item)\n return lst"
}
},
{
"task_type": "medium",
"pr": {
"id": "14",
"title": "Unhandled exception",
"description": "File read without error handling",
"language": "python",
"diffs": [
{
"file_name": "reader.py",
"diff": "def read_file(path):\n with open(path) as f:\n return f.read()"
}
]
},
"ground_truth": {
"issues": ["unhandled exception", "missing error handling"],
"decision": "reject",
"fix": "def read_file(path):\n try:\n with open(path) as f:\n return f.read()\n except FileNotFoundError:\n return None"
}
},
{
"task_type": "medium",
"pr": {
"id": "15",
"title": "Integer overflow risk",
"description": "Large number multiplication",
"language": "python",
"diffs": [
{
"file_name": "compute.py",
"diff": "def factorial(n):\n result = 1\n for i in range(1, n+1):\n result *= i\n return result"
}
]
},
"ground_truth": {
"issues": ["missing input validation"],
"decision": "reject",
"fix": "def factorial(n):\n if n < 0:\n raise ValueError('n must be non-negative')\n result = 1\n for i in range(1, n+1):\n result *= i\n return result"
}
},
{
"task_type": "hard",
"pr": {
"id": "6",
"title": "Authentication logic",
"description": "Adds login system",
"language": "python",
"diffs": [
{
"file_name": "auth.py",
"diff": "def login(password):\n if password == 'admin123':\n return True"
}
]
},
"ground_truth": {
"issues": ["hardcoded password", "security vulnerability"],
"decision": "reject",
"fix": "import bcrypt\n\ndef login(password, hashed_password):\n return bcrypt.checkpw(password.encode(), hashed_password)"
}
},
{
"task_type": "hard",
"pr": {
"id": "7",
"title": "SQL query issue",
"description": "Fetch user data",
"language": "python",
"diffs": [
{
"file_name": "db.py",
"diff": "query = \"SELECT * FROM users WHERE id = \" + user_id"
}
]
},
"ground_truth": {
"issues": ["sql injection"],
"decision": "reject",
"fix": "query = \"SELECT * FROM users WHERE id = %s\"\ncursor.execute(query, (user_id,))"
}
},
{
"task_type": "hard",
"pr": {
"id": "8",
"title": "Cross-file null bug",
"description": "User fetch logic",
"language": "python",
"diffs": [
{
"file_name": "service.py",
"diff": "def get_user(id):\n return db[id]"
},
{
"file_name": "controller.py",
"diff": "user = get_user(None)"
}
]
},
"ground_truth": {
"issues": ["invalid input", "null handling"],
"decision": "reject",
"fix": "def get_user(id):\n if id is None:\n raise ValueError('id must not be None')\n return db[id]\n\nuser = get_user(user_id)"
}
},
{
"task_type": "hard",
"pr": {
"id": "16",
"title": "Race condition in counter",
"description": "Shared counter increment",
"language": "python",
"diffs": [
{
"file_name": "counter.py",
"diff": "counter = 0\n\ndef increment():\n global counter\n counter += 1"
}
]
},
"ground_truth": {
"issues": ["race condition", "thread safety"],
"decision": "reject",
"fix": "import threading\n\ncounter = 0\nlock = threading.Lock()\n\ndef increment():\n global counter\n with lock:\n counter += 1"
}
},
{
"task_type": "hard",
"pr": {
"id": "17",
"title": "Insecure deserialization",
"description": "Load user data from request",
"language": "python",
"diffs": [
{
"file_name": "api.py",
"diff": "import pickle\n\ndef load_user(data):\n return pickle.loads(data)"
}
]
},
"ground_truth": {
"issues": ["insecure deserialization", "security vulnerability"],
"decision": "reject",
"fix": "import json\n\ndef load_user(data):\n return json.loads(data)"
}
},
{
"task_type": "hard",
"pr": {
"id": "18",
"title": "Path traversal vulnerability",
"description": "Serve user requested files",
"language": "python",
"diffs": [
{
"file_name": "files.py",
"diff": "def read_file(filename):\n with open('/var/data/' + filename) as f:\n return f.read()"
}
]
},
"ground_truth": {
"issues": ["path traversal", "security vulnerability"],
"decision": "reject",
"fix": "import os\n\ndef read_file(filename):\n base = '/var/data/'\n full_path = os.path.realpath(os.path.join(base, filename))\n if not full_path.startswith(base):\n raise ValueError('Invalid file path')\n with open(full_path) as f:\n return f.read()"
}
}
] |