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 
 
 
 
 
 
 
 
 
 
 
 
 
 
60012bb
1340dfb
33f4451
 
 
 
1340dfb
 
 
0bf6eef
1340dfb
0bf6eef
1340dfb
0bf6eef
 
 
 
1340dfb
0bf6eef
 
1340dfb
 
 
33f4451
 
1340dfb
 
 
 
 
 
 
 
 
 
 
 
0bf6eef
 
1340dfb
0bf6eef
1340dfb
0bf6eef
1340dfb
 
0bf6eef
 
1340dfb
0bf6eef
 
1340dfb
0bf6eef
 
 
 
 
1340dfb
0bf6eef
1340dfb
0bf6eef
1340dfb
0bf6eef
 
 
 
 
 
 
1340dfb
0bf6eef
 
 
1340dfb
0bf6eef
1340dfb
0bf6eef
 
 
 
 
 
 
 
 
1340dfb
0bf6eef
 
1340dfb
 
 
0bf6eef
 
 
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
---

pretty_name: "CodeDNA: Python Security Benchmark"
language:
- en
license: apache-2.0
task_categories:
- text-classification
size_categories:
- n<1K
tags:
- python
- code
- cybersecurity
- secure-coding
- synthetic
configs:
- config_name: default
  default: true
  data_files:
  - split: examples
    path: data/examples.jsonl
- config_name: corpus
  data_files:
  - split: train
    path: data/research/corpus/train.jsonl
  - split: validation
    path: data/research/corpus/validation.jsonl
  - split: test
    path: data/research/corpus/test.jsonl
- config_name: benchmark
  data_files:
  - split: train
    path: data/research/benchmark/train.jsonl
  - split: validation
    path: data/research/benchmark/validation.jsonl
  - split: test
    path: data/research/benchmark/test.jsonl
- config_name: official
  data_files:
  - split: train
    path: data/research/v3b2/official/train.jsonl
  - split: validation
    path: data/research/v3b2/official/validation.jsonl
  - split: test
    path: data/research/v3b2/official/test.jsonl
- config_name: corpus_3c1
  data_files:
  - split: train
    path: data/research/v3c1/corpus/train.jsonl
  - split: validation
    path: data/research/v3c1/corpus/validation.jsonl
  - split: test
    path: data/research/v3c1/corpus/test.jsonl
- config_name: official_3c1
  data_files:
  - split: train
    path: data/research/v3c1/official/train.jsonl
  - split: validation
    path: data/research/v3c1/official/validation.jsonl
  - split: test
    path: data/research/v3c1/official/test.jsonl
dataset_info:
- config_name: corpus
  features:
  - name: code
    dtype: string
  - name: code_files
    list:
    - name: code
      dtype: string
    - name: path
      dtype: string
  - name: cwe_id
    dtype: string
  - name: difficulty
    dtype: string
  - name: evidence_reference
    dtype: string
  - name: expected_finding
    dtype: bool
  - name: explanation
    dtype: string
  - name: fix_explanation
    dtype: string
  - name: framework
    dtype: string
  - name: hard_negative
    dtype: bool
  - name: id
    dtype: string
  - name: label
    dtype: string
  - name: language
    dtype: string
  - name: leakage_group_id
    dtype: string
  - name: pair_id
    dtype: string
  - name: pattern
    dtype: string
  - name: provenance
    struct:
    - name: authoring
      dtype: string
    - name: collection
      dtype: string
    - name: independent_human_review
      dtype: bool
    - name: origin
      dtype: string
  - name: review_note
    dtype: string
  - name: sample_id
    dtype: string
  - name: sanitization
    dtype: string
  - name: scenario_family_id
    dtype: string
  - name: secure_fix
    dtype: string
  - name: sink_location
    struct:
    - name: end_line
      dtype: int64
    - name: path
      dtype: string
    - name: start_line
      dtype: int64
  - name: source_location
    struct:
    - name: end_line
      dtype: int64
    - name: path
      dtype: string
    - name: start_line
      dtype: int64
  - name: source_type
    dtype: string
  - name: split
    dtype: string
  - name: taint_path
    list: string
  - name: verification_method
    dtype: string
  - name: verification_status
    dtype: string
  - name: vulnerability_type
    dtype: string
  - name: vulnerable_lines
    list:
    - name: end_line
      dtype: int64
    - name: path
      dtype: string
    - name: start_line
      dtype: int64
