Spaces:
Sleeping
Sleeping
File size: 650 Bytes
a448db8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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
)
|