Datasets:
Delete PrimeVul_original.py
Browse files- PrimeVul_original.py +0 -112
PrimeVul_original.py
DELETED
|
@@ -1,112 +0,0 @@
|
|
| 1 |
-
"""PrimeVul Original Test Dataset"""
|
| 2 |
-
|
| 3 |
-
import json
|
| 4 |
-
import pandas as pd
|
| 5 |
-
import datasets
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
_DESCRIPTION = """\
|
| 9 |
-
This dataset contains the original test split from the PrimeVul dataset, provided for reproducibility purposes.
|
| 10 |
-
The data is sourced from the paper "PrimeVul: Vulnerability Detection with Code Language Models: How Far Are We?"
|
| 11 |
-
and includes both the default (single functions) and paired (vulnerable/non-vulnerable pairs) configurations.
|
| 12 |
-
"""
|
| 13 |
-
|
| 14 |
-
_HOMEPAGE = "https://github.com/DLVulDet/PrimeVul"
|
| 15 |
-
|
| 16 |
-
_LICENSE = "See original repository"
|
| 17 |
-
|
| 18 |
-
_CITATION = """\
|
| 19 |
-
@article{primevul2024,
|
| 20 |
-
title={PrimeVul: Vulnerability Detection with Code Language Models: How Far Are We?},
|
| 21 |
-
author={[Authors from the original paper]},
|
| 22 |
-
journal={arXiv preprint arXiv:2403.18624},
|
| 23 |
-
year={2024},
|
| 24 |
-
url={https://arxiv.org/abs/2403.18624}
|
| 25 |
-
}
|
| 26 |
-
"""
|
| 27 |
-
|
| 28 |
-
_URLs = {
|
| 29 |
-
"default": "https://huggingface.co/datasets/Code-TREAT/PrimeVul_original/resolve/main/default/test.parquet",
|
| 30 |
-
"paired": "https://huggingface.co/datasets/Code-TREAT/PrimeVul_original/resolve/main/paired/test.parquet",
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
class PrimeVulOriginal(datasets.GeneratorBasedBuilder):
|
| 35 |
-
"""PrimeVul Original Test Dataset."""
|
| 36 |
-
|
| 37 |
-
VERSION = datasets.Version("1.0.0")
|
| 38 |
-
|
| 39 |
-
BUILDER_CONFIGS = [
|
| 40 |
-
datasets.BuilderConfig(
|
| 41 |
-
name="default",
|
| 42 |
-
version=VERSION,
|
| 43 |
-
description="Single function vulnerability detection dataset"
|
| 44 |
-
),
|
| 45 |
-
datasets.BuilderConfig(
|
| 46 |
-
name="paired",
|
| 47 |
-
version=VERSION,
|
| 48 |
-
description="Paired vulnerability detection dataset with before/after patch pairs"
|
| 49 |
-
),
|
| 50 |
-
]
|
| 51 |
-
|
| 52 |
-
DEFAULT_CONFIG_NAME = "default"
|
| 53 |
-
|
| 54 |
-
def _info(self):
|
| 55 |
-
if self.config.name == "default":
|
| 56 |
-
features = datasets.Features({
|
| 57 |
-
"project": datasets.Value("string"),
|
| 58 |
-
"commit_id": datasets.Value("string"),
|
| 59 |
-
"target": datasets.Value("int64"),
|
| 60 |
-
"func": datasets.Value("string"),
|
| 61 |
-
"cwe": datasets.Value("string"),
|
| 62 |
-
"big_vul_idx": datasets.Value("string"),
|
| 63 |
-
"idx": datasets.Value("int64"),
|
| 64 |
-
"hash": datasets.Value("string"),
|
| 65 |
-
"size": datasets.Value("int64"),
|
| 66 |
-
"message": datasets.Value("string"),
|
| 67 |
-
"dataset": datasets.Value("string"),
|
| 68 |
-
})
|
| 69 |
-
else: # paired
|
| 70 |
-
features = datasets.Features({
|
| 71 |
-
"idx": datasets.Value("int64"),
|
| 72 |
-
"project": datasets.Value("string"),
|
| 73 |
-
"commit_id": datasets.Value("string"),
|
| 74 |
-
"project_url": datasets.Value("string"),
|
| 75 |
-
"commit_url": datasets.Value("string"),
|
| 76 |
-
"commit_message": datasets.Value("string"),
|
| 77 |
-
"target": datasets.Value("int64"),
|
| 78 |
-
"func": datasets.Value("string"),
|
| 79 |
-
"func_hash": datasets.Value("string"),
|
| 80 |
-
"file_name": datasets.Value("string"),
|
| 81 |
-
"file_hash": datasets.Value("string"),
|
| 82 |
-
"cwe": datasets.Value("string"),
|
| 83 |
-
"cve": datasets.Value("string"),
|
| 84 |
-
"cve_desc": datasets.Value("string"),
|
| 85 |
-
"nvd_url": datasets.Value("string"),
|
| 86 |
-
})
|
| 87 |
-
|
| 88 |
-
return datasets.DatasetInfo(
|
| 89 |
-
description=_DESCRIPTION,
|
| 90 |
-
features=features,
|
| 91 |
-
homepage=_HOMEPAGE,
|
| 92 |
-
license=_LICENSE,
|
| 93 |
-
citation=_CITATION,
|
| 94 |
-
)
|
| 95 |
-
|
| 96 |
-
def _split_generators(self, dl_manager):
|
| 97 |
-
urls = _URLs[self.config.name]
|
| 98 |
-
data_file = dl_manager.download(urls)
|
| 99 |
-
|
| 100 |
-
return [
|
| 101 |
-
datasets.SplitGenerator(
|
| 102 |
-
name=datasets.Split.TEST,
|
| 103 |
-
gen_kwargs={
|
| 104 |
-
"filepath": data_file,
|
| 105 |
-
},
|
| 106 |
-
),
|
| 107 |
-
]
|
| 108 |
-
|
| 109 |
-
def _generate_examples(self, filepath):
|
| 110 |
-
df = pd.read_parquet(filepath)
|
| 111 |
-
for idx, row in df.iterrows():
|
| 112 |
-
yield idx, row.to_dict()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|