system HF staff commited on
Commit
9782595
0 Parent(s):

Update files from the datasets library (from 1.8.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.8.0

.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - found
4
+ language_creators:
5
+ - found
6
+ languages:
7
+ - code
8
+ licenses:
9
+ - other-C-UDA
10
+ multilinguality:
11
+ - other-programming-languages
12
+ size_categories:
13
+ - 10K<n<100K
14
+ source_datasets:
15
+ - original
16
+ task_categories:
17
+ - text-classification
18
+ task_ids:
19
+ - multi-class-classification
20
+ ---
21
+ # Dataset Card for "code_x_glue_cc_defect_detection"
22
+
23
+ ## Table of Contents
24
+ - [Dataset Description](#dataset-description)
25
+ - [Dataset Summary](#dataset-summary)
26
+ - [Supported Tasks and Leaderboards](#supported-tasks)
27
+ - [Languages](#languages)
28
+ - [Dataset Structure](#dataset-structure)
29
+ - [Data Instances](#data-instances)
30
+ - [Data Fields](#data-fields)
31
+ - [Data Splits](#data-splits-sample-size)
32
+ - [Dataset Creation](#dataset-creation)
33
+ - [Curation Rationale](#curation-rationale)
34
+ - [Source Data](#source-data)
35
+ - [Annotations](#annotations)
36
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
37
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
38
+ - [Social Impact of Dataset](#social-impact-of-dataset)
39
+ - [Discussion of Biases](#discussion-of-biases)
40
+ - [Other Known Limitations](#other-known-limitations)
41
+ - [Additional Information](#additional-information)
42
+ - [Dataset Curators](#dataset-curators)
43
+ - [Licensing Information](#licensing-information)
44
+ - [Citation Information](#citation-information)
45
+ - [Contributions](#contributions)
46
+
47
+ ## Dataset Description
48
+
49
+ - **Homepage:** https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/Defect-detection
50
+
51
+ ### Dataset Summary
52
+
53
+ CodeXGLUE Defect-detection dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/Defect-detection
54
+
55
+ Given a source code, the task is to identify whether it is an insecure code that may attack software systems, such as resource leaks, use-after-free vulnerabilities and DoS attack. We treat the task as binary classification (0/1), where 1 stands for insecure code and 0 for secure code.
56
+ The dataset we use comes from the paper Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networks. We combine all projects and split 80%/10%/10% for training/dev/test.
57
+
58
+ ### Supported Tasks and Leaderboards
59
+
60
+ - `multi-class-classification`: The dataset can be used to train a model for detecting if code has a defect in it.
61
+
62
+ ### Languages
63
+
64
+ - C **programming** language
65
+
66
+ ## Dataset Structure
67
+
68
+ ### Data Instances
69
+
70
+ An example of 'validation' looks as follows.
71
+ ```
72
+ {
73
+ "commit_id": "aa1530dec499f7525d2ccaa0e3a876dc8089ed1e",
74
+ "func": "static void filter_mirror_setup(NetFilterState *nf, Error **errp)\n{\n MirrorState *s = FILTER_MIRROR(nf);\n Chardev *chr;\n chr = qemu_chr_find(s->outdev);\n if (chr == NULL) {\n error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,\n \"Device '%s' not found\", s->outdev);\n qemu_chr_fe_init(&s->chr_out, chr, errp);",
75
+ "id": 8,
76
+ "project": "qemu",
77
+ "target": true
78
+ }
79
+ ```
80
+
81
+ ### Data Fields
82
+
83
+ In the following each data field in go is explained for each config. The data fields are the same among all splits.
84
+
85
+ #### default
86
+
87
+ |field name| type | description |
88
+ |----------|------|------------------------------------------|
89
+ |id |int32 | Index of the sample |
90
+ |func |string| The source code |
91
+ |target |bool | 0 or 1 (vulnerability or not) |
92
+ |project |string| Original project that contains this code |
93
+ |commit_id |string| Commit identifier in the original project|
94
+
95
+ ### Data Splits
96
+
97
+ | name |train|validation|test|
98
+ |-------|----:|---------:|---:|
99
+ |default|21854| 2732|2732|
100
+
101
+ ## Dataset Creation
102
+
103
+ ### Curation Rationale
104
+
105
+ [More Information Needed]
106
+
107
+ ### Source Data
108
+
109
+ #### Initial Data Collection and Normalization
110
+
111
+ [More Information Needed]
112
+
113
+ #### Who are the source language producers?
114
+
115
+ [More Information Needed]
116
+
117
+ ### Annotations
118
+
119
+ #### Annotation process
120
+
121
+ [More Information Needed]
122
+
123
+ #### Who are the annotators?
124
+
125
+ [More Information Needed]
126
+
127
+ ### Personal and Sensitive Information
128
+
129
+ [More Information Needed]
130
+
131
+ ## Considerations for Using the Data
132
+
133
+ ### Social Impact of Dataset
134
+
135
+ [More Information Needed]
136
+
137
+ ### Discussion of Biases
138
+
139
+ [More Information Needed]
140
+
141
+ ### Other Known Limitations
142
+
143
+ [More Information Needed]
144
+
145
+ ## Additional Information
146
+
147
+ ### Dataset Curators
148
+
149
+ https://github.com/microsoft, https://github.com/madlag
150
+
151
+ ### Licensing Information
152
+
153
+ Computational Use of Data Agreement (C-UDA) License.
154
+
155
+ ### Citation Information
156
+
157
+ ```
158
+ @inproceedings{zhou2019devign,
159
+ title={Devign: Effective vulnerability identification by learning comprehensive program semantics via graph neural networks},
160
+ author={Zhou, Yaqin and Liu, Shangqing and Siow, Jingkai and Du, Xiaoning and Liu, Yang},
161
+ booktitle={Advances in Neural Information Processing Systems},
162
+ pages={10197--10207}, year={2019}
163
+ ```
164
+
165
+ ### Contributions
166
+
167
+ Thanks to @madlag (and partly also @ncoop57) for adding this dataset.
code_x_glue_cc_defect_detection.py ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import List
2
+
3
+ import datasets
4
+
5
+ from .common import TrainValidTestChild
6
+ from .generated_definitions import DEFINITIONS
7
+
8
+
9
+ _DESCRIPTION = """Given a source code, the task is to identify whether it is an insecure code that may attack software systems, such as resource leaks, use-after-free vulnerabilities and DoS attack. We treat the task as binary classification (0/1), where 1 stands for insecure code and 0 for secure code.
10
+ The dataset we use comes from the paper Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networks. We combine all projects and split 80%/10%/10% for training/dev/test."""
11
+ _CITATION = """@inproceedings{zhou2019devign,
12
+ title={Devign: Effective vulnerability identification by learning comprehensive program semantics via graph neural networks},
13
+ author={Zhou, Yaqin and Liu, Shangqing and Siow, Jingkai and Du, Xiaoning and Liu, Yang},
14
+ booktitle={Advances in Neural Information Processing Systems},
15
+ pages={10197--10207}, year={2019}"""
16
+
17
+
18
+ class CodeXGlueCcDefectDetectionImpl(TrainValidTestChild):
19
+ _DESCRIPTION = _DESCRIPTION
20
+ _CITATION = _CITATION
21
+
22
+ _FEATURES = {
23
+ "id": datasets.Value("int32"), # Index of the sample
24
+ "func": datasets.Value("string"), # The source code
25
+ "target": datasets.Value("bool"), # 0 or 1 (vulnerability or not)
26
+ "project": datasets.Value("string"), # Original project that contains this code
27
+ "commit_id": datasets.Value("string"), # Commit identifier in the original project
28
+ }
29
+ _SUPERVISED_KEYS = ["target"]
30
+
31
+ def generate_urls(self, split_name):
32
+ yield "index", f"{split_name}.txt"
33
+ yield "data", "function.json"
34
+
35
+ def _generate_examples(self, split_name, file_paths):
36
+ import json
37
+
38
+ js_all = json.load(open(file_paths["data"], encoding="utf-8"))
39
+
40
+ index = set()
41
+ with open(file_paths["index"], encoding="utf-8") as f:
42
+ for line in f:
43
+ line = line.strip()
44
+ index.add(int(line))
45
+
46
+ for idx, js in enumerate(js_all):
47
+ if idx in index:
48
+ js["id"] = idx
49
+ js["target"] = int(js["target"]) == 1
50
+ yield idx, js
51
+
52
+
53
+ CLASS_MAPPING = {
54
+ "CodeXGlueCcDefectDetection": CodeXGlueCcDefectDetectionImpl,
55
+ }
56
+
57
+
58
+ class CodeXGlueCcDefectDetection(datasets.GeneratorBasedBuilder):
59
+ BUILDER_CONFIG_CLASS = datasets.BuilderConfig
60
+ BUILDER_CONFIGS = [
61
+ datasets.BuilderConfig(name=name, description=info["description"]) for name, info in DEFINITIONS.items()
62
+ ]
63
+
64
+ def _info(self):
65
+ name = self.config.name
66
+ info = DEFINITIONS[name]
67
+ if info["class_name"] in CLASS_MAPPING:
68
+ self.child = CLASS_MAPPING[info["class_name"]](info)
69
+ else:
70
+ raise RuntimeError(f"Unknown python class for dataset configuration {name}")
71
+ ret = self.child._info()
72
+ return ret
73
+
74
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
75
+ return self.child._split_generators(dl_manager=dl_manager)
76
+
77
+ def _generate_examples(self, split_name, file_paths):
78
+ return self.child._generate_examples(split_name, file_paths)
common.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import List
2
+
3
+ import datasets
4
+
5
+
6
+ # Citation, taken from https://github.com/microsoft/CodeXGLUE
7
+ _DEFAULT_CITATION = """@article{CodeXGLUE,
8
+ title={CodeXGLUE: A Benchmark Dataset and Open Challenge for Code Intelligence},
9
+ year={2020},}"""
10
+
11
+
12
+ class Child:
13
+ _DESCRIPTION = None
14
+ _FEATURES = None
15
+ _CITATION = None
16
+ SPLITS = {"train": datasets.Split.TRAIN}
17
+ _SUPERVISED_KEYS = None
18
+
19
+ def __init__(self, info):
20
+ self.info = info
21
+
22
+ def homepage(self):
23
+ return self.info["project_url"]
24
+
25
+ def _info(self):
26
+ # This is the description that will appear on the datasets page.
27
+ return datasets.DatasetInfo(
28
+ description=self.info["description"] + "\n\n" + self._DESCRIPTION,
29
+ features=datasets.Features(self._FEATURES),
30
+ homepage=self.homepage(),
31
+ citation=self._CITATION or _DEFAULT_CITATION,
32
+ supervised_keys=self._SUPERVISED_KEYS,
33
+ )
34
+
35
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
36
+ SPLITS = self.SPLITS
37
+ _URL = self.info["raw_url"]
38
+ urls_to_download = {}
39
+ for split in SPLITS:
40
+ if split not in urls_to_download:
41
+ urls_to_download[split] = {}
42
+
43
+ for key, url in self.generate_urls(split):
44
+ if not url.startswith("http"):
45
+ url = _URL + "/" + url
46
+ urls_to_download[split][key] = url
47
+
48
+ downloaded_files = {}
49
+ for k, v in urls_to_download.items():
50
+ downloaded_files[k] = dl_manager.download_and_extract(v)
51
+
52
+ return [
53
+ datasets.SplitGenerator(
54
+ name=SPLITS[k],
55
+ gen_kwargs={"split_name": k, "file_paths": downloaded_files[k]},
56
+ )
57
+ for k in SPLITS
58
+ ]
59
+
60
+ def check_empty(self, entries):
61
+ all_empty = all([v == "" for v in entries.values()])
62
+ all_non_empty = all([v != "" for v in entries.values()])
63
+
64
+ if not all_non_empty and not all_empty:
65
+ raise RuntimeError("Parallel data files should have the same number of lines.")
66
+
67
+ return all_empty
68
+
69
+
70
+ class TrainValidTestChild(Child):
71
+ SPLITS = {
72
+ "train": datasets.Split.TRAIN,
73
+ "valid": datasets.Split.VALIDATION,
74
+ "test": datasets.Split.TEST,
75
+ }
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
1
+ {"default": {"description": "CodeXGLUE Defect-detection dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/Defect-detection\n\nGiven a source code, the task is to identify whether it is an insecure code that may attack software systems, such as resource leaks, use-after-free vulnerabilities and DoS attack. We treat the task as binary classification (0/1), where 1 stands for insecure code and 0 for secure code.\nThe dataset we use comes from the paper Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networks. We combine all projects and split 80%/10%/10% for training/dev/test.", "citation": "@inproceedings{zhou2019devign,\ntitle={Devign: Effective vulnerability identification by learning comprehensive program semantics via graph neural networks},\nauthor={Zhou, Yaqin and Liu, Shangqing and Siow, Jingkai and Du, Xiaoning and Liu, Yang},\nbooktitle={Advances in Neural Information Processing Systems},\npages={10197--10207}, year={2019}", "homepage": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Code/Defect-detection", "license": "", "features": {"id": {"dtype": "int32", "id": null, "_type": "Value"}, "func": {"dtype": "string", "id": null, "_type": "Value"}, "target": {"dtype": "bool", "id": null, "_type": "Value"}, "project": {"dtype": "string", "id": null, "_type": "Value"}, "commit_id": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": {"input": "target", "output": ""}, "task_templates": null, "builder_name": "code_x_glue_cc_defect_detection", "config_name": "default", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 45723487, "num_examples": 21854, "dataset_name": "code_x_glue_cc_defect_detection"}, "validation": {"name": "validation", "num_bytes": 5582545, "num_examples": 2732, "dataset_name": "code_x_glue_cc_defect_detection"}, "test": {"name": "test", "num_bytes": 5646752, "num_examples": 2732, "dataset_name": "code_x_glue_cc_defect_detection"}}, "download_checksums": {"https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Code/Defect-detection/dataset/train.txt": {"num_bytes": 122185, "checksum": "f0a25410594302a9f0e542a393ad82ad479308a8aa471f4d6cf61b91d6d572bf"}, "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Code/Defect-detection/dataset/function.json": {"num_bytes": 61532917, "checksum": "0a3b2d561dc6280e53795886ede727d0045c016d083905ba3e9ce384a7eab246"}, "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Code/Defect-detection/dataset/valid.txt": {"num_bytes": 15295, "checksum": "9f2fa1e108955f197d4a7fa2aa2c7f5e542457b51e0eb1f6e890172d6f700a6e"}, "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Code/Defect-detection/dataset/test.txt": {"num_bytes": 15318, "checksum": "b5336b337170ea1edf0570b69edb5a90e3c99bf41cd92909795f5fe32d376d52"}}, "download_size": 61685715, "post_processing_size": null, "dataset_size": 56952784, "size_in_bytes": 118638499}}
dummy/default/0.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d1d5e6ce75c2506167dcf500c1c29680db8946445e49db1b27345215cd6db2a0
3
+ size 21872
generated_definitions.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ DEFINITIONS = {
2
+ "default": {
3
+ "class_name": "CodeXGlueCcDefectDetection",
4
+ "dataset_type": "Code-Code",
5
+ "description": "CodeXGLUE Defect-detection dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/Defect-detection",
6
+ "dir_name": "Defect-detection",
7
+ "name": "default",
8
+ "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Code/Defect-detection",
9
+ "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Code/Defect-detection/dataset",
10
+ "sizes": {"test": 2732, "train": 21854, "validation": 2732},
11
+ }
12
+ }