File size: 4,858 Bytes
be455ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c01459
58e5328
3c01459
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4e322f6
3c01459
 
 
 
58e5328
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
---
dataset_info:
  features:
  - name: project
    dtype: string
  - name: commit_id
    dtype: string
  - name: func
    dtype: string
  - name: vul
    dtype: int64
  - name: CVE ID
    dtype: string
  - name: CWE ID
    dtype: string
  - name: CWE Name
    dtype: string
  - name: CWE Description
    dtype: string
  - name: Potential Mitigation
    dtype: string
  - name: __index_level_0__
    dtype: int64
  splits:
  - name: train
    num_bytes: 64041861
    num_examples: 15770
  - name: validation
    num_bytes: 9198025
    num_examples: 2253
  - name: test
    num_bytes: 17932135
    num_examples: 4506
  download_size: 25107430
  dataset_size: 91172021
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
  - split: validation
    path: data/validation-*
  - split: test
    path: data/test-*
---

# CWE Enriched and Balanced BigVul+PrimeVul

This dataset is a processed and enriched version of the **BigVul and PrimeVul datasets**, enhanced using CWE mappings from [MITRE's CWE Database](https://cwe.mitre.org/). The purpose of this dataset is to provide a cleaner, more balanced, and more informative version of the original datasets for vulnerability prediction and CWE classification tasks.


## 📌 Dataset Description

This dataset contains vulnerability information from BigVul and PrimeVul datasets, with additional columns added from CWE ID mappings fetched from MITRE’s CWE database. The dataset was cleaned, balanced, and split into **training, validation, and test sets** while maintaining:
- The distribution ratio of vulnerable and non-vulnerable functions.
- The distribution ratio of each CWE ID across all splits.

### 💡 Key Features:
- **Project & Commit Information:** Metadata related to the project and its commits.
- **Function Code (`func`):** The code snippet associated with each entry.
- **Vulnerability Label (`vul`):** Whether the function is vulnerable (`1`) or not (`0`).
- **CVE ID & CWE ID Mapping:** Relevant IDs for categorizing vulnerabilities.
- **CWE Information:** Additional information fetched from MITRE's CWE database including:
  - `CWE Name`
  - `CWE Description`
  - `Potential Mitigation`

## 📂 Dataset Structure

The dataset consists of the following columns:
| Column Name           | Description                                                    |
|-----------------------|----------------------------------------------------------------|
| project               | The name of the project where the code is taken from.        |
| commit_id             | The unique commit identifier.                                |
| func                  | The function code snippet.                                    |
| vul                   | Label indicating if the function is vulnerable (`1`) or not (`0`). |
| CVE ID                | The CVE identifier (if applicable).                          |
| CWE ID                | The CWE identifier corresponding to the vulnerability.      |
| CWE Name              | The name of the CWE ID.                                       |
| CWE Description       | Description of the CWE category.                             |
| Potential Mitigation  | Recommended mitigations for addressing the vulnerability.   |



## 📊 CWE IDs Contained In This Dataset

The dataset contains the following **13 unique CWE IDs (Including Not Applicable)**:

| CWE ID    | CWE Name                             |
|-----------|-------------------------------------|
| CWE-119   | Improper Restriction of Operations within the Bounds of a Memory Buffer |
| CWE-20    | Improper Input Validation            |
| CWE-125   | Out-of-bounds Read                   |
| CWE-399   | Resource Management Errors           |
| CWE-200   | Information Exposure                 |
| CWE-787   | Out-of-bounds Write                  |
| CWE-264   | Permissions, Privileges, and Access Control |
| CWE-416   | Use After Free                       |
| CWE-476   | NULL Pointer Dereference             |
| CWE-190   | Integer Overflow or Wraparound       |
| CWE-189   | Numeric Errors                       |
| CWE-362   | Concurrent Execution using Shared Resource with Improper Synchronization (Race Condition) |
| NOT_APPLICABLE | Not applicable / No CWE ID assigned |


## 🔍 Data Splitting & Balancing

The dataset has been split into **training, validation, and test sets** using stratified sampling to ensure the distribution of:
1. Vulnerable (`vul = 1`) and Non-Vulnerable (`vul = 0`) functions.
2. Each CWE ID remains consistent across splits.


## 📥 Usage

To load this dataset from the Hugging Face Hub:
```python
from datasets import load_dataset

dataset = load_dataset('mahdin70/cwe_enriched_balanced_bigvul_primevul')
```


## 📌 Citation
If you use this dataset, please cite the original sources of BigVul and PrimeVul datasets.