mwritescode commited on
Commit
27b5d75
1 Parent(s): 22b288d

Added dataset loading script and dataset infos

Browse files
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"all-plain-text": {"description": "This dataset contains source code and deployed bytecode for Solidity Smart Contracts that have been verified on Etherscan.io, along with a classification of their vulnerabilities according to the Slither static analysis framework.\n", "citation": "@misc{rossini2022slitherauditedcontracts,\n title = {Slither Audited Smart Contracts Dataset},\n author={Martina Rossini},\n year={2022}\n}\n", "homepage": "https://github.com/mwritescode/slither-audited-smart-contracts", "license": "MIT", "features": {"address": {"dtype": "string", "id": null, "_type": "Value"}, "source_code": {"dtype": "string", "id": null, "_type": "Value"}, "bytecode": {"dtype": "string", "id": null, "_type": "Value"}, "slither": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "slither_audited_smart_contracts", "config_name": "all-plain-text", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 5363539272, "num_examples": 120608, "dataset_name": "slither_audited_smart_contracts"}}, "download_checksums": {"data/raw/contracts0.parquet": {"num_bytes": 202691140, "checksum": "d8f83dfa0a506f6975663075a5dab3726588d27917eb9f2dfa29344264fcef20"}, "data/raw/contracts1.parquet": {"num_bytes": 196756032, "checksum": "bb968d8609db6bf5673055c0444113484758cceb9002ebbcbdb56da501f91370"}, "data/raw/contracts2.parquet": {"num_bytes": 192828480, "checksum": "6f6d9845994239487f350402405a4d06768fb96503db2d9701b745b4cb07d133"}, "data/raw/contracts3.parquet": {"num_bytes": 224449142, "checksum": "06a8a91bdf60b4f1b0d3ba7d4c69d029b98b4ac4c455e5423f89b44e9e12fad7"}, "data/raw/contracts4.parquet": {"num_bytes": 227432088, "checksum": "a33708f15c32a753fbac2e150034ff9cc6d014ec1db274f07b273935bba6d9b2"}, "data/raw/contracts5.parquet": {"num_bytes": 231552826, "checksum": "1f09da430b487b1b6b4e32d8f53f1dafee62ea91fcad990349efb910f2e2d424"}, "data/raw/contracts6.parquet": {"num_bytes": 230186733, "checksum": "003e3c3a0f67ee495bc255c775f911529523d969ff2d402b6a1ce9b5b90066f5"}, "data/raw/contracts7.parquet": {"num_bytes": 233402915, "checksum": "688a3efa91ddda9eaa07ef1f3b68c3f6f64e004ccbfa01c684d890978c8bb054"}, "data/raw/contracts8.parquet": {"num_bytes": 4038839, "checksum": "6dadf447862ba30965af3cb97c2e28e0f691c67a6dd7c526ab69e42f9a00b145"}, "data/label_mappings.json": {"num_bytes": 1261, "checksum": "4d8dec3f8cfd0b573309248d4899be0ed651ff9648ee77e8b0a90a429b6d8e39"}, "data/big-splits.csv": {"num_bytes": 5073075, "checksum": "f85d695fa0244d1db9a20fdae0139b70e8b7f425b2322f633653bbefb18ee1a8"}, "data/small-splits.csv": {"num_bytes": 673444, "checksum": "2c10a8e2133466476773bf57ca70517f6355721d9b6fa99a834cdd9c4d4e0e4b"}}, "download_size": 1749085975, "post_processing_size": null, "dataset_size": 5363539272, "size_in_bytes": 7112625247}, "all-multilabel": {"description": "This dataset contains source code and deployed bytecode for Solidity Smart Contracts that have been verified on Etherscan.io, along with a classification of their vulnerabilities according to the Slither static analysis framework.\n", "citation": "@misc{rossini2022slitherauditedcontracts,\n title = {Slither Audited Smart Contracts Dataset},\n author={Martina Rossini},\n year={2022}\n}\n", "homepage": "https://github.com/mwritescode/slither-audited-smart-contracts", "license": "MIT", "features": {"address": {"dtype": "string", "id": null, "_type": "Value"}, "source_code": {"dtype": "string", "id": null, "_type": "Value"}, "bytecode": {"dtype": "string", "id": null, "_type": "Value"}, "slither": {"feature": {"num_classes": 39, "names": ["uninitialized-state", "constant-function-asm", "locked-ether", "incorrect-shift", "divide-before-multiply", "unused-return", "write-after-write", "reentrancy-no-eth", "unchecked-lowlevel", "incorrect-equality", "weak-prng", "arbitrary-send", "uninitialized-local", "reentrancy-eth", "shadowing-abstract", "controlled-delegatecall", "unchecked-transfer", "erc20-interface", "controlled-array-length", "tautology", "shadowing-state", "tx-origin", "unprotected-upgrade", "suicidal", "boolean-cst", "unchecked-send", "msg-value-loop", "erc721-interface", "constant-function-state", "delegatecall-loop", "mapping-deletion", "reused-constructor", "uninitialized-storage", "public-mappings-nested", "array-by-reference", "backdoor", "rtlo", "name-reused", "safe"], "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "slither_audited_smart_contracts", "config_name": "all-multilabel", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 5343571406, "num_examples": 120608, "dataset_name": "slither_audited_smart_contracts"}}, "download_checksums": {"data/raw/contracts0.parquet": {"num_bytes": 202691140, "checksum": "d8f83dfa0a506f6975663075a5dab3726588d27917eb9f2dfa29344264fcef20"}, "data/raw/contracts1.parquet": {"num_bytes": 196756032, "checksum": "bb968d8609db6bf5673055c0444113484758cceb9002ebbcbdb56da501f91370"}, "data/raw/contracts2.parquet": {"num_bytes": 192828480, "checksum": "6f6d9845994239487f350402405a4d06768fb96503db2d9701b745b4cb07d133"}, "data/raw/contracts3.parquet": {"num_bytes": 224449142, "checksum": "06a8a91bdf60b4f1b0d3ba7d4c69d029b98b4ac4c455e5423f89b44e9e12fad7"}, "data/raw/contracts4.parquet": {"num_bytes": 227432088, "checksum": "a33708f15c32a753fbac2e150034ff9cc6d014ec1db274f07b273935bba6d9b2"}, "data/raw/contracts5.parquet": {"num_bytes": 231552826, "checksum": "1f09da430b487b1b6b4e32d8f53f1dafee62ea91fcad990349efb910f2e2d424"}, "data/raw/contracts6.parquet": {"num_bytes": 230186733, "checksum": "003e3c3a0f67ee495bc255c775f911529523d969ff2d402b6a1ce9b5b90066f5"}, "data/raw/contracts7.parquet": {"num_bytes": 233402915, "checksum": "688a3efa91ddda9eaa07ef1f3b68c3f6f64e004ccbfa01c684d890978c8bb054"}, "data/raw/contracts8.parquet": {"num_bytes": 4038839, "checksum": "6dadf447862ba30965af3cb97c2e28e0f691c67a6dd7c526ab69e42f9a00b145"}, "data/label_mappings.json": {"num_bytes": 1261, "checksum": "4d8dec3f8cfd0b573309248d4899be0ed651ff9648ee77e8b0a90a429b6d8e39"}, "data/big-splits.csv": {"num_bytes": 5073075, "checksum": "f85d695fa0244d1db9a20fdae0139b70e8b7f425b2322f633653bbefb18ee1a8"}, "data/small-splits.csv": {"num_bytes": 673444, "checksum": "2c10a8e2133466476773bf57ca70517f6355721d9b6fa99a834cdd9c4d4e0e4b"}}, "download_size": 1749085975, "post_processing_size": null, "dataset_size": 5343571406, "size_in_bytes": 7092657381}, "big-plain-text": {"description": "This dataset contains source code and deployed bytecode for Solidity Smart Contracts that have been verified on Etherscan.io, along with a classification of their vulnerabilities according to the Slither static analysis framework.\n", "citation": "@misc{rossini2022slitherauditedcontracts,\n title = {Slither Audited Smart Contracts Dataset},\n author={Martina Rossini},\n year={2022}\n}\n", "homepage": "https://github.com/mwritescode/slither-audited-smart-contracts", "license": "MIT", "features": {"address": {"dtype": "string", "id": null, "_type": "Value"}, "source_code": {"dtype": "string", "id": null, "_type": "Value"}, "bytecode": {"dtype": "string", "id": null, "_type": "Value"}, "slither": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "slither_audited_smart_contracts", "config_name": "big-plain-text", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 3542030395, "num_examples": 79641, "dataset_name": "slither_audited_smart_contracts"}, "test": {"name": "test", "num_bytes": 703749699, "num_examples": 15972, "dataset_name": "slither_audited_smart_contracts"}, "validation": {"name": "validation", "num_bytes": 480889962, "num_examples": 10861, "dataset_name": "slither_audited_smart_contracts"}}, "download_checksums": {"data/raw/contracts0.parquet": {"num_bytes": 202691140, "checksum": "d8f83dfa0a506f6975663075a5dab3726588d27917eb9f2dfa29344264fcef20"}, "data/raw/contracts1.parquet": {"num_bytes": 196756032, "checksum": "bb968d8609db6bf5673055c0444113484758cceb9002ebbcbdb56da501f91370"}, "data/raw/contracts2.parquet": {"num_bytes": 192828480, "checksum": "6f6d9845994239487f350402405a4d06768fb96503db2d9701b745b4cb07d133"}, "data/raw/contracts3.parquet": {"num_bytes": 224449142, "checksum": "06a8a91bdf60b4f1b0d3ba7d4c69d029b98b4ac4c455e5423f89b44e9e12fad7"}, "data/raw/contracts4.parquet": {"num_bytes": 227432088, "checksum": "a33708f15c32a753fbac2e150034ff9cc6d014ec1db274f07b273935bba6d9b2"}, "data/raw/contracts5.parquet": {"num_bytes": 231552826, "checksum": "1f09da430b487b1b6b4e32d8f53f1dafee62ea91fcad990349efb910f2e2d424"}, "data/raw/contracts6.parquet": {"num_bytes": 230186733, "checksum": "003e3c3a0f67ee495bc255c775f911529523d969ff2d402b6a1ce9b5b90066f5"}, "data/raw/contracts7.parquet": {"num_bytes": 233402915, "checksum": "688a3efa91ddda9eaa07ef1f3b68c3f6f64e004ccbfa01c684d890978c8bb054"}, "data/raw/contracts8.parquet": {"num_bytes": 4038839, "checksum": "6dadf447862ba30965af3cb97c2e28e0f691c67a6dd7c526ab69e42f9a00b145"}, "data/label_mappings.json": {"num_bytes": 1261, "checksum": "4d8dec3f8cfd0b573309248d4899be0ed651ff9648ee77e8b0a90a429b6d8e39"}, "data/big-splits.csv": {"num_bytes": 5073075, "checksum": "f85d695fa0244d1db9a20fdae0139b70e8b7f425b2322f633653bbefb18ee1a8"}, "data/small-splits.csv": {"num_bytes": 673444, "checksum": "2c10a8e2133466476773bf57ca70517f6355721d9b6fa99a834cdd9c4d4e0e4b"}}, "download_size": 1749085975, "post_processing_size": null, "dataset_size": 4726670056, "size_in_bytes": 6475756031}, "big-multilabel": {"description": "This dataset contains source code and deployed bytecode for Solidity Smart Contracts that have been verified on Etherscan.io, along with a classification of their vulnerabilities according to the Slither static analysis framework.\n", "citation": "@misc{rossini2022slitherauditedcontracts,\n title = {Slither Audited Smart Contracts Dataset},\n author={Martina Rossini},\n year={2022}\n}\n", "homepage": "https://github.com/mwritescode/slither-audited-smart-contracts", "license": "MIT", "features": {"address": {"dtype": "string", "id": null, "_type": "Value"}, "source_code": {"dtype": "string", "id": null, "_type": "Value"}, "bytecode": {"dtype": "string", "id": null, "_type": "Value"}, "slither": {"feature": {"num_classes": 6, "names": ["access-control", "arithmetic", "other", "reentrancy", "safe", "unchecked-calls"], "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "slither_audited_smart_contracts", "config_name": "big-multilabel", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 3528952557, "num_examples": 79641, "dataset_name": "slither_audited_smart_contracts"}, "test": {"name": "test", "num_bytes": 701135745, "num_examples": 15972, "dataset_name": "slither_audited_smart_contracts"}, "validation": {"name": "validation", "num_bytes": 479113059, "num_examples": 10861, "dataset_name": "slither_audited_smart_contracts"}}, "download_checksums": {"data/raw/contracts0.parquet": {"num_bytes": 202691140, "checksum": "d8f83dfa0a506f6975663075a5dab3726588d27917eb9f2dfa29344264fcef20"}, "data/raw/contracts1.parquet": {"num_bytes": 196756032, "checksum": "bb968d8609db6bf5673055c0444113484758cceb9002ebbcbdb56da501f91370"}, "data/raw/contracts2.parquet": {"num_bytes": 192828480, "checksum": "6f6d9845994239487f350402405a4d06768fb96503db2d9701b745b4cb07d133"}, "data/raw/contracts3.parquet": {"num_bytes": 224449142, "checksum": "06a8a91bdf60b4f1b0d3ba7d4c69d029b98b4ac4c455e5423f89b44e9e12fad7"}, "data/raw/contracts4.parquet": {"num_bytes": 227432088, "checksum": "a33708f15c32a753fbac2e150034ff9cc6d014ec1db274f07b273935bba6d9b2"}, "data/raw/contracts5.parquet": {"num_bytes": 231552826, "checksum": "1f09da430b487b1b6b4e32d8f53f1dafee62ea91fcad990349efb910f2e2d424"}, "data/raw/contracts6.parquet": {"num_bytes": 230186733, "checksum": "003e3c3a0f67ee495bc255c775f911529523d969ff2d402b6a1ce9b5b90066f5"}, "data/raw/contracts7.parquet": {"num_bytes": 233402915, "checksum": "688a3efa91ddda9eaa07ef1f3b68c3f6f64e004ccbfa01c684d890978c8bb054"}, "data/raw/contracts8.parquet": {"num_bytes": 4038839, "checksum": "6dadf447862ba30965af3cb97c2e28e0f691c67a6dd7c526ab69e42f9a00b145"}, "data/label_mappings.json": {"num_bytes": 1261, "checksum": "4d8dec3f8cfd0b573309248d4899be0ed651ff9648ee77e8b0a90a429b6d8e39"}, "data/big-splits.csv": {"num_bytes": 5073075, "checksum": "f85d695fa0244d1db9a20fdae0139b70e8b7f425b2322f633653bbefb18ee1a8"}, "data/small-splits.csv": {"num_bytes": 673444, "checksum": "2c10a8e2133466476773bf57ca70517f6355721d9b6fa99a834cdd9c4d4e0e4b"}}, "download_size": 1749085975, "post_processing_size": null, "dataset_size": 4709201361, "size_in_bytes": 6458287336}, "small-plain-text": {"description": "This dataset contains source code and deployed bytecode for Solidity Smart Contracts that have been verified on Etherscan.io, along with a classification of their vulnerabilities according to the Slither static analysis framework.\n", "citation": "@misc{rossini2022slitherauditedcontracts,\n title = {Slither Audited Smart Contracts Dataset},\n author={Martina Rossini},\n year={2022}\n}\n", "homepage": "https://github.com/mwritescode/slither-audited-smart-contracts", "license": "MIT", "features": {"address": {"dtype": "string", "id": null, "_type": "Value"}, "source_code": {"dtype": "string", "id": null, "_type": "Value"}, "bytecode": {"dtype": "string", "id": null, "_type": "Value"}, "slither": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "slither_audited_smart_contracts", "config_name": "small-plain-text", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 474498392, "num_examples": 10571, "dataset_name": "slither_audited_smart_contracts"}, "test": {"name": "test", "num_bytes": 92280813, "num_examples": 2121, "dataset_name": "slither_audited_smart_contracts"}, "validation": {"name": "validation", "num_bytes": 70090011, "num_examples": 1442, "dataset_name": "slither_audited_smart_contracts"}}, "download_checksums": {"data/raw/contracts0.parquet": {"num_bytes": 202691140, "checksum": "d8f83dfa0a506f6975663075a5dab3726588d27917eb9f2dfa29344264fcef20"}, "data/raw/contracts1.parquet": {"num_bytes": 196756032, "checksum": "bb968d8609db6bf5673055c0444113484758cceb9002ebbcbdb56da501f91370"}, "data/raw/contracts2.parquet": {"num_bytes": 192828480, "checksum": "6f6d9845994239487f350402405a4d06768fb96503db2d9701b745b4cb07d133"}, "data/raw/contracts3.parquet": {"num_bytes": 224449142, "checksum": "06a8a91bdf60b4f1b0d3ba7d4c69d029b98b4ac4c455e5423f89b44e9e12fad7"}, "data/raw/contracts4.parquet": {"num_bytes": 227432088, "checksum": "a33708f15c32a753fbac2e150034ff9cc6d014ec1db274f07b273935bba6d9b2"}, "data/raw/contracts5.parquet": {"num_bytes": 231552826, "checksum": "1f09da430b487b1b6b4e32d8f53f1dafee62ea91fcad990349efb910f2e2d424"}, "data/raw/contracts6.parquet": {"num_bytes": 230186733, "checksum": "003e3c3a0f67ee495bc255c775f911529523d969ff2d402b6a1ce9b5b90066f5"}, "data/raw/contracts7.parquet": {"num_bytes": 233402915, "checksum": "688a3efa91ddda9eaa07ef1f3b68c3f6f64e004ccbfa01c684d890978c8bb054"}, "data/raw/contracts8.parquet": {"num_bytes": 4038839, "checksum": "6dadf447862ba30965af3cb97c2e28e0f691c67a6dd7c526ab69e42f9a00b145"}, "data/label_mappings.json": {"num_bytes": 1261, "checksum": "4d8dec3f8cfd0b573309248d4899be0ed651ff9648ee77e8b0a90a429b6d8e39"}, "data/big-splits.csv": {"num_bytes": 5073075, "checksum": "f85d695fa0244d1db9a20fdae0139b70e8b7f425b2322f633653bbefb18ee1a8"}, "data/small-splits.csv": {"num_bytes": 673444, "checksum": "2c10a8e2133466476773bf57ca70517f6355721d9b6fa99a834cdd9c4d4e0e4b"}}, "download_size": 1749085975, "post_processing_size": null, "dataset_size": 636869216, "size_in_bytes": 2385955191}, "small-multilabel": {"description": "This dataset contains source code and deployed bytecode for Solidity Smart Contracts that have been verified on Etherscan.io, along with a classification of their vulnerabilities according to the Slither static analysis framework.\n", "citation": "@misc{rossini2022slitherauditedcontracts,\n title = {Slither Audited Smart Contracts Dataset},\n author={Martina Rossini},\n year={2022}\n}\n", "homepage": "https://github.com/mwritescode/slither-audited-smart-contracts", "license": "MIT", "features": {"address": {"dtype": "string", "id": null, "_type": "Value"}, "source_code": {"dtype": "string", "id": null, "_type": "Value"}, "bytecode": {"dtype": "string", "id": null, "_type": "Value"}, "slither": {"feature": {"num_classes": 9, "names": ["access-control", "arithmetic", "other", "reentrancy", "safe", "unchecked-calls", "locked-ether", "bad-randomness", "double-spending"], "id": null, "_type": "ClassLabel"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "slither_audited_smart_contracts", "config_name": "small-multilabel", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 472439497, "num_examples": 10571, "dataset_name": "slither_audited_smart_contracts"}, "test": {"name": "test", "num_bytes": 91870689, "num_examples": 2121, "dataset_name": "slither_audited_smart_contracts"}, "validation": {"name": "validation", "num_bytes": 69801307, "num_examples": 1442, "dataset_name": "slither_audited_smart_contracts"}}, "download_checksums": {"data/raw/contracts0.parquet": {"num_bytes": 202691140, "checksum": "d8f83dfa0a506f6975663075a5dab3726588d27917eb9f2dfa29344264fcef20"}, "data/raw/contracts1.parquet": {"num_bytes": 196756032, "checksum": "bb968d8609db6bf5673055c0444113484758cceb9002ebbcbdb56da501f91370"}, "data/raw/contracts2.parquet": {"num_bytes": 192828480, "checksum": "6f6d9845994239487f350402405a4d06768fb96503db2d9701b745b4cb07d133"}, "data/raw/contracts3.parquet": {"num_bytes": 224449142, "checksum": "06a8a91bdf60b4f1b0d3ba7d4c69d029b98b4ac4c455e5423f89b44e9e12fad7"}, "data/raw/contracts4.parquet": {"num_bytes": 227432088, "checksum": "a33708f15c32a753fbac2e150034ff9cc6d014ec1db274f07b273935bba6d9b2"}, "data/raw/contracts5.parquet": {"num_bytes": 231552826, "checksum": "1f09da430b487b1b6b4e32d8f53f1dafee62ea91fcad990349efb910f2e2d424"}, "data/raw/contracts6.parquet": {"num_bytes": 230186733, "checksum": "003e3c3a0f67ee495bc255c775f911529523d969ff2d402b6a1ce9b5b90066f5"}, "data/raw/contracts7.parquet": {"num_bytes": 233402915, "checksum": "688a3efa91ddda9eaa07ef1f3b68c3f6f64e004ccbfa01c684d890978c8bb054"}, "data/raw/contracts8.parquet": {"num_bytes": 4038839, "checksum": "6dadf447862ba30965af3cb97c2e28e0f691c67a6dd7c526ab69e42f9a00b145"}, "data/label_mappings.json": {"num_bytes": 1261, "checksum": "4d8dec3f8cfd0b573309248d4899be0ed651ff9648ee77e8b0a90a429b6d8e39"}, "data/big-splits.csv": {"num_bytes": 5073075, "checksum": "f85d695fa0244d1db9a20fdae0139b70e8b7f425b2322f633653bbefb18ee1a8"}, "data/small-splits.csv": {"num_bytes": 673444, "checksum": "2c10a8e2133466476773bf57ca70517f6355721d9b6fa99a834cdd9c4d4e0e4b"}}, "download_size": 1749085975, "post_processing_size": null, "dataset_size": 634111493, "size_in_bytes": 2383197468}}
slither-audited-smart-contracts.py ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Dataset of Slither audited Solidity Smart Contracts."""
16
+
17
+ import json
18
+
19
+ import datasets
20
+ import pandas as pd
21
+
22
+ _LABELS = {
23
+ 'all': [
24
+ 'uninitialized-state','constant-function-asm', 'locked-ether',
25
+ 'incorrect-shift', 'divide-before-multiply', 'unused-return',
26
+ 'write-after-write', 'reentrancy-no-eth', 'unchecked-lowlevel',
27
+ 'incorrect-equality', 'weak-prng', 'arbitrary-send',
28
+ 'uninitialized-local', 'reentrancy-eth', 'shadowing-abstract',
29
+ 'controlled-delegatecall', 'unchecked-transfer', 'erc20-interface',
30
+ 'controlled-array-length', 'tautology', 'shadowing-state',
31
+ 'tx-origin', 'unprotected-upgrade', 'suicidal',
32
+ 'boolean-cst', 'unchecked-send', 'msg-value-loop',
33
+ 'erc721-interface', 'constant-function-state', 'delegatecall-loop',
34
+ 'mapping-deletion', 'reused-constructor', 'uninitialized-storage',
35
+ 'public-mappings-nested', 'array-by-reference','backdoor',
36
+ 'rtlo', 'name-reused','safe'],
37
+ 'big': ['access-control', 'arithmetic', 'other', 'reentrancy', 'safe', 'unchecked-calls'],
38
+ 'small': ['access-control', 'arithmetic', 'other', 'reentrancy', 'safe', 'unchecked-calls', 'locked-ether', 'bad-randomness', 'double-spending']
39
+ }
40
+
41
+
42
+ _CITATION = """\
43
+ @misc{rossini2022slitherauditedcontracts,
44
+ title = {Slither Audited Smart Contracts Dataset},
45
+ author={Martina Rossini},
46
+ year={2022}
47
+ }
48
+ """
49
+
50
+
51
+ _DESCRIPTION = """\
52
+ This dataset contains source code and deployed bytecode for Solidity Smart Contracts \
53
+ that have been verified on Etherscan.io, along with a classification of their vulnerabilities \
54
+ according to the Slither static analysis framework.
55
+ """
56
+
57
+ _HOMEPAGE = "https://github.com/mwritescode/slither-audited-smart-contracts"
58
+
59
+ _LICENSE = "MIT"
60
+
61
+
62
+ _URLS = {
63
+ "raw": [f"data/raw/contracts{i}.parquet" for i in range(9)],
64
+ "label_mappings": "data/label_mappings.json",
65
+ "big-splits": "data/big-splits.csv",
66
+ "small-splits": "data/small-splits.csv"
67
+ }
68
+
69
+
70
+ class SlitherAuditedSmartContracts(datasets.GeneratorBasedBuilder):
71
+ """Slither Audited Smart Contracts dataset, including source code and deployed bytecode"""
72
+
73
+ VERSION = datasets.Version("1.1.0")
74
+
75
+ # You will be able to load one or the other configurations in the following list with
76
+ # data = datasets.load_dataset('slither-audited-smart-contracts', 'all-plain-text')
77
+ BUILDER_CONFIGS = [
78
+ datasets.BuilderConfig(name="all-plain-text", version=VERSION, description="Complete dataset with plain-text slither results"),
79
+ datasets.BuilderConfig(name="all-multilabel", version=VERSION, description="Complete dataset with slither results as sequence of labels"),
80
+ datasets.BuilderConfig(name="big-plain-text", version=VERSION, description="Dataset containing only labels having numerous examples with plain-text slither results"),
81
+ datasets.BuilderConfig(name="big-multilabel", version=VERSION, description="Dataset containing only labels having numerous examples with slither results as a sequence of labels"),
82
+ datasets.BuilderConfig(name="small-plain-text", version=VERSION, description="Dataset containing only labels having few examples with plain-text slither results"),
83
+ datasets.BuilderConfig(name="small-multilabel", version=VERSION, description="Dataset containing only labels having few examples with slither results as a sequence of labels")
84
+ ]
85
+
86
+ def _info(self):
87
+ if "plain-text" in self.config.name:
88
+ features = datasets.Features(
89
+ {
90
+ "address": datasets.Value("string"),
91
+ "source_code": datasets.Value("string"),
92
+ "bytecode": datasets.Value("string"),
93
+ "slither": datasets.Value("string"),
94
+ }
95
+ )
96
+ else:
97
+ features = datasets.Features(
98
+ {
99
+ "address": datasets.Value("string"),
100
+ "source_code": datasets.Value("string"),
101
+ "bytecode": datasets.Value("string"),
102
+ "slither": datasets.Sequence(
103
+ datasets.features.ClassLabel(
104
+ names=_LABELS[self.config.name.split('-')[0]]
105
+ )
106
+ )
107
+
108
+ }
109
+ )
110
+ return datasets.DatasetInfo(
111
+ description=_DESCRIPTION,
112
+ features=features,
113
+ homepage=_HOMEPAGE,
114
+ license=_LICENSE,
115
+ citation=_CITATION,
116
+ )
117
+
118
+ def _split_generators(self, dl_manager):
119
+ data_dir = dl_manager.download_and_extract(_URLS)
120
+
121
+ generators = [
122
+ datasets.SplitGenerator(
123
+ name=datasets.Split.TRAIN,
124
+ gen_kwargs={
125
+ "filepath": data_dir,
126
+ "split": "train"
127
+ },
128
+ )]
129
+ if self.config.name.split('-')[0] != 'all':
130
+ generators += [
131
+ datasets.SplitGenerator(
132
+ name=datasets.Split.TEST,
133
+ gen_kwargs={
134
+ "filepath": data_dir,
135
+ "split": "test"
136
+ },
137
+ ),
138
+ datasets.SplitGenerator(
139
+ name=datasets.Split.VALIDATION,
140
+ gen_kwargs={
141
+ "filepath": data_dir,
142
+ "split": "val"
143
+ },
144
+ )]
145
+ return generators
146
+
147
+ def __elaborate_results(self, slither_res, mappings):
148
+ if not slither_res["results"]:
149
+ contract_class = ["safe"]
150
+ else:
151
+ contract_class = [elem["check"] for elem in slither_res["results"]["detectors"]]
152
+ if self.config.name.split('-')[0] != 'all':
153
+ with open(mappings, 'r') as mappings_file:
154
+ class_mappings = json.load(mappings_file)
155
+ contract_class = list(set([class_mappings[cls] for cls in contract_class]) - {'ignore'})
156
+ if len(contract_class) == 0:
157
+ contract_class = ['safe']
158
+ return contract_class
159
+
160
+
161
+ def _generate_examples(self, filepath, split):
162
+ prefix = self.config.name.split('-')[0]
163
+ split_file = filepath[f"{prefix}-splits"] if prefix != 'all' else None
164
+
165
+ for chunk in filepath['raw']:
166
+ data = pd.read_parquet(chunk)
167
+ if split_file:
168
+ split_addrs = pd.read_csv(split_file).query('split == @split')['contracts']
169
+ data = data[data['contracts'].isin(split_addrs)]
170
+
171
+ for idx, row in data.iterrows():
172
+ if 'plain-text' in self.config.name:
173
+ yield idx, {
174
+ "address": row['contracts'],
175
+ "source_code": row['source_code'],
176
+ "bytecode": row['bytecode'],
177
+ "slither": row['results'],
178
+ }
179
+ else:
180
+ slither = json.loads(row['results'])
181
+ contract_classes = self.__elaborate_results(slither, filepath['label_mappings'])
182
+ yield idx, {
183
+ "address": row['contracts'],
184
+ "source_code": row['source_code'],
185
+ "bytecode": row['bytecode'],
186
+ "slither": contract_classes,
187
+ }