guychuk commited on
Commit
eb64253
·
verified ·
1 Parent(s): f9088b1

Upload folder using huggingface_hub

Browse files
Files changed (6) hide show
  1. .gitattributes +2 -0
  2. README.md +235 -0
  3. full.jsonl +3 -0
  4. test.jsonl +0 -0
  5. train.jsonl +3 -0
  6. validation.jsonl +0 -0
.gitattributes CHANGED
@@ -57,3 +57,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
60
+ full.jsonl filter=lfs diff=lfs merge=lfs -text
61
+ train.jsonl filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ernest Nuclei Templates Dataset v3
2
+
3
+ A comprehensive dataset for training models to generate Nuclei security scanning templates from vulnerability descriptions.
4
+
5
+ ## Dataset Description
6
+
7
+ This dataset contains 11,590 training examples for generating Nuclei YAML templates in JSON IR (Intermediate Representation) format from structured vulnerability specifications.
8
+
9
+ ### Format
10
+
11
+ Each training example consists of:
12
+
13
+ 1. **`id`**: Unique identifier (CVE ID, CWE ID, or template name)
14
+ 2. **`prompt`**: Structured input with 4 sections (see below)
15
+ 3. **`completion`**: JSON IR output matching `nuclei_ir.schema.json`
16
+
17
+ ### Prompt Structure
18
+
19
+ The prompt contains exactly 4 sections in this order:
20
+
21
+ #### **[CANONICAL_RECORD]**
22
+ Structured vulnerability representation as JSON:
23
+ ```json
24
+ {
25
+ "cve_id": "cve-2024-1234",
26
+ "summary": "Description of vulnerability",
27
+ "affected_products": [{"vendor": "...", "product": "...", "version_range": "..."}],
28
+ "paths": ["/admin/upload.php"],
29
+ "indicators": ["error", "exception"],
30
+ "severity_hint": "high"
31
+ }
32
+ ```
33
+
34
+ #### **[RETRIEVED_TEMPLATES]**
35
+ JSON array of 2-3 similar templates (flattened, structural):
36
+ ```json
37
+ [
38
+ {
39
+ "id": "cve-2024-5678",
40
+ "severity": "high",
41
+ "tags": ["cve", "sqli", "apache"],
42
+ "requests": [
43
+ {
44
+ "method": "GET",
45
+ "paths": ["{{BaseURL}}/admin.php?id=1"],
46
+ "matcher_types": ["word", "status"]
47
+ }
48
+ ]
49
+ }
50
+ ]
51
+ ```
52
+
53
+ #### **[POC_SNIPPETS]**
54
+ JSON array of PoC snippets (or empty array):
55
+ ```json
56
+ [
57
+ {
58
+ "source": "nvd",
59
+ "url": "https://...",
60
+ "snippet": "curl -X POST ..."
61
+ }
62
+ ]
63
+ ```
64
+
65
+ #### **[INSTRUCTION]**
66
+ Fixed instruction text:
67
+ ```
68
+ Generate a valid Nuclei template as JSON IR. Output ONLY the JSON object matching nuclei_ir.schema.json. No markdown, no explanations, no code fences.
69
+ ```
70
+
71
+ ### Completion Format
72
+
73
+ Pure JSON IR matching `nuclei_ir.schema.json`:
74
+ ```json
75
+ {
76
+ "id": "cve-2024-1234",
77
+ "info": {
78
+ "name": "XSS Vulnerability in Product X",
79
+ "author": "ernest-generator",
80
+ "severity": "high",
81
+ "description": "...",
82
+ "tags": ["cve", "xss"],
83
+ "reference": ["https://..."]
84
+ },
85
+ "requests": [
86
+ {
87
+ "method": "GET",
88
+ "path": ["{{BaseURL}}/vulnerable.php"],
89
+ "matchers": [...]
90
+ }
91
+ ],
92
+ "safety_flags": {...},
93
+ "limits": {...},
94
+ "metadata": {...}
95
+ }
96
+ ```
97
+
98
+ **No markdown, no code fences, no extra text** - ONLY the JSON object.
99
+
100
+ ## Dataset Statistics
101
+
102
+ - **Total examples**: 11,590
103
+ - **Train split**: 8,112 (70%)
104
+ - **Test split**: 1,736 (15%)
105
+ - **Validation split**: 1,742 (15%)
106
+
107
+ ### By Category
108
+
109
+ - **CVE-based**: 3,666 (31.6%) - Enriched with NVD CVE data
110
+ - **CWE-based**: 2,499 (21.6%) - Enriched with MITRE CWE data
111
+ - **Generic**: 5,425 (46.8%) - Self-contained templates
112
+
113
+ ### File Sizes
114
+
115
+ - `full.jsonl`: 60 MB
116
+ - `train.jsonl`: 42 MB
117
+ - `test.jsonl`: 9 MB
118
+ - `validation.jsonl`: 9 MB
119
+
120
+ ## Usage
121
+
122
+ ### Loading the Dataset
123
+
124
+ ```python
125
+ from datasets import load_dataset
126
+
127
+ # Load from local files
128
+ dataset = load_dataset('json', data_files={
129
+ 'train': 'train.jsonl',
130
+ 'test': 'test.jsonl',
131
+ 'validation': 'validation.jsonl'
132
+ })
133
+
134
+ # Or from Hugging Face Hub
135
+ # dataset = load_dataset('OzLabs/ernest-nuclei-templates-v3')
136
+
137
+ # Access a training example
138
+ example = dataset['train'][0]
139
+ print(f"ID: {example['id']}")
140
+ print(f"\nPrompt:\n{example['prompt'][:500]}...")
141
+ print(f"\nCompletion:\n{example['completion'][:500]}...")
142
+ ```
143
+
144
+ ### Fine-tuning Example
145
+
146
+ ```python
147
+ from transformers import AutoTokenizer, AutoModelForCausalLM
148
+
149
+ model_name = "Qwen/Qwen2.5-Coder-7B-Instruct"
150
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
151
+ model = AutoModelForCausalLM.from_pretrained(model_name)
152
+
153
+ def format_example(example):
154
+ """Format example for instruction tuning."""
155
+ return {
156
+ "input": example["prompt"],
157
+ "output": example["completion"]
158
+ }
159
+
160
+ # Prepare dataset
161
+ formatted_dataset = dataset.map(format_example)
162
+
163
+ # Fine-tune with your preferred framework (TRL, Axolotl, etc.)
164
+ ```
165
+
166
+ ## Data Source
167
+
168
+ Templates extracted from [ProjectDiscovery/nuclei-templates](https://github.com/projectdiscovery/nuclei-templates) repository and enriched with:
169
+
170
+ - **CVE Data**: National Vulnerability Database (NVD) API 2.0
171
+ - **CWE Data**: MITRE Common Weakness Enumeration
172
+ - **Template Similarity**: Pre-computed similar templates for few-shot learning
173
+
174
+ ## Schema Validation
175
+
176
+ ~70% of examples pass strict JSON schema validation. Validation failures are mostly due to:
177
+ - Empty path arrays (legitimate for SSL/TLS templates)
178
+ - Templates with minimal matchers
179
+
180
+ The prompt structure (4 sections) is valid for 100% of examples.
181
+
182
+ ## Intended Use
183
+
184
+ This dataset is designed for:
185
+
186
+ 1. **Fine-tuning** code generation models (Qwen, CodeLlama, DeepSeek Coder, etc.)
187
+ 2. **Few-shot learning** for security template generation
188
+ 3. **Research** on structured code generation from specifications
189
+
190
+ ## Model Recommendations
191
+
192
+ Best suited for instruction-tuned models:
193
+ - **Qwen2.5-Coder** (1.5B - 32B)
194
+ - **CodeLlama-Instruct** (7B - 34B)
195
+ - **DeepSeek-Coder-Instruct** (6.7B - 33B)
196
+ - **StarCoder2-Instruct** (3B - 15B)
197
+
198
+ ## Citation
199
+
200
+ If you use this dataset, please cite:
201
+
202
+ ```bibtex
203
+ @dataset{ernest_nuclei_v3_2025,
204
+ title={Ernest Nuclei Templates Dataset v3},
205
+ author={OzLabs},
206
+ year={2025},
207
+ publisher={Hugging Face},
208
+ howpublished={\url{https://huggingface.co/datasets/OzLabs/ernest-nuclei-templates-v3}}
209
+ }
210
+ ```
211
+
212
+ ## License
213
+
214
+ This dataset is derived from Nuclei templates which are licensed under MIT. The dataset itself is released under MIT License.
215
+
216
+ ## Changelog
217
+
218
+ ### v3 (2025-01-13)
219
+ - Complete restructuring to match specification
220
+ - Added CANONICAL_RECORD with structured vulnerability data
221
+ - Added RETRIEVED_TEMPLATES for few-shot learning
222
+ - Added POC_SNIPPETS from CVE references
223
+ - JSON IR completions (no YAML, no markdown)
224
+ - Optimized similarity matching (O(n) vs O(n²))
225
+ - 11,590 training pairs (99.8% success rate)
226
+
227
+ ## Contact
228
+
229
+ - **Organization**: [OzLabs](https://github.com/OzLabs)
230
+ - **Project**: [Ernest](https://github.com/OzLabs/ernest)
231
+ - **Issues**: https://github.com/OzLabs/ernest/issues
232
+
233
+ ---
234
+
235
+ **Note**: This dataset is for security research and defensive purposes only. Generated templates should be validated before use in production environments.
full.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a9161df0c07af5cd4aa4033c18cf8058518cc9cf3c15973cebc974fb5983d57
3
+ size 62880830
test.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
train.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:70307031da493fc7996cb10c9814e91af95b48e75151e56027925d513422f8cb
3
+ size 46737190
validation.jsonl ADDED
The diff for this file is too large to render. See raw diff