Datasets:
Update non-Juliet-only dataset card, manifest, and pipeline
Browse files- README.md +1 -1
- prepare_openzeppelin.py +87 -0
README.md
CHANGED
|
@@ -59,4 +59,4 @@ OpenZeppelin Contracts v5.7.0 dan subset Juice Shop yang dipilih memakai MIT. Sa
|
|
| 59 |
|
| 60 |
## Reproduksi
|
| 61 |
|
| 62 |
-
`
|
|
|
|
| 59 |
|
| 60 |
## Reproduksi
|
| 61 |
|
| 62 |
+
Pipeline ini hanya mengambil sumber non-Juliet yang dipatok. Dari direktori rilis, jalankan `pip install -r requirements.txt`, lalu `python3 prepare_openzeppelin.py`, `python3 scrape_juice_shop.py`, dan `python3 build_release.py`. Hasil perantara ada di `staging/`, bukan bagian dari data final. Tautan sumber, lisensi, dan prosedur seleksi ada di `DATA_SOURCES.md`.
|
prepare_openzeppelin.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Fetch five MIT-marked OpenZeppelin Contracts v5.7.0 reference files."""
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import hashlib
|
| 6 |
+
import json
|
| 7 |
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
import requests
|
| 11 |
+
|
| 12 |
+
REPO = "OpenZeppelin/openzeppelin-contracts"
|
| 13 |
+
VERSION = "v5.7.0"
|
| 14 |
+
RAW = f"https://raw.githubusercontent.com/{REPO}/{VERSION}/"
|
| 15 |
+
FILES = [
|
| 16 |
+
("contracts/token/ERC20/ERC20.sol", "ERC20: fungible-token accounting and transfer/allowance interface"),
|
| 17 |
+
("contracts/access/Ownable.sol", "Ownable: single-owner access-control pattern"),
|
| 18 |
+
("contracts/access/AccessControl.sol", "AccessControl: role-based authorization primitives"),
|
| 19 |
+
("contracts/utils/ReentrancyGuard.sol", "ReentrancyGuard: explicit nonReentrant execution guard"),
|
| 20 |
+
("contracts/utils/Pausable.sol", "Pausable: emergency pause-state primitives; authorization must be supplied by integrating code"),
|
| 21 |
+
]
|
| 22 |
+
INSTRUCTION = "Gunakan berkas Solidity rujukan berikut untuk menjelaskan fungsi pola atau komponen yang disediakan. Bedakan kemampuan library dari jaminan keamanan seluruh sistem; jangan menganggap cuplikan ini sebagai audit atau aplikasi lengkap."
|
| 23 |
+
SELECTION = "Five specific Solidity files with SPDX-License-Identifier: MIT from the tagged OpenZeppelin Contracts v5.7.0 release."
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def fetch(path: str) -> bytes:
|
| 27 |
+
response = requests.get(RAW + path, timeout=45)
|
| 28 |
+
response.raise_for_status()
|
| 29 |
+
return response.content
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def sha256(data: bytes) -> str:
|
| 33 |
+
return hashlib.sha256(data).hexdigest()
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def main() -> None:
|
| 37 |
+
paths = [path for path, _ in FILES] + ["LICENSE"]
|
| 38 |
+
contents = {}
|
| 39 |
+
with ThreadPoolExecutor(max_workers=6) as pool:
|
| 40 |
+
futures = {pool.submit(fetch, path): path for path in paths}
|
| 41 |
+
for future in as_completed(futures):
|
| 42 |
+
contents[futures[future]] = future.result()
|
| 43 |
+
|
| 44 |
+
license_text = contents["LICENSE"].decode("utf-8", "replace")
|
| 45 |
+
if "Permission is hereby granted, free of charge" not in license_text:
|
| 46 |
+
raise RuntimeError("Pinned OpenZeppelin LICENSE did not match the MIT grant text")
|
| 47 |
+
Path("OPENZEPPELIN-MIT.txt").write_bytes(contents["LICENSE"])
|
| 48 |
+
|
| 49 |
+
records = []
|
| 50 |
+
for relpath, summary in FILES:
|
| 51 |
+
raw = contents[relpath]
|
| 52 |
+
code = raw.decode("utf-8")
|
| 53 |
+
if not code.startswith("// SPDX-License-Identifier: MIT"):
|
| 54 |
+
raise RuntimeError(f"Missing MIT SPDX header: {relpath}")
|
| 55 |
+
records.append({
|
| 56 |
+
"id": "openzeppelin-" + relpath.rsplit("/", 1)[-1].removesuffix(".sol").lower(),
|
| 57 |
+
"task_type": "secure_code_reference",
|
| 58 |
+
"domain": "smart_contract",
|
| 59 |
+
"language": "Solidity",
|
| 60 |
+
"instruction": INSTRUCTION,
|
| 61 |
+
"input": code,
|
| 62 |
+
"output": summary,
|
| 63 |
+
"source_file": relpath,
|
| 64 |
+
"source_version": VERSION,
|
| 65 |
+
"source_url": f"https://github.com/{REPO}/blob/{VERSION}/{relpath}",
|
| 66 |
+
"source_license": "MIT (SPDX identifier present in the source file; repository LICENSE included)",
|
| 67 |
+
"source_sha256": sha256(raw),
|
| 68 |
+
"selection_policy": SELECTION,
|
| 69 |
+
"split": "reference",
|
| 70 |
+
})
|
| 71 |
+
|
| 72 |
+
output = Path("staging/openzeppelin_solidity_references.jsonl")
|
| 73 |
+
output.parent.mkdir(parents=True, exist_ok=True)
|
| 74 |
+
with output.open("w", encoding="utf-8", newline="\n") as handle:
|
| 75 |
+
for row in sorted(records, key=lambda item: item["id"]):
|
| 76 |
+
handle.write(json.dumps(row, ensure_ascii=False, sort_keys=True) + "\n")
|
| 77 |
+
print(json.dumps({
|
| 78 |
+
"source": REPO,
|
| 79 |
+
"version": VERSION,
|
| 80 |
+
"records": len(records),
|
| 81 |
+
"output": str(output),
|
| 82 |
+
"license": "OPENZEPPELIN-MIT.txt",
|
| 83 |
+
}, ensure_ascii=False, indent=2))
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
if __name__ == "__main__":
|
| 87 |
+
main()
|