starsofchance commited on
Commit
f52a4f8
·
verified ·
1 Parent(s): 0c09220

Add dataset card

Browse files
Files changed (1) hide show
  1. README.md +209 -0
README.md ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+ dataset_info:
4
+ name: DiverseVul
5
+ description: A comprehensive dataset of vulnerable and non-vulnerable C/C++ source code for deep learning-based vulnerability detection, featuring 523,956 functions from 933 projects and 155 CWEs.
6
+ citation: |
7
+ @article{chen2023diversevul,
8
+ title={DiverseVul: A New Vulnerable Source Code Dataset for Deep Learning Based Vulnerability Detection},
9
+ author={Chen, Yizheng and Ding, Zhoujie and Alowain, Lamya and Chen, Xinyun and Wagner, David},
10
+ journal={arXiv preprint arXiv:2304.00409v2},
11
+ year={2023}
12
+ }
13
+ homepage: https://github.com/wagner-group/diversevul
14
+ license: Not specified; usage subject to original authors' terms and project licenses
15
+ features:
16
+ - name: project
17
+ type: string
18
+ description: Name of the open-source project the function originates from
19
+ - name: commit_id
20
+ type: string
21
+ nullable: true
22
+ description: Commit ID associated with the function, or null if unavailable
23
+ - name: target
24
+ type: int32
25
+ description: Binary label (0 = non-vulnerable, 1 = vulnerable)
26
+ - name: func
27
+ type: string
28
+ description: Full C/C++ source code of the function
29
+ - name: idx
30
+ type: int32
31
+ description: Unique index of the sample
32
+ splits:
33
+ - name: train
34
+ num_examples: 419404
35
+ - name: validation
36
+ num_examples: 52337
37
+ - name: test
38
+ num_examples: 52215
39
+ task_categories:
40
+ - text-classification
41
+ languages:
42
+ - C
43
+ - C++
44
+ pretty_name: DiverseVul - Vulnerable Source Code Dataset
45
+ ---
46
+
47
+ # DiverseVul Dataset Card
48
+
49
+ ## Dataset Description
50
+
51
+ **DiverseVul** is a comprehensive and meticulously curated dataset of vulnerable and non-vulnerable C/C++ source code, designed to advance deep learning-based vulnerability detection research. Originally introduced by Yizheng Chen, Zhoujie Ding, Lamya Alowain, Xinyun Chen, and David Wagner in their seminal paper, this dataset has been expanded and uploaded to Hugging Face to facilitate broader access and application. It captures real-world software vulnerabilities extracted from vulnerability-fixing commits across a diverse array of open-source projects, making it an invaluable resource for researchers, developers, and security professionals.
52
+
53
+
54
+
55
+ ### Dataset Summary
56
+
57
+ The version of `DiverseVul` hosted on Hugging Face represents an enhanced and more complete iteration of the dataset described in the original paper. It contains **523,956 rows** of function-level source code samples, split into three predefined sections:
58
+
59
+ - **Training Set:** 419,404 rows
60
+ - **Validation Set:** 52,337 rows
61
+ - **Test Set:** 52,215 rows
62
+
63
+ These samples are derived from **933 unique projects** and cover **155 Common Weakness Enumerations (CWEs)**, including:
64
+ Number of target0 in training split: 386305
65
+ Number of target1 in training split: 33099
66
+ Number of target0 in test_data split: 48072
67
+ Number of target1 in test_data split: 4143
68
+ Number of target0 in val_data split: 48202
69
+ Number of target1 in val_data split: 4135
70
+
71
+
72
+
73
+ ### Citation
74
+
75
+ This dataset was created by Yizheng Chen, Zhoujie Ding, Lamya Alowain, Xinyun Chen, and David Wagner. If you use `DiverseVul` in your work, please cite the original paper:
76
+ - **Homepage:** [https://github.com/wagner-group/diversevul](https://github.com/wagner-group/diversevul)
77
+ - **Repository:** [https://github.com/wagner-group/diversevul](https://github.com/wagner-group/diversevul)
78
+ - **Paper:** [DiverseVul: A New Vulnerable Source Code Dataset for Deep Learning Based Vulnerability Detection](https://arxiv.org/abs/2304.00409v2)
79
+ - **Point of Contact:** Yizheng Chen (yzchen@umd.edu), Zhoujie Ding (zhoujie.ding@berkeley.edu)
80
+
81
+ ```bibtex
82
+ @article{chen2023diversevul,
83
+ title={DiverseVul: A New Vulnerable Source Code Dataset for Deep Learning Based Vulnerability Detection},
84
+ author={Chen, Yizheng and Ding, Zhoujie and Alowain, Lamya and Chen, Xinyun and Wagner, David},
85
+ journal={arXiv preprint arXiv:2304.00409v2},
86
+ year={2023}
87
+ }
88
+ ```
89
+
90
+ Note: The version uploaded to Hugging Face is an expanded dataset built upon the original work available at [https://github.com/wagner-group/diversevul](https://github.com/wagner-group/diversevul), with all credit attributed to the original authors.
91
+
92
+ ---
93
+
94
+ ## Dataset Structure
95
+
96
+ ### Data Instances
97
+
98
+ Each row in `DiverseVul` represents a single C/C++ function extracted from a project, labeled as vulnerable (`target: 1`) or non-vulnerable (`target: 0`). The dataset is structured with the following columns:
99
+
100
+ - **`project`**: The name of the open-source project from which the function originates (e.g., "debian", "bluez", "Chrome").
101
+ - **`commit_id`**: The unique identifier of the commit associated with the function. For non-vulnerable functions or cases where commit information is unavailable, this may be `None`.
102
+ - **`target`**: Binary label indicating vulnerability status (0 = non-vulnerable, 1 = vulnerable).
103
+ - **`func`**: The full source code of the function as a string, preserving its original syntax and formatting.
104
+ - **`idx`**: A unique index assigned to the sample within the dataset.
105
+
106
+ #### Example Instances
107
+
108
+ - **Training Set (Index 0):**
109
+ ```json
110
+ {
111
+ "project": "debian",
112
+ "commit_id": null,
113
+ "target": 0,
114
+ "func": "static guint16 de_ciph_key_seq_num ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len _U_ , gchar * add_string _U_ , int string_len _U_ ) {\n guint32 curr_offset , bit_offset ;\n curr_offset = offset ;\n if ( RIGHT_NIBBLE == len ) bit_offset = 4 ;\n else bit_offset = 0 ;\n proto_tree_add_bits_item ( tree , hf_gsm_a_spare_bits , tvb , ( curr_offset << 3 ) + bit_offset , 1 , ENC_BIG_ENDIAN ) ;\n proto_tree_add_bits_item ( tree , hf_gsm_a_key_seq , tvb , ( curr_offset << 3 ) + bit_offset + 1 , 3 , ENC_BIG_ENDIAN ) ;\n curr_offset ++ ;\n return ( curr_offset - offset ) ;\n }",
115
+ "idx": 17792
116
+ }
117
+ ```
118
+ *Description*: A non-vulnerable function from the "debian" project, handling bit-level operations for GSM protocol parsing.
119
+
120
+ - **Test Set (Index 0):**
121
+ ```json
122
+ {
123
+ "project": "bluez",
124
+ "commit_id": "1cd644db8c23a2f530ddb93cebed7dacc5f5721a",
125
+ "target": 1,
126
+ "func": "bool bt_att_cancel(struct bt_att *att, unsigned int id)\n{\n\tconst struct queue_entry *entry;\n\tstruct att_send_op *op;\n\n\tif (!att || !id)\n\t\treturn false;\n\n\t/* Lookuo request on each channel first */\n\tfor (entry = queue_get_entries(att->chans); entry;\n\t\t\t\t\t\tentry = entry->next) {\n\t\tstruct bt_att_chan *chan = entry->data;\n\n\t\tif (bt_att_chan_cancel(chan, id))\n\t\t\treturn true;\n\t}\n\n\top = queue_remove_if(att->req_queue, match_op_id, UINT_TO_PTR(id));\n\tif (op)\n\t\tgoto done;\n\n\top = queue_remove_if(att->ind_queue, match_op_id, UINT_TO_PTR(id));\n\tif (op)\n\t\tgoto done;\n\n\top = queue_remove_if(att->write_queue, match_op_id, UINT_TO_PTR(id));\n\tif (op)\n\t\tgoto done;\n\n\tif (!op)\n\t\treturn false;\n\ndone:\n\tdestroy_att_send_op(op);\n\n\twakeup_writer(att);\n\n\treturn true;\n}",
127
+ "idx": 7502
128
+ }
129
+ ```
130
+ *Description*: A vulnerable function from the "bluez" project, tied to a specific commit, managing Bluetooth ATT protocol operations.
131
+
132
+ - **Validation Set (Index 0):**
133
+ ```json
134
+ {
135
+ "project": "Chrome",
136
+ "commit_id": "d007b8b750851fe1b375c463009ea3b24e5c021d",
137
+ "target": 1,
138
+ "func": " IndexedDBCursor::~IndexedDBCursor() {\n Close();\n }\n",
139
+ "idx": 10542
140
+ }
141
+ ```
142
+ *Description*: A concise, vulnerable destructor from the "Chrome" project, linked to a commit fixing an IndexedDB-related vulnerability.
143
+
144
+ ### Data Fields
145
+
146
+ - **`project` (string)**: Identifies the source project, reflecting the dataset’s diversity across 933 projects, including well-known ones like "linux," "Chrome," "debian," and "bluez."
147
+ - **`commit_id` (string or null)**: Ties the function to a specific vulnerability-fixing commit, providing traceability where available.
148
+ - **`target` (integer)**: Labels the function’s vulnerability status, enabling binary classification tasks.
149
+ - **`func` (string)**: Contains the raw C/C++ code, offering rich context for code analysis and model training.
150
+ - **`idx` (integer)**: A unique identifier for tracking and referencing individual samples.
151
+
152
+ ### Source Data
153
+
154
+ `DiverseVul` was constructed by crawling security issue websites to identify vulnerability-fixing commits from 933 open-source C/C++ projects. The authors cloned these projects, extracted relevant commits, and parsed C/C++ files to label functions as vulnerable (changed in the commit) or non-vulnerable (unchanged or post-fix). The process involved deduplication using MD5 hashes and mapping vulnerabilities to 155 CWEs via the National Vulnerability Database (NVD) API and manual annotation.
155
+
156
+ ### Annotation Process
157
+
158
+ - **Vulnerable Functions**: Functions modified in vulnerability-fixing commits are labeled `target: 1`. Manual analysis of 50 samples from `DiverseVul` showed a 60% label accuracy, with errors due to multi-function vulnerabilities or irrelevant changes.
159
+ - **Non-Vulnerable Functions**: Unchanged functions or post-fix versions are labeled `target: 0`.
160
+ - **CWE Coverage**: Approximately 85% of vulnerable functions are mapped to 155 CWE categories, enhancing the dataset’s utility for specific vulnerability type studies.
161
+
162
+ ### Projects Covered
163
+
164
+ The dataset spans a wide range of projects, including but not limited to:
165
+ - **leptonica, mongo, drogon, libuv, ark, exiv2, Bento4, perl5, e2guardian, libheif**
166
+ - **pigz, Little-CMS, polarssl, godot, openafs, arangodb, infradead, android_security**
167
+ - **qtbase, git, uftpd, linux-uek, xrootd, runc, dosfstools, openmpt, webserver**
168
+ - **yast-core, jhead, cJSON, vim, openfortivpn, libgit2, abrt, c-blosc2, libfep**
169
+ - And many more
170
+ ---
171
+
172
+ ## Uses
173
+
174
+ ### What Kind of Projects This Dataset Is Good For
175
+
176
+ `DiverseVul` is ideal for:
177
+ - **Vulnerability Detection Research**: Training and evaluating deep learning models (e.g., LLMs, GNNs) to identify C/C++ vulnerabilities.
178
+ - **Software Security Tools**: Developing or enhancing static analysis tools and code auditing systems.
179
+ - **Educational Purposes**: Teaching students about software vulnerabilities, CWEs, and secure coding practices.
180
+ - **Generalization Studies**: Investigating model performance on unseen projects, a critical challenge in real-world deployment.
181
+ - **CWE-Specific Analysis**: Studying patterns in specific vulnerability types due to its broad CWE coverage.
182
+
183
+ ### How People Can Use the Dataset
184
+
185
+ - **Machine Learning Training**: Use the train/validation/test splits to fine-tune models like CodeT5, NatGen, or custom architectures for binary classification (vulnerable vs. non-vulnerable).
186
+ - *Example*: Fine-tune a transformer model on the `func` column with `target` as the label.
187
+ - **Code Analysis**: Analyze the `func` field to extract features (e.g., ASTs, CFGs) for traditional or hybrid vulnerability detection methods.
188
+ - **Project Benchmarking**: Evaluate model generalization by training on a subset of projects and testing on others, leveraging the `project` field.
189
+ - **CWE Research**: Filter samples by CWE (via external mapping) to study specific vulnerability types or improve detection for hard-to-learn CWEs.
190
+ - **Data Augmentation**: Combine with other datasets (e.g., CVEFixes, BigVul) to increase training volume and diversity.
191
+
192
+ ---
193
+
194
+ ## Dataset Characteristics
195
+
196
+ - **Size**: 523,956 functions (41,377 vulnerable, 482,579 non-vulnerable).
197
+ - **Languages**: C and C++ exclusively.
198
+ - **Diversity**: 933 projects, 155 CWEs, 21,949 commits.
199
+ - **Label Noise**: Approximately 40% of labels may be noisy due to multi-function vulnerabilities or irrelevant changes (60% accuracy per manual audit).
200
+
201
+ ---
202
+
203
+ ## Limitations
204
+
205
+ - **Label Noise**: Automated labeling from commits introduces errors (e.g., irrelevant changes mislabeled as vulnerable), potentially affecting model performance.
206
+ - **C/C++ Focus**: Limited to C/C++ code, not applicable to other languages without adaptation.
207
+ - **Pretraining Contamination Risk**: Some LLMs may have seen code from these projects during pretraining, though this is unlikely to include vulnerability annotations.
208
+ - **Whitespace Duplication**: Lack of whitespace normalization during deduplication may retain redundant samples.
209
+ ---