- config_name: benchmark
  features:
  - name: code
    dtype: string
  - name: code_files
    list:
    - name: code
      dtype: string
    - name: path
      dtype: string
  - name: cwe_id
    dtype: string
  - name: difficulty
    dtype: string
  - name: evidence_reference
    dtype: string
  - name: expected_finding
    dtype: bool
  - name: explanation
    dtype: string
  - name: fix_explanation
    dtype: string
  - name: framework
    dtype: string
  - name: hard_negative
    dtype: bool
  - name: id
    dtype: string
  - name: label
    dtype: string
  - name: language
    dtype: string
  - name: leakage_group_id
    dtype: string
  - name: pair_id
    dtype: string
  - name: pattern
    dtype: string
  - name: provenance
    struct:
    - name: authoring
      dtype: string
    - name: collection
      dtype: string
    - name: independent_human_review
      dtype: bool
    - name: origin
      dtype: string
  - name: review_note
    dtype: string
  - name: sample_id
    dtype: string
  - name: sanitization
    dtype: string
  - name: scenario_family_id
    dtype: string
  - name: secure_fix
    dtype: string
  - name: sink_location
    struct:
    - name: end_line
      dtype: int64
    - name: path
      dtype: string
    - name: start_line
      dtype: int64
  - name: source_location
    struct:
    - name: end_line
      dtype: int64
    - name: path
      dtype: string
    - name: start_line
      dtype: int64
  - name: source_type
    dtype: string
  - name: split
    dtype: string
  - name: taint_path
    list: string
  - name: verification_method
    dtype: string
  - name: verification_status
    dtype: string
  - name: vulnerability_type
    dtype: string
  - name: vulnerable_lines
    list:
    - name: end_line
      dtype: int64
    - name: path
      dtype: string
    - name: start_line
      dtype: int64
- config_name: official
  features:
  - name: code
    dtype: string
  - name: code_files
    list:
    - name: code
      dtype: string
    - name: path
      dtype: string
  - name: cwe_id
    dtype: string
  - name: difficulty
    dtype: string
  - name: evidence_reference
    dtype: string
  - name: expected_finding
    dtype: bool
  - name: explanation
    dtype: string
  - name: fix_explanation
    dtype: string
  - name: framework
    dtype: string
  - name: hard_negative
    dtype: bool
  - name: id
    dtype: string
  - name: label
    dtype: string
  - name: language
    dtype: string
  - name: leakage_group_id
    dtype: string
  - name: pair_id
    dtype: string
  - name: pattern
    dtype: string
  - name: provenance
    struct:
    - name: authoring
      dtype: string
    - name: collection
      dtype: string
    - name: independent_human_review
      dtype: bool
    - name: origin
      dtype: string
  - name: review_note
    dtype: string
  - name: sample_id
    dtype: string
  - name: sanitization
    dtype: string
  - name: scenario_family_id
    dtype: string
  - name: secure_fix
    dtype: string
  - name: sink_location
    struct:
    - name: end_line
      dtype: int64
    - name: path
      dtype: string
    - name: start_line
      dtype: int64
  - name: source_location
    struct:
    - name: end_line
      dtype: int64
    - name: path
      dtype: string
    - name: start_line
      dtype: int64
  - name: source_type
    dtype: string
  - name: split
    dtype: string
  - name: taint_path
    list: string
  - name: verification_method
    dtype: string
  - name: verification_status
    dtype: string
  - name: vulnerability_type
    dtype: string
  - name: vulnerable_lines
    list:
    - name: end_line
      dtype: int64
    - name: path
      dtype: string
    - name: start_line
      dtype: int64
- config_name: corpus_3c1
  features:
  - name: assumptions
    dtype: string
  - name: code
    dtype: string
  - name: code_files
    list:
    - name: code
      dtype: string
    - name: path
      dtype: string
  - name: code_sha256
    dtype: string
  - name: cwe_id
    dtype: string
  - name: cwe_rationale
    dtype: string
  - name: cwe_reference
    dtype: string
  - name: evidence_reference
    dtype: string
  - name: explanation
    dtype: string
  - name: framework
    dtype: string
  - name: full_behavior_contract
    dtype: bool
  - name: hard_negative
    dtype: bool
  - name: id
    dtype: string
  - name: independent_review
    dtype: bool
  - name: label
    dtype: string
  - name: leakage_group_id
    dtype: string
  - name: pair_id
    dtype: string
  - name: pattern
    dtype: string
  - name: sample_id
    dtype: string
  - name: scenario_family_id
    dtype: string
  - name: secure_fix
    dtype: string
  - name: sink_location
    struct:
    - name: end_line
      dtype: int64
    - name: path
      dtype: string
    - name: start_line
      dtype: int64
  - name: source_location
    struct:
    - name: end_line
      dtype: int64
    - name: path
      dtype: string
    - name: start_line
      dtype: int64
  - name: source_type
    dtype: string
  - name: split
    dtype: string
  - name: taint_path
    list: string
  - name: threat_model
    dtype: string
  - name: verification_contract
    dtype: string
  - name: verification_status
    dtype: string
  - name: vulnerable_lines
    list:
    - name: end_line
      dtype: int64
    - name: path
      dtype: string
    - name: start_line
      dtype: int64
- config_name: official_3c1
  features:
  - name: assumptions
    dtype: string
  - name: code
    dtype: string
  - name: code_files
    list:
    - name: code
      dtype: string
    - name: path
      dtype: string
  - name: code_sha256
    dtype: string
  - name: cwe_id
    dtype: string
  - name: cwe_rationale
    dtype: string
  - name: cwe_reference
    dtype: string
  - name: evidence_reference
    dtype: string
  - name: explanation
    dtype: string
  - name: framework
    dtype: string
  - name: full_behavior_contract
    dtype: bool
  - name: hard_negative
    dtype: bool
  - name: id
    dtype: string
  - name: independent_review
    dtype: bool
  - name: label
    dtype: string
  - name: leakage_group_id
    dtype: string
  - name: pair_id
    dtype: string
  - name: pattern
    dtype: string
  - name: sample_id
    dtype: string
  - name: scenario_family_id
    dtype: string
  - name: secure_fix
    dtype: string
  - name: sink_location
    struct:
    - name: end_line
      dtype: int64
    - name: path
      dtype: string
    - name: start_line
      dtype: int64
  - name: source_location
    struct:
    - name: end_line
      dtype: int64
    - name: path
      dtype: string
    - name: start_line
      dtype: int64
  - name: source_type
    dtype: string
  - name: split
    dtype: string
  - name: taint_path
    list: string
  - name: threat_model
    dtype: string
  - name: verification_contract
    dtype: string
  - name: verification_status
    dtype: string
  - name: vulnerable_lines
    list:
    - name: end_line
      dtype: int64
    - name: path
      dtype: string
    - name: start_line
      dtype: int64
---

# CodeDNA: Python Security Benchmark

An independent AI/ML security research project with original synthetic Python
examples for vulnerability detection, secure remediation and static analysis.
Paired implementations include explicit security assumptions and executable
verification.

**154 records · 34 CWE categories · 115 evidence-eligible examples · Apache-2.0**

[Documentation](docs/README.md) · [Methodology](docs/methodology.md) · [Release notes](docs/releases.md) · [Review protocol](docs/review.md)

## Scope

Examples cover SQL injection, command injection, path traversal, unsafe
deserialization, authorization, credential handling and related weaknesses.
Fixtures use Flask, FastAPI, SQLAlchemy and Python's standard library, including
cross-module flows and benign/adversarial checks.

This is a small educational research dataset. Examples are synthetic; labels have
not undergone independent human review. It is not a production vulnerability corpus.

## Quick start

Install `datasets` in a Python environment. This public dataset can be loaded
without a Hugging Face account or access token:

```python
from datasets import load_dataset

dataset = load_dataset(
    "Helinity/python-security-benchmark",
    "official_3c1",
    revision="v0.1.0",
)
print(dataset["test"][0]["code_files"])
```

Pin `v0.1.0` for reproducible experiments. See the
[reproduction instructions](docs/README.md#reproduction) for installation and checks.

## Configurations

| Configuration | Records | Use |
|---|---:|---|
| `default` | 64 | Original eight-field compatibility snapshot |
| `corpus` | 84 | Legacy research corpus, including excluded examples |
| `official` | 49 | Evidence-eligible subset of the legacy corpus |
| `corpus_3c1` | 70 | Application fixtures and hard negatives |
| `official_3c1` | 66 | Evidence-eligible subset of the application corpus |
| `benchmark` | 60 | Historical subset; not the current official evaluation set |

Names are stable API identifiers; `_3c1` identifies the application expansion.
The two corpora contain 154 distinct records. Their official subsets contain 115
records and are evaluated separately. Other configurations overlap these sets;
do not sum every row of the table. Use the declared splits: `default` includes
held-out examples and must not serve as training data for those evaluations.

## Evidence and limitations

- **Runtime evidence:** 82 eligible records have Docker evidence; 33 have
  controlled local-process property evidence, which is not an OS sandbox.
- **Validation:** the historical acceptance audit recorded 65 regression tests
  and 140 application contract checks. The migrated release passed 66 regression
  tests after a privacy-log regression test was added. These are separate runs.
- **Exclusions:** 39 records remain outside official scoring, including four
  HTML/redirect examples without sufficient sink context.
- **Human review:** pending. Secure labels depend on each example's assumptions;
  they do not establish the security of an entire application.

Use only `code` or `code_files` as detector inputs. Fixes, contracts, annotations
and explanations can disclose the expected label. Small synthetic fixtures and
small test splits do not support broad model-generalization claims.

## Repository

```text
data/       Versioned datasets, splits and evidence
curation/   Original example definitions
research/   Fixtures, generators, verification and evaluation
scripts/    Compatibility dataset generation and validation
tests/      Regression tests
docs/       Guides, methodology and historical audit reports
releases/   Frozen schemas, statistics, eligibility and review materials
```

The [documentation index](docs/README.md) separates current guidance from historical
reports. `main` carries documentation maintenance; the `v0.1.0` tag remains fixed.

## License and provenance

Authored with AI assistance for this project. No third-party dataset or proprietary
code was imported. Original examples and annotations use [Apache-2.0](LICENSE);
dependencies retain their own licenses.