codearena-rl / tasks /security_bugs /security_bug_1.py
havinashpatil
Complete all tasks: Adaptive curriculum, GRPO, React frontend, LLM-as-a-judge
a448db8
raw
history blame contribute delete
650 Bytes
from server.models import TaskInfo
TASK = TaskInfo(
task_id="security_bugs-1",
difficulty="security_bugs",
description="Fix the function to parse JSON safely without using eval().",
buggy_code="""import json
def parse_user_data(data_string):
return eval(data_string)""",
test_code="""
import unittest
import inspect
class TestSecurity1(unittest.TestCase):
def test_normal(self):
self.assertEqual(parse_user_data('{"name": "alice"}'), {"name": "alice"})
def test_security(self):
source = inspect.getsource(parse_user_data)
self.assertNotIn("eval(", source)
""",
optimal_time_seconds=0.05
)