Spaces:
Running
Running
Nitish commited on
Commit ·
1f9ff11
1
Parent(s): 474eafa
refactor: calibrate scores for progression Easy > Medium > Hard
Browse files- server/tasks.py +33 -39
server/tasks.py
CHANGED
|
@@ -1,40 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
TASKS = {
|
| 2 |
"python-off-by-one": {
|
| 3 |
"id": "python-off-by-one",
|
| 4 |
"name": "Python Off-by-One Error",
|
| 5 |
"language": "Python",
|
| 6 |
"difficulty": "easy",
|
| 7 |
-
"bug_class": "Off-by-one
|
| 8 |
-
"pr_title": "
|
| 9 |
-
"file_path": "finance/
|
| 10 |
-
"context": "
|
| 11 |
"code_snippet": (
|
| 12 |
-
"def
|
| 13 |
" total = 0\n"
|
| 14 |
-
" for i in range(len(transactions) + 1):
|
| 15 |
-
" total += transactions[i]
|
| 16 |
" return total"
|
| 17 |
),
|
| 18 |
"bug_type": "off-by-one",
|
| 19 |
-
"bug_location": "line 3 — range(len(transactions) + 1)",
|
| 20 |
-
"severity": "
|
| 21 |
"keywords": [
|
| 22 |
-
"off-by-one", "index", "range", "
|
| 23 |
-
"
|
| 24 |
-
"
|
| 25 |
-
"fix", "bug", "identify", "code", "crash", "out-of-range",
|
| 26 |
-
"python", "finance", "batch", "amount", "total", "transactions",
|
| 27 |
-
"iterate", "sum", "loop", "account", "process"
|
| 28 |
],
|
| 29 |
"fix_patterns": [
|
| 30 |
"range(len(transactions))",
|
| 31 |
-
"len(transactions))",
|
| 32 |
-
"for transaction in transactions",
|
| 33 |
-
"in transactions:",
|
| 34 |
-
"pop()",
|
| 35 |
"enumerate(transactions)",
|
| 36 |
-
"transactions
|
| 37 |
-
"
|
|
|
|
| 38 |
],
|
| 39 |
},
|
| 40 |
|
|
@@ -43,10 +40,10 @@ TASKS = {
|
|
| 43 |
"name": "JavaScript Auth Logic Flaw",
|
| 44 |
"language": "JavaScript",
|
| 45 |
"difficulty": "medium",
|
| 46 |
-
"bug_class": "
|
| 47 |
-
"pr_title": "
|
| 48 |
"file_path": "middleware/auth.js",
|
| 49 |
-
"context": "Node.js
|
| 50 |
"code_snippet": (
|
| 51 |
"function checkAdmin(req, res, next) {\n"
|
| 52 |
" const user = req.user;\n"
|
|
@@ -57,16 +54,12 @@ TASKS = {
|
|
| 57 |
"}"
|
| 58 |
),
|
| 59 |
"bug_type": "logic-error",
|
| 60 |
-
"bug_location": "line 3 — incorrect boolean operator || instead of &&",
|
| 61 |
"severity": "critical",
|
| 62 |
"keywords": [
|
| 63 |
-
"
|
| 64 |
-
"
|
| 65 |
-
"
|
| 66 |
-
"authorization bypass disjunction logic", "improper validation layer check",
|
| 67 |
-
"role check disjunction pattern match", "permission leak evaluation flow",
|
| 68 |
-
"evaluation shortcut logic flaw", "middleware logic hazard state",
|
| 69 |
-
"security constraint bypass", "access control logic inversion"
|
| 70 |
],
|
| 71 |
"fix_patterns": [
|
| 72 |
"user.role === \"admin\" && user.isActive",
|
|
@@ -96,15 +89,16 @@ TASKS = {
|
|
| 96 |
"bug_location": "line 2 — f-string interpolation directly in SQL query",
|
| 97 |
"severity": "critical",
|
| 98 |
"keywords": [
|
| 99 |
-
"
|
| 100 |
-
"
|
| 101 |
-
"
|
| 102 |
],
|
| 103 |
"fix_patterns": [
|
| 104 |
-
"
|
| 105 |
-
"
|
| 106 |
-
"parameterized",
|
| 107 |
-
"
|
|
|
|
| 108 |
],
|
| 109 |
},
|
| 110 |
}
|
|
|
|
| 1 |
+
# OpenEnv Tasks for Code Security Review
|
| 2 |
+
# These tasks are designed to test AI agents' ability to identify common security vulnerabilities.
|
| 3 |
+
|
| 4 |
TASKS = {
|
| 5 |
"python-off-by-one": {
|
| 6 |
"id": "python-off-by-one",
|
| 7 |
"name": "Python Off-by-One Error",
|
| 8 |
"language": "Python",
|
| 9 |
"difficulty": "easy",
|
| 10 |
+
"bug_class": "Index Error / Off-by-one",
|
| 11 |
+
"pr_title": "Update finance batch processor for transactions",
|
| 12 |
+
"file_path": "finance/processor.py",
|
| 13 |
+
"context": "Process numeric transaction data for weekly reporting",
|
| 14 |
"code_snippet": (
|
| 15 |
+
"def calculate_total(transactions):\n"
|
| 16 |
" total = 0\n"
|
| 17 |
+
" for i in range(len(transactions) + 1):\n"
|
| 18 |
+
" total += transactions[i]\n"
|
| 19 |
" return total"
|
| 20 |
),
|
| 21 |
"bug_type": "off-by-one",
|
| 22 |
+
"bug_location": "line 3 — loop range(len(transactions) + 1) incorrectly iterates one past the end",
|
| 23 |
+
"severity": "medium",
|
| 24 |
"keywords": [
|
| 25 |
+
"off-by-one", "index", "error", "range", "length", "loop", "extra",
|
| 26 |
+
"out of bounds", "indexerror", "end", "one past", "terminates",
|
| 27 |
+
"iteration", "boundary", "array", "transactions", "last"
|
|
|
|
|
|
|
|
|
|
| 28 |
],
|
| 29 |
"fix_patterns": [
|
| 30 |
"range(len(transactions))",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
"enumerate(transactions)",
|
| 32 |
+
"for tx in transactions",
|
| 33 |
+
"len(transactions)",
|
| 34 |
+
"0, len(transactions)"
|
| 35 |
],
|
| 36 |
},
|
| 37 |
|
|
|
|
| 40 |
"name": "JavaScript Auth Logic Flaw",
|
| 41 |
"language": "JavaScript",
|
| 42 |
"difficulty": "medium",
|
| 43 |
+
"bug_class": "Privilege Escalation / Logic Flaw",
|
| 44 |
+
"pr_title": "Implement admin middleware for dashboard",
|
| 45 |
"file_path": "middleware/auth.js",
|
| 46 |
+
"context": "Node.js/Express middleware to restrict access to admin routes",
|
| 47 |
"code_snippet": (
|
| 48 |
"function checkAdmin(req, res, next) {\n"
|
| 49 |
" const user = req.user;\n"
|
|
|
|
| 54 |
"}"
|
| 55 |
),
|
| 56 |
"bug_type": "logic-error",
|
| 57 |
+
"bug_location": "line 3 — incorrect boolean operator || instead of && allows any active user",
|
| 58 |
"severity": "critical",
|
| 59 |
"keywords": [
|
| 60 |
+
"logic", "operator", "operator mistake", "boolean", "disjunction",
|
| 61 |
+
"escalation", "bypass", "checkAdmin", "admin", "role", "active",
|
| 62 |
+
"isActive", "should be and", "should be &&", "or", "security barrier"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
],
|
| 64 |
"fix_patterns": [
|
| 65 |
"user.role === \"admin\" && user.isActive",
|
|
|
|
| 89 |
"bug_location": "line 2 — f-string interpolation directly in SQL query",
|
| 90 |
"severity": "critical",
|
| 91 |
"keywords": [
|
| 92 |
+
"interpolated", "f-string", "format", "string", "concatenation",
|
| 93 |
+
"exfiltrate", "malicious", "union", "tautology", "attack",
|
| 94 |
+
"vulnerability", "sanitization", "validation", "parameterized", "query"
|
| 95 |
],
|
| 96 |
"fix_patterns": [
|
| 97 |
+
"execute(query, (search_term,))",
|
| 98 |
+
"bind variables",
|
| 99 |
+
"parameterized query",
|
| 100 |
+
"query parameters",
|
| 101 |
+
"DBAPI parameter"
|
| 102 |
],
|
| 103 |
},
|
| 104 |
}
|