Datasets:
Upload PrimeVul Original test dataset
Browse files- PrimeVul_original.py +112 -0
- README.md +98 -3
- dataset_infos.json +128 -0
- default/test.parquet +3 -0
- paired/test.parquet +3 -0
- requirements.txt +4 -0
- verify_dataset.py +139 -0
PrimeVul_original.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|
README.md
CHANGED
|
@@ -1,3 +1,98 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PrimeVul Original Test Dataset
|
| 2 |
+
|
| 3 |
+
## Overview
|
| 4 |
+
|
| 5 |
+
This dataset contains the original test split from the PrimeVul dataset, provided for reproducibility purposes. The data is sourced from the paper "PrimeVul: Vulnerability Detection with Code Language Models: How Far Are We?" and includes both the default (single functions) and paired (vulnerable/non-vulnerable pairs) configurations.
|
| 6 |
+
|
| 7 |
+
## Citation
|
| 8 |
+
|
| 9 |
+
If you use this dataset, please cite the original PrimeVul paper:
|
| 10 |
+
|
| 11 |
+
```bibtex
|
| 12 |
+
@article{primevul2024,
|
| 13 |
+
title={PrimeVul: Vulnerability Detection with Code Language Models: How Far Are We?},
|
| 14 |
+
author={[Authors from the original paper]},
|
| 15 |
+
journal={arXiv preprint arXiv:2403.18624},
|
| 16 |
+
year={2024},
|
| 17 |
+
url={https://arxiv.org/abs/2403.18624}
|
| 18 |
+
}
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
## Dataset Configurations
|
| 22 |
+
|
| 23 |
+
### `default`
|
| 24 |
+
- **Description**: Single function vulnerability detection dataset
|
| 25 |
+
- **Size**: 25,911 test samples
|
| 26 |
+
- **Format**: Each sample contains a single code function with binary vulnerability label
|
| 27 |
+
- **Fields**:
|
| 28 |
+
- `project`: Source project name
|
| 29 |
+
- `commit_id`: Git commit hash
|
| 30 |
+
- `target`: Binary label (0=non-vulnerable, 1=vulnerable)
|
| 31 |
+
- `func`: Source code function
|
| 32 |
+
- `cwe`: Common Weakness Enumeration categories
|
| 33 |
+
- `idx`: Unique sample identifier
|
| 34 |
+
- `hash`: Function hash
|
| 35 |
+
- Additional metadata fields
|
| 36 |
+
|
| 37 |
+
### `paired`
|
| 38 |
+
- **Description**: Paired vulnerability detection dataset with before/after patch pairs
|
| 39 |
+
- **Size**: 870 test samples
|
| 40 |
+
- **Format**: Each sample represents either the vulnerable or patched version of a function
|
| 41 |
+
- **Fields**:
|
| 42 |
+
- `idx`: Unique sample identifier
|
| 43 |
+
- `project`: Source project name
|
| 44 |
+
- `commit_id`: Git commit hash
|
| 45 |
+
- `target`: Binary label (0=non-vulnerable, 1=vulnerable)
|
| 46 |
+
- `func`: Source code function
|
| 47 |
+
- `func_hash`: Function hash
|
| 48 |
+
- `cwe`: Common Weakness Enumeration categories
|
| 49 |
+
- `cve`: CVE identifier (if applicable)
|
| 50 |
+
- `project_url`: Source project repository URL
|
| 51 |
+
- `commit_url`: Direct link to the commit
|
| 52 |
+
- Additional metadata fields
|
| 53 |
+
|
| 54 |
+
## Data Source
|
| 55 |
+
|
| 56 |
+
The original JSONL files are available from the PrimeVul authors at:
|
| 57 |
+
- **Google Drive**: https://drive.google.com/drive/folders/19iLaNDS0z99N8kB_jBRTmDLehwZBolMY
|
| 58 |
+
- **GitHub Repository**: https://github.com/DLVulDet/PrimeVul
|
| 59 |
+
|
| 60 |
+
## Data Format
|
| 61 |
+
|
| 62 |
+
This dataset provides the test splits in Parquet format for easy loading with HuggingFace datasets. The original data was in JSONL format and has been converted while preserving all original fields and values.
|
| 63 |
+
|
| 64 |
+
## Usage
|
| 65 |
+
|
| 66 |
+
```python
|
| 67 |
+
from datasets import load_dataset
|
| 68 |
+
|
| 69 |
+
# Load the default configuration (single functions)
|
| 70 |
+
dataset_default = load_dataset("Code-TREAT/PrimeVul_original", "default")
|
| 71 |
+
|
| 72 |
+
# Load the paired configuration
|
| 73 |
+
dataset_paired = load_dataset("Code-TREAT/PrimeVul_original", "paired")
|
| 74 |
+
|
| 75 |
+
# Access test split
|
| 76 |
+
test_data_default = dataset_default["test"]
|
| 77 |
+
test_data_paired = dataset_paired["test"]
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
## Purpose
|
| 81 |
+
|
| 82 |
+
This dataset is provided by the Code-TREAT project to ensure reproducibility and consistency in vulnerability detection research. By providing the exact test splits used in evaluations, researchers can:
|
| 83 |
+
|
| 84 |
+
1. **Reproduce results** from papers using this dataset
|
| 85 |
+
2. **Compare methods** fairly using identical test data
|
| 86 |
+
3. **Validate new approaches** against established benchmarks
|
| 87 |
+
|
| 88 |
+
## License
|
| 89 |
+
|
| 90 |
+
Please refer to the original PrimeVul repository for licensing information: https://github.com/DLVulDet/PrimeVul
|
| 91 |
+
|
| 92 |
+
## Acknowledgments
|
| 93 |
+
|
| 94 |
+
We thank the authors of PrimeVul for making their dataset publicly available and for their contributions to vulnerability detection research.
|
| 95 |
+
|
| 96 |
+
## Contact
|
| 97 |
+
|
| 98 |
+
For questions about this dataset distribution, please refer to the original PrimeVul repository or the Code-TREAT project.
|
dataset_infos.json
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"default": {
|
| 3 |
+
"description": "Single function vulnerability detection dataset from PrimeVul test split",
|
| 4 |
+
"citation": "@article{primevul2024,\n title={PrimeVul: Vulnerability Detection with Code Language Models: How Far Are We?},\n author={[Authors]},\n journal={arXiv preprint arXiv:2403.18624},\n year={2024}\n}",
|
| 5 |
+
"homepage": "https://github.com/DLVulDet/PrimeVul",
|
| 6 |
+
"license": "See original repository",
|
| 7 |
+
"features": {
|
| 8 |
+
"project": {
|
| 9 |
+
"dtype": "string",
|
| 10 |
+
"_type": "Value"
|
| 11 |
+
},
|
| 12 |
+
"commit_id": {
|
| 13 |
+
"dtype": "string",
|
| 14 |
+
"_type": "Value"
|
| 15 |
+
},
|
| 16 |
+
"target": {
|
| 17 |
+
"dtype": "int64",
|
| 18 |
+
"_type": "Value"
|
| 19 |
+
},
|
| 20 |
+
"func": {
|
| 21 |
+
"dtype": "string",
|
| 22 |
+
"_type": "Value"
|
| 23 |
+
},
|
| 24 |
+
"cwe": {
|
| 25 |
+
"dtype": "string",
|
| 26 |
+
"_type": "Value"
|
| 27 |
+
},
|
| 28 |
+
"big_vul_idx": {
|
| 29 |
+
"dtype": "string",
|
| 30 |
+
"_type": "Value"
|
| 31 |
+
},
|
| 32 |
+
"idx": {
|
| 33 |
+
"dtype": "int64",
|
| 34 |
+
"_type": "Value"
|
| 35 |
+
},
|
| 36 |
+
"hash": {
|
| 37 |
+
"dtype": "string",
|
| 38 |
+
"_type": "Value"
|
| 39 |
+
}
|
| 40 |
+
},
|
| 41 |
+
"splits": {
|
| 42 |
+
"test": {
|
| 43 |
+
"name": "test",
|
| 44 |
+
"num_bytes": 0,
|
| 45 |
+
"num_examples": 25911
|
| 46 |
+
}
|
| 47 |
+
},
|
| 48 |
+
"download_size": 0,
|
| 49 |
+
"dataset_size": 0
|
| 50 |
+
},
|
| 51 |
+
"paired": {
|
| 52 |
+
"description": "Paired vulnerability detection dataset from PrimeVul test split with before/after patch pairs",
|
| 53 |
+
"citation": "@article{primevul2024,\n title={PrimeVul: Vulnerability Detection with Code Language Models: How Far Are We?},\n author={[Authors]},\n journal={arXiv preprint arXiv:2403.18624},\n year={2024}\n}",
|
| 54 |
+
"homepage": "https://github.com/DLVulDet/PrimeVul",
|
| 55 |
+
"license": "See original repository",
|
| 56 |
+
"features": {
|
| 57 |
+
"idx": {
|
| 58 |
+
"dtype": "int64",
|
| 59 |
+
"_type": "Value"
|
| 60 |
+
},
|
| 61 |
+
"project": {
|
| 62 |
+
"dtype": "string",
|
| 63 |
+
"_type": "Value"
|
| 64 |
+
},
|
| 65 |
+
"commit_id": {
|
| 66 |
+
"dtype": "string",
|
| 67 |
+
"_type": "Value"
|
| 68 |
+
},
|
| 69 |
+
"project_url": {
|
| 70 |
+
"dtype": "string",
|
| 71 |
+
"_type": "Value"
|
| 72 |
+
},
|
| 73 |
+
"commit_url": {
|
| 74 |
+
"dtype": "string",
|
| 75 |
+
"_type": "Value"
|
| 76 |
+
},
|
| 77 |
+
"commit_message": {
|
| 78 |
+
"dtype": "string",
|
| 79 |
+
"_type": "Value"
|
| 80 |
+
},
|
| 81 |
+
"target": {
|
| 82 |
+
"dtype": "int64",
|
| 83 |
+
"_type": "Value"
|
| 84 |
+
},
|
| 85 |
+
"func": {
|
| 86 |
+
"dtype": "string",
|
| 87 |
+
"_type": "Value"
|
| 88 |
+
},
|
| 89 |
+
"func_hash": {
|
| 90 |
+
"dtype": "string",
|
| 91 |
+
"_type": "Value"
|
| 92 |
+
},
|
| 93 |
+
"file_name": {
|
| 94 |
+
"dtype": "string",
|
| 95 |
+
"_type": "Value"
|
| 96 |
+
},
|
| 97 |
+
"file_hash": {
|
| 98 |
+
"dtype": "string",
|
| 99 |
+
"_type": "Value"
|
| 100 |
+
},
|
| 101 |
+
"cwe": {
|
| 102 |
+
"dtype": "string",
|
| 103 |
+
"_type": "Value"
|
| 104 |
+
},
|
| 105 |
+
"cve": {
|
| 106 |
+
"dtype": "string",
|
| 107 |
+
"_type": "Value"
|
| 108 |
+
},
|
| 109 |
+
"cve_desc": {
|
| 110 |
+
"dtype": "string",
|
| 111 |
+
"_type": "Value"
|
| 112 |
+
},
|
| 113 |
+
"nvd_url": {
|
| 114 |
+
"dtype": "string",
|
| 115 |
+
"_type": "Value"
|
| 116 |
+
}
|
| 117 |
+
},
|
| 118 |
+
"splits": {
|
| 119 |
+
"test": {
|
| 120 |
+
"name": "test",
|
| 121 |
+
"num_bytes": 0,
|
| 122 |
+
"num_examples": 870
|
| 123 |
+
}
|
| 124 |
+
},
|
| 125 |
+
"download_size": 0,
|
| 126 |
+
"dataset_size": 0
|
| 127 |
+
}
|
| 128 |
+
}
|
default/test.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9c328b9637aee0e0cfb6a08e8ac5d2bfc60a36ab4a792cf1f9cdf7a064b67f5f
|
| 3 |
+
size 13790289
|
paired/test.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9ebff1a6f1a789a890aa174a0a748e9fae0cc2dd8f27ccc18ef56391280988a3
|
| 3 |
+
size 1523766
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
huggingface_hub>=0.16.0
|
| 2 |
+
datasets>=2.14.0
|
| 3 |
+
pandas>=1.5.0
|
| 4 |
+
pyarrow>=10.0.0
|
verify_dataset.py
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Script to verify the dataset files before upload
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import pandas as pd
|
| 7 |
+
import json
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def verify_parquet_files():
|
| 12 |
+
"""Verify the Parquet files are valid and contain expected data"""
|
| 13 |
+
|
| 14 |
+
upload_dir = Path(__file__).parent
|
| 15 |
+
|
| 16 |
+
print("🔍 Verifying Parquet files...")
|
| 17 |
+
|
| 18 |
+
# Check default dataset
|
| 19 |
+
default_file = upload_dir / "default" / "test.parquet"
|
| 20 |
+
if default_file.exists():
|
| 21 |
+
try:
|
| 22 |
+
df_default = pd.read_parquet(default_file)
|
| 23 |
+
print(f"✅ Default dataset: {len(df_default)} rows, {len(df_default.columns)} columns")
|
| 24 |
+
print(f" Columns: {list(df_default.columns)}")
|
| 25 |
+
print(f" Target distribution: {df_default['target'].value_counts().to_dict()}")
|
| 26 |
+
except Exception as e:
|
| 27 |
+
print(f"❌ Error reading default dataset: {e}")
|
| 28 |
+
return False
|
| 29 |
+
else:
|
| 30 |
+
print(f"❌ Default dataset file not found: {default_file}")
|
| 31 |
+
return False
|
| 32 |
+
|
| 33 |
+
# Check paired dataset
|
| 34 |
+
paired_file = upload_dir / "paired" / "test.parquet"
|
| 35 |
+
if paired_file.exists():
|
| 36 |
+
try:
|
| 37 |
+
df_paired = pd.read_parquet(paired_file)
|
| 38 |
+
print(f"✅ Paired dataset: {len(df_paired)} rows, {len(df_paired.columns)} columns")
|
| 39 |
+
print(f" Columns: {list(df_paired.columns)}")
|
| 40 |
+
print(f" Target distribution: {df_paired['target'].value_counts().to_dict()}")
|
| 41 |
+
except Exception as e:
|
| 42 |
+
print(f"❌ Error reading paired dataset: {e}")
|
| 43 |
+
return False
|
| 44 |
+
else:
|
| 45 |
+
print(f"❌ Paired dataset file not found: {paired_file}")
|
| 46 |
+
return False
|
| 47 |
+
|
| 48 |
+
return True
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def verify_config_files():
|
| 52 |
+
"""Verify configuration files exist and are valid"""
|
| 53 |
+
|
| 54 |
+
upload_dir = Path(__file__).parent
|
| 55 |
+
|
| 56 |
+
print("\n🔍 Verifying configuration files...")
|
| 57 |
+
|
| 58 |
+
# Check README.md
|
| 59 |
+
readme_file = upload_dir / "README.md"
|
| 60 |
+
if readme_file.exists():
|
| 61 |
+
print("✅ README.md exists")
|
| 62 |
+
else:
|
| 63 |
+
print("❌ README.md not found")
|
| 64 |
+
return False
|
| 65 |
+
|
| 66 |
+
# Check dataset_infos.json
|
| 67 |
+
dataset_info_file = upload_dir / "dataset_infos.json"
|
| 68 |
+
if dataset_info_file.exists():
|
| 69 |
+
try:
|
| 70 |
+
with open(dataset_info_file, 'r') as f:
|
| 71 |
+
dataset_info = json.load(f)
|
| 72 |
+
|
| 73 |
+
if "default" in dataset_info and "paired" in dataset_info:
|
| 74 |
+
print("✅ dataset_infos.json is valid")
|
| 75 |
+
else:
|
| 76 |
+
print("❌ dataset_infos.json missing required configurations")
|
| 77 |
+
return False
|
| 78 |
+
except Exception as e:
|
| 79 |
+
print(f"❌ Error reading dataset_infos.json: {e}")
|
| 80 |
+
return False
|
| 81 |
+
else:
|
| 82 |
+
print("❌ dataset_infos.json not found")
|
| 83 |
+
return False
|
| 84 |
+
|
| 85 |
+
# Check Python script
|
| 86 |
+
py_file = upload_dir / "PrimeVul_original.py"
|
| 87 |
+
if py_file.exists():
|
| 88 |
+
print("✅ PrimeVul_original.py exists")
|
| 89 |
+
else:
|
| 90 |
+
print("❌ PrimeVul_original.py not found")
|
| 91 |
+
return False
|
| 92 |
+
|
| 93 |
+
return True
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def show_file_sizes():
|
| 97 |
+
"""Show file sizes for reference"""
|
| 98 |
+
|
| 99 |
+
upload_dir = Path(__file__).parent
|
| 100 |
+
|
| 101 |
+
print("\n📊 File sizes:")
|
| 102 |
+
|
| 103 |
+
files_to_check = [
|
| 104 |
+
"default/test.parquet",
|
| 105 |
+
"paired/test.parquet",
|
| 106 |
+
"README.md",
|
| 107 |
+
"dataset_infos.json",
|
| 108 |
+
"PrimeVul_original.py"
|
| 109 |
+
]
|
| 110 |
+
|
| 111 |
+
for file_path in files_to_check:
|
| 112 |
+
full_path = upload_dir / file_path
|
| 113 |
+
if full_path.exists():
|
| 114 |
+
size = full_path.stat().st_size
|
| 115 |
+
size_mb = size / (1024 * 1024)
|
| 116 |
+
print(f" {file_path}: {size:,} bytes ({size_mb:.2f} MB)")
|
| 117 |
+
else:
|
| 118 |
+
print(f" {file_path}: NOT FOUND")
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
def main():
|
| 122 |
+
print("🚀 Verifying PrimeVul Original dataset files...")
|
| 123 |
+
|
| 124 |
+
parquet_ok = verify_parquet_files()
|
| 125 |
+
config_ok = verify_config_files()
|
| 126 |
+
|
| 127 |
+
show_file_sizes()
|
| 128 |
+
|
| 129 |
+
if parquet_ok and config_ok:
|
| 130 |
+
print("\n✅ All verifications passed! Ready for upload.")
|
| 131 |
+
print("\nTo upload to HuggingFace:")
|
| 132 |
+
print("python upload_to_hf.py --token YOUR_HF_TOKEN")
|
| 133 |
+
else:
|
| 134 |
+
print("\n❌ Verification failed! Please fix the issues above.")
|
| 135 |
+
exit(1)
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
if __name__ == "__main__":
|
| 139 |
+
main()
|