CoolFace
Datasetpublic

starsofchance/MSR_data_cleaned

MSR Data Cleaned - C/C++ Code Vulnerability Dataset ๐Ÿ“Œ Dataset Description A curated collection of C/C++ code vulnerabilities paired with: CVE details (scores, classifications, exploit status) Code changes (commit messages, added/deleted lines) File-level and function-level diffs ๐Ÿ” Sample Data Structure from original file +---------------+-----------------+----------------------+---------------------------+ | CVE ID | Attack Origin |โ€ฆ See the full description on the dataset page: https://huggingface.co/datasets/starsofchance/MSR_data_cleaned.

sourceHugging Facemitupdated 1y agoView on Hugging Face
1likes87downloads
Dataset Card

MSR Data Cleaned - C/C++ Code Vulnerability Dataset

![Dataset License](LICENSE)

๐Ÿ“Œ Dataset Description

A curated collection of C/C++ code vulnerabilities paired with:

  • โ€”CVE details (scores, classifications, exploit status)
  • โ€”Code changes (commit messages, added/deleted lines)
  • โ€”File-level and function-level diffs

๐Ÿ” Sample Data Structure from original file

python
+---------------+-----------------+----------------------+---------------------------+
| CVE ID        | Attack Origin   | Publish Date         | Summary                   |
+===============+=================+======================+===========================+
| CVE-2015-8467 | Remote          | 2015-12-29           | "The samldb_check_user..."|
+---------------+-----------------+----------------------+---------------------------+
| CVE-2016-1234 | Local           | 2016-01-15           | "Buffer overflow in..."   |
+---------------+-----------------+----------------------+---------------------------+

Note: This is a simplified preview; the full dataset includes additional fields like commitid, funcbefore, etc.

1. Accessing in Colab

python
!pip install huggingface_hub -q
from huggingface_hub import snapshot_download

repo_id = "starsofchance/MSR_data_cleaned"
dataset_path = snapshot_download(repo_id=repo_id, repo_type="dataset")

2. Extracting the Dataset

python
!apt-get install unzip -qq
!unzip "/root/.cache/huggingface/.../MSR_data_cleaned.zip" -d "/content/extracted_data"

**Note: Extracted size is 10GB (1.5GB compressed). Ensure sufficient disk space.

3. Creating Splits (Colab Pro Recommended)

We used this memory-efficient approach:

python
from datasets import load_dataset
dataset = load_dataset("csv", data_files="MSR_data_cleaned.csv", streaming=True)

# Randomly distribute rows (80-10-10)
for row in dataset:
    rand = random.random()
    if rand < 0.8: write_to(train.csv)
    elif rand < 0.9: write_to(validation.csv)
    else: write_to(test.csv)

Hardware Requirements:

  • โ€”Minimum 25GB RAM
  • โ€”Strong CPU (Colab Pro T4 GPU recommended)

##๐Ÿ“Š Dataset Statistics

  • โ€”Number of Rows: 188,636
  • โ€”Vulnerability Distribution:
  • โ€”Vulnerable (1): 18,863 (~10%)
  • โ€”Non-Vulnerable (0): 169,773 (~90%) ##๐Ÿ“‹ Data Fields Description
  • โ€”CVE_ID: Unique identifier for the vulnerability (Common Vulnerabilities and Exposures).
  • โ€”CWE_ID: Weakness category identifier (Common Weakness Enumeration).
  • โ€”Score: CVSS score indicating severity (float, 0-10).
  • โ€”Summary: Brief description of the vulnerability.
  • โ€”commit_id: Git commit hash linked to the code change.
  • โ€”codeLink: URL to the code repository or commit.
  • โ€”file_name: Name of the file containing the vulnerability.
  • โ€”func_after: Function code after the change.
  • โ€”lines_after: Code lines after the change.
  • โ€”Access_Gained: Type of access gained by exploiting the vulnerability.
  • โ€”Attack_Origin: Source of the attack (e.g., Remote, Local).
  • โ€”Authentication_Required: Whether authentication is needed to exploit.
  • โ€”Availability: Impact on system availability.
  • โ€”CVE_Page: URL to the CVE details page.
  • โ€”Complexity: Complexity of exploiting the vulnerability.
  • โ€”Confidentiality: Impact on data confidentiality.
  • โ€”Integrity: Impact on data integrity.
  • โ€”Known_Exploits: Details of known exploits, if any.
  • โ€”Publish_Date: Date the vulnerability was published.
  • โ€”Update_Date: Date of the last update to the vulnerability data.
  • โ€”Vulnerability_Classification: Type or category of the vulnerability.
  • โ€”add_lines: Lines added in the commit.
  • โ€”del_lines: Lines deleted in the commit.
  • โ€”commit_message: Description of the commit.
  • โ€”files_changed: List of files modified in the commit.
  • โ€”func_before: Function code before the change.
  • โ€”lang: Programming language (e.g., C, C++).
  • โ€”lines_before: Code lines before the change.

splits file for UltiVul project:

๐Ÿ” Sample Data Structure (from train.csv)

python
{
 'idx': 0, # Unique ID within the train split
 'func_before': '...', # String containing function code before change
 'Vulnerability Classification': '...', # Original vulnerability type classification
 'vul': 0, # Integer: 0 for non-vulnerable, 1 for vulnerable (target label)
 'func_after': '...', # String containing function code after change
 'patch': '...', # String containing diff patch
 'CWE ID': '...', # String CWE ID, e.g., "CWE-119"
 'lines_before': '...', # String lines before change context
 'lines_after': '...' # String lines after change context
}

**Note: This shows the structure of the final split files (train.csv, validation.csv, test.csv). The original MSRdatacleaned.csv contains many more metadata fields.

##๐Ÿ“ฆ Dataset New Files The dataset is available as three CSV files (specially created for the UltiVul project) hosted on Hugging Face, uploaded via huggingface_hub:

  • โ€”train.csv Size: 667 MB Description: Training split with 150,909 samples, approximately 80% of the data.
  • โ€”validation.csv Size: 86 MB Description: Validation split with 18,864 samples, approximately 10% of the data.
  • โ€”test.csv Size: 84.8 MB Description: Test split with 18,863 samples, approximately 10% of the data.

๐Ÿ™ Acknowledgements Original dataset provided by Fan et al., 2020 Thanks to the Hugging Face team for dataset hosting tools.

๐Ÿ“œ Citation

bibtex
@inproceedings{fan2020ccode,
  title={A C/C++ Code Vulnerability Dataset with Code Changes and CVE Summaries},
  author={Fan, Jiahao and Li, Yi and Wang, Shaohua and Nguyen, Tien N},
  booktitle={MSR '20: 17th International Conference on Mining Software Repositories},
  pages={1--5},
  year={2020},
  doi={10.1145/3379597.3387501}
}

๐ŸŒŸ Dataset Creation

  • โ€”Source: Original data from MSR 2020 Paper
  • โ€”Processing:
  • โ€”Cleaned and standardized CSV format
  • โ€”Stream-based splitting to handle large size
  • โ€”Preserved all original metadata