Zreby commited on
Commit
d400b15
·
verified ·
1 Parent(s): 50ef647

Add audited multi-source security code dataset

Browse files
CURATION_DECISIONS.md ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Keputusan kurasi dan sumber yang ditahan
2
+
3
+ Rilis ini hanya memuat sampel yang memiliki bukti lisensi atau status penggunaan ulang yang cukup jelas untuk subset spesifiknya. Tautan publik atau penggunaan untuk riset saja tidak dianggap izin redistribusi. Menyimpan repo Hugging Face secara privat juga tidak menghapus kewajiban lisensi.
4
+
5
+ ## Disertakan
6
+
7
+ - **Juliet Java 1.3 #111 dan Juliet C# 1.3 #110:** halaman resmi NIST secara khusus menyatakan public domain di AS serta CC0 1.0 sejauh NIST mungkin mempunyai hak di luar AS. Hanya berkas kasus uji terpilih yang disertakan; arsip lengkap, pustaka, dokumentasi, dan berkas pendukung tidak disalin.
8
+ - **OpenZeppelin Contracts v5.7.0:** hanya lima berkas Solidity terpilih, masing-masing dengan penanda `SPDX-License-Identifier: MIT`. Teks MIT asli disertakan. Kode diperlakukan sebagai referensi komponen, bukan bukti bahwa aplikasi yang menggunakannya aman.
9
+ - **OWASP Juice Shop:** hanya subset first-party di `data/static/codefixes/` pada commit `c9f99228d9d56afb5f5ca7925376292f7fa44b13`, setelah pencocokan metadata `.info.yml`, kandidat bernomor, dan file `_correct`. Lisensi root pada commit memberi izin MIT; salinan noticenya disertakan. 83 pasangan TypeScript/YAML dari 33 challenge disertakan. `_correct` hanya dilabel sebagai “ditandai benar oleh challenge”; alternatif lain bukan otomatis rentan. Berkas dengan notice SPDX/hak cipta eksplisit atau pola umum kunci rahasia ditahan. Companion guide tidak disalin karena memakai lisensi berbeda CC BY-NC-ND.
10
+
11
+ ## Dikeluarkan atau ditahan
12
+
13
+ - **Semgrep rules:** lisensi Rules v1.0 yang diperiksa membatasi penggunaan untuk kepentingan internal dan tidak mengizinkan distribusi rules; fixture juga tidak otomatis tercakup lisensi yang sama.
14
+ - **Sealevel Attacks:** repositori yang diperiksa tidak menyatakan lisensi yang memberi izin eksplisit redistribusi kode.
15
+ - **DiverseVul:** tidak ditemukan lisensi dataset/kode pada repositori; CC BY 4.0 pada artikelnya tidak otomatis melisensikan contoh kode yang dikumpulkan dari repositori lain.
16
+ - **SmartBugs Curated:** Apache-2.0 berlaku pada berkas tertentu di repositori, tetapi README menyebut kontrak mempertahankan lisensi asal masing-masing. Sampel kontrak tidak disertakan tanpa audit lisensi per berkas.
17
+ - **SWC Registry:** lisensi MIT di akar repositori tidak cukup untuk memastikan asal dan hak redistribusi semua contoh pada tiap entri; tidak ada contoh kode SWC yang disalin.
18
+ - **Big-Vul dan CVEfixes:** lisensi perangkat lunak pengumpul atau metadata agregat tidak otomatis mencakup fungsi kode upstream dari banyak proyek. Sampel tidak disertakan karena audit lisensi pada setiap repo/commit/file sumber belum dilakukan.
19
+ - **OWASP Benchmark Java:** proyek menyatakan GPLv2; tidak dimasukkan karena subset kode dan kewajiban lisensi turunannya belum diaudit per berkas.
20
+ - **NIST Juliet C/C++ 1.3 #112:** tidak diambil dalam rilis ini agar tidak menduplikasi cakupan Juliet C/C++ yang sudah ada di repo lain milik pengguna. Repo lama tidak diubah.
21
+ - **OWASP NodeGoat, GitHub CodeQL, OWASP crAPI, MITRE CWE examples, dan OWASP Cheat Sheets:** lisensi proyek yang ditinjau memberi dasar awal berbeda-beda, tetapi belum dilakukan audit seluruh file/fixture atau validasi label untuk rilis ini. Jangan menganggap lisensi akar otomatis mencakup semua fixture atau kode pihak ketiga; sumber tersebut belum disalin.
22
+
23
+ Keputusan ini bukan penetapan hukum. Untuk sumber yang ditahan, materi dapat dipertimbangkan dalam rilis berikutnya bila izin pemegang hak atau audit file/commit membuktikan hak redistribusi dan ketentuan yang berlaku. Rincian kandidat dan tautan audit ada di `NON_JULIET_AUDIT.md`.
DATA_SOURCES.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Sumber dan provenance
2
+
3
+ ## NIST SARD Juliet 1.3 — Java
4
+
5
+ - Halaman suite resmi #111: https://samate.nist.gov/SARD/test-suites/111
6
+ - Arsip resmi: https://samate.nist.gov/SARD/downloads/test-suites/2017-10-01-juliet-test-suite-for-java-v1-3.zip
7
+ - Suite mencakup kasus uji Java untuk 112 CWE. Halaman NIST menyatakan bahwa Juliet Java 1.3 tidak dilindungi hak cipta dan berada di public domain di Amerika Serikat; sejauh NIST mungkin memiliki hak di luar AS, NIST menyediakan suite di bawah CC0 1.0.
8
+ - SHA-256 arsip yang diunduh: `d985f4177c2bcd7b03455a05c1c8f2e755f55c9eb250accd052f05f877347e60`.
9
+ - Seleksi: 101 berkas kasus uji, satu per CWE yang memenuhi kriteria pasangan metode `Bad`/`Good*`, berasal dari `Java/src/testcases/`. Berkas pendukung, pustaka, JAR, dokumentasi, dan materi di luar berkas kasus uji tidak dimasukkan.
10
+
11
+ ## NIST SARD Juliet 1.3 — C#
12
+
13
+ - Halaman suite resmi #110: https://samate.nist.gov/SARD/test-suites/110
14
+ - Arsip resmi: https://samate.nist.gov/SARD/downloads/test-suites/2020-08-01-juliet-test-suite-for-csharp-v1-3.zip
15
+ - Suite mencakup kasus uji C# untuk 105 CWE. Halaman NIST menyatakan bahwa Juliet C# 1.3 tidak dilindungi hak cipta dan berada di public domain di Amerika Serikat; sejauh NIST mungkin memiliki hak di luar AS, NIST menyediakan suite di bawah CC0 1.0.
16
+ - SHA-256 arsip yang diunduh: `2e6dbac4741fb020a0b1c2db69e98aed165987df2bd70bd51f7c8c5302c8e8f8`.
17
+ - Seleksi: 103 berkas kasus uji, satu per CWE yang memenuhi kriteria pasangan metode `Bad`/`Good*`, berasal dari `src/testcases/`. Berkas pendukung, pustaka, dokumentasi, dan materi di luar berkas kasus uji tidak dimasukkan.
18
+
19
+ Untuk kedua suite, sampel dipilih deterministik: urutkan jalur berkas secara leksikografis, lalu ambil berkas pertama per bahasa/CWE yang memiliki metode `Bad` dan sekurangnya satu metode `Good*`. Berkas dengan deklarasi SPDX atau pemberitahuan hak cipta eksplisit pada 30 baris awal ditahan. Hash SHA-256 konten sumber setiap rekaman tercatat di `provenance_json`.
20
+
21
+ ## OpenZeppelin Contracts v5.7.0 — Solidity
22
+
23
+ - Tag rilis: https://github.com/OpenZeppelin/openzeppelin-contracts/tree/v5.7.0
24
+ - README proyek menyatakan Contracts dirilis di bawah MIT; setiap berkas yang dipilih juga diawali `SPDX-License-Identifier: MIT`.
25
+ - Teks lisensi sumber disertakan sebagai `OPENZEPPELIN-MIT.txt`.
26
+ - Lima berkas: `contracts/token/ERC20/ERC20.sol`, `contracts/access/Ownable.sol`, `contracts/access/AccessControl.sol`, `contracts/utils/ReentrancyGuard.sol`, dan `contracts/utils/Pausable.sol`.
27
+ - URL sumber, hash SHA-256, dan lisensi tercatat pada setiap rekaman.
28
+
29
+ ## OWASP Juice Shop — code-fix challenges
30
+
31
+ - Repositori: https://github.com/juice-shop/juice-shop
32
+ - Commit dipatok: `c9f99228d9d56afb5f5ca7925376292f7fa44b13` (snapshot branch `master` yang diidentifikasi saat audit). Commit immutable: https://github.com/juice-shop/juice-shop/tree/c9f99228d9d56afb5f5ca7925376292f7fa44b13 ; API: https://api.github.com/repos/juice-shop/juice-shop/commits/c9f99228d9d56afb5f5ca7925376292f7fa44b13
33
+ - Lisensi: file `LICENSE` akar pada commit tersebut memberikan izin MIT. Salinan persis disertakan sebagai `LICENSES/OWASP-JUICE-SHOP-MIT.txt`. Tautan teks berlisensi: https://raw.githubusercontent.com/juice-shop/juice-shop/c9f99228d9d56afb5f5ca7925376292f7fa44b13/LICENSE
34
+ - Cakupan: hanya berkas `.ts` dan `.yml` first-party di `data/static/codefixes/` yang memiliki metadata `.info.yml`, sekurangnya satu alternatif bernomor, dan berkas pasangan bernama `_correct`. Tidak ada source di luar folder tersebut yang disalin. File dengan notice SPDX/hak cipta eksplisit di 30 baris pertama atau pola kunci rahasia umum ditahan.
35
+ - Hasil: 83 pasangan dari 33 kelompok challenge (71 TypeScript, 12 YAML). Setiap rekaman memuat jalur, URL blob mentah pada commit yang dipatok, SHA-256 kandidat/solusi/metadata, serta penjelasan `fixes` dari metadata resmi.
36
+ - Semantik label: `_correct` berarti ditandai benar oleh challenge Juice Shop; alternatif lain berarti `not_marked_correct_by_upstream_challenge`. Label tidak menyatakan bahwa alternatif itu pasti exploitable atau solusi resmi selalu aman di sistem lain. Tidak ada CWE yang ditambahkan tanpa sumber eksplisit.
37
+ - Companion guide Juice Shop tidak disalin; proyek OWASP menyatakan lisensi CC BY-NC-ND yang berbeda untuk panduan: https://pwning.owasp-juice.shop/companion-guide/latest/ .
38
+ - Bukti lisensi proyek: https://owasp.org/www-project-juice-shop/ dan https://raw.githubusercontent.com/juice-shop/juice-shop/master/LICENSE . Tiap file yang diambil tetap ditinjau; lisensi root tidak diasumsikan mencakup dependency atau materi pihak ketiga di luar subset.
39
+
40
+ ## Bentuk rilis
41
+
42
+ `data/*.jsonl` berisi skema kolom seragam. Field `provenance_json` mempertahankan metadata yang diperlukan untuk menelusuri rekaman ke sumbernya; `labels_json` mempertahankan objek label sumber dalam bentuk JSON string. File di `staging/` hanya perantara untuk pipeline, bukan berkas dataset final.
43
+
44
+ Lisensi repositori induk tidak diasumsikan berlaku pada materi lain yang tidak dipilih. Tidak ada satu lisensi gabungan yang diterapkan kepada semua subset.
LICENSES/NIST-JULIET.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Lisensi sumber NIST Juliet 1.3
2
+
3
+ Halaman suite resmi NIST menyatakan bahwa Juliet Java 1.3 (#111) dan Juliet C# 1.3 (#110) tidak dilindungi hak cipta dan berada di public domain di Amerika Serikat. Halaman tersebut menambahkan bahwa, sejauh NIST mungkin memiliki hak di luar AS, suite disediakan di bawah CC0 1.0 Public Domain License.
4
+
5
+ - Java 1.3, suite #111: https://samate.nist.gov/SARD/test-suites/111
6
+ - C# 1.3, suite #110: https://samate.nist.gov/SARD/test-suites/110
7
+ - Teks CC0 1.0: https://creativecommons.org/publicdomain/zero/1.0/legalcode
8
+
9
+ Pernyataan ini diterapkan hanya pada versi suite yang disebutkan dan sampel yang dipilih dari dalam suite tersebut. Jangan memperluasnya ke arsip, versi, suite, pustaka, atau file pihak ketiga lain tanpa memeriksa lisensi masing-masing.
LICENSES/OWASP-JUICE-SHOP-MIT.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2014-2026 Bjoern Kimminich & the OWASP Juice Shop contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
NON_JULIET_AUDIT.md ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Catatan audit sumber non-Juliet
2
+
3
+ ## OWASP Juice Shop
4
+
5
+ README dan LICENSE resmi menyatakan MIT untuk perangkat lunak proyek. MIT memberi hak salin, modifikasi, dan distribusi dengan kewajiban mempertahankan copyright/permission notice. Batas penting: companion guide/eBook memakai CC BY-NC-ND 4.0, bukan MIT; jangan mengambil atau mengolah materi guide. Root MIT tidak otomatis mencakup dependency, aset, fixture pihak ketiga, generated code, atau file dengan notice lain. Untuk rilis ini, scraping dibatasi ke berkas TypeScript first-party di `data/static/codefixes/` pada commit `c9f99228d9d56afb5f5ca7925376292f7fa44b13`; setiap file yang dipakai harus diperiksa header/notices. README/License yang diperiksa tidak memuat larangan AI/ML eksplisit; ini bukan izin AI khusus, hanya penggunaan sesuai MIT untuk file yang tercakup.
6
+
7
+ Sumber: https://github.com/juice-shop/juice-shop ; https://raw.githubusercontent.com/juice-shop/juice-shop/master/LICENSE ; https://owasp.org/www-project-juice-shop/ ; https://pwning.owasp-juice.shop/companion-guide/latest/ . Commit yang dipatok didapat dari GitHub API untuk branch `master`: https://api.github.com/repos/juice-shop/juice-shop/commits/master .
8
+
9
+ Repositori menyediakan codefix challenge metadata di `data/static/codefixes/*.info.yml` serta pasangan kandidat dan berkas dengan akhiran `_correct.ts`. Contoh metadata resmi menerangkan perbedaan antara blocklist SQL injection dan parameter binding, mengapa sanitization bypass yang tidak perlu menyebabkan local XSS, dan mengapa membuka rute log merupakan kebocoran. File `_correct.ts` adalah label challenge yang eksplisit; file kandidat lain tidak otomatis rentan, sehingga data akan memberi label `not_marked_correct` dan bukan `vulnerable` kecuali sumber membuktikannya.
10
+
11
+ Contoh sumber yang sudah dibaca langsung:
12
+ - SQL injection metadata: https://raw.githubusercontent.com/juice-shop/juice-shop/c9f99228d9d56afb5f5ca7925376292f7fa44b13/data/static/codefixes/unionSqlInjectionChallenge.info.yml
13
+ - SQL candidate #1: https://raw.githubusercontent.com/juice-shop/juice-shop/c9f99228d9d56afb5f5ca7925376292f7fa44b13/data/static/codefixes/unionSqlInjectionChallenge_1.ts
14
+ - SQL source-marked correct #2: https://raw.githubusercontent.com/juice-shop/juice-shop/c9f99228d9d56afb5f5ca7925376292f7fa44b13/data/static/codefixes/unionSqlInjectionChallenge_2_correct.ts
15
+ - Local XSS metadata: https://raw.githubusercontent.com/juice-shop/juice-shop/c9f99228d9d56afb5f5ca7925376292f7fa44b13/data/static/codefixes/localXssChallenge.info.yml
16
+ - Local XSS candidate #1: https://raw.githubusercontent.com/juice-shop/juice-shop/c9f99228d9d56afb5f5ca7925376292f7fa44b13/data/static/codefixes/localXssChallenge_1.ts
17
+ - Local XSS source-marked correct #2: https://raw.githubusercontent.com/juice-shop/juice-shop/c9f99228d9d56afb5f5ca7925376292f7fa44b13/data/static/codefixes/localXssChallenge_2_correct.ts
18
+ - Access log disclosure metadata: https://raw.githubusercontent.com/juice-shop/juice-shop/c9f99228d9d56afb5f5ca7925376292f7fa44b13/data/static/codefixes/accessLogDisclosureChallenge.info.yml
19
+
20
+ ## Kandidat lain yang belum diambil
21
+
22
+ OWASP NodeGoat memiliki Apache-2.0 di root; sample yang benar-benar tercakup dapat dimodifikasi dan didistribusikan dengan salinan lisensi, notices, serta pemberitahuan perubahan yang disyaratkan, tetapi masih perlu audit file-level dan validasi pasangan rentan/perbaikan.
23
+
24
+ GitHub CodeQL menyatakan kode di repositori query berlisensi MIT; test fixtures berpotensi memberi expected-result labels, tetapi setiap sample perlu cek provenance dan notice. Jangan mencampur CodeQL CLI/engine dari repositori terpisah dengan lisensi berbeda.
25
+
26
+ OWASP crAPI juga memiliki Apache-2.0, tetapi repo multi-service memerlukan pemeriksaan per-file terhadap third-party, fixtures, generated artifacts, dan labels. MITRE CWE terms mengizinkan penggunaan research/development dengan copyright/license notice, tetapi bukan lisensi MIT blanket untuk semua snippet; asal dan hak tiap contoh perlu dipastikan. OWASP Cheat Sheet Series berlisensi CC BY-SA 4.0: adaptasi dapat didistribusikan dengan atribusi, perubahan, dan ShareAlike; sebagian besar contoh bersifat potongan kontekstual, sehingga tidak dijadikan label vuln-code ground truth dalam rilis ini.
27
+
28
+ Sumber kandidat: https://github.com/OWASP/NodeGoat ; https://github.com/github/codeql ; https://github.com/OWASP/crAPI ; https://cwe.mitre.org/about/termsofuse.html ; https://github.com/OWASP/CheatSheetSeries/blob/master/LICENSE.md .
OPENZEPPELIN-MIT.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016-2026 Zeppelin Group Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included
14
+ in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
README.md ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: Korpus Kode Keamanan Terkurasi — Juliet, OWASP Juice Shop, dan OpenZeppelin
3
+ language:
4
+ - id
5
+ - en
6
+ license: other
7
+ size_categories:
8
+ - n<1K
9
+ task_categories:
10
+ - text-generation
11
+ tags:
12
+ - secure-coding
13
+ - vulnerability-detection
14
+ - code-review
15
+ - code-fix
16
+ - nist-juliet
17
+ - owasp-juice-shop
18
+ - openzeppelin
19
+ - smart-contracts
20
+ - java
21
+ - c-sharp
22
+ - typescript
23
+ - yaml
24
+ - solidity
25
+ ---
26
+
27
+ # Korpus Kode Keamanan Terkurasi
28
+
29
+ Korpus ini menggabungkan **292 rekaman** dari tiga sumber yang lolos pemeriksaan lisensi untuk subset terpilih: 204 kasus uji Juliet NIST, 83 pasangan kandidat/perbaikan OWASP Juice Shop, dan 5 referensi Solidity OpenZeppelin. Repo ditujukan privat; status privat tidak menghapus kewajiban lisensi atau atribusi.
30
+
31
+ ## Isi dan split
32
+
33
+ | Berkas | Rekaman | Isi |
34
+ |---|---:|---|
35
+ | `data/train.jsonl` | 171 | Sampel Juliet Java/C# untuk train; seluruh bahasa pada CWE yang sama tetap dalam split sama. |
36
+ | `data/validation.jsonl` | 18 | Sampel Juliet validation. |
37
+ | `data/test.jsonl` | 15 | Sampel Juliet test. |
38
+ | `data/challenge_fix.jsonl` | 83 | 71 TypeScript dan 12 YAML dari 33 kelompok challenge Juice Shop. |
39
+ | `data/reference.jsonl` | 5 | Berkas Solidity OpenZeppelin sebagai referensi, bukan label vuln/secure. |
40
+
41
+ Semua berkas final menggunakan kolom yang sama: `id`, `source`, `task_type`, `domain`, `language`, `instruction`, `input`, `output`, `split`, `labels_json`, dan `provenance_json`. Kolom `provenance_json` menyimpan detail URL/path sumber, commit/versi, lisensi, kebijakan seleksi, dan hash. Untuk Juliet dan Juice Shop, `output` adalah JSON label yang berasal dari struktur sumber; untuk OpenZeppelin, `output` adalah ringkasan fungsi komponen.
42
+
43
+ Contoh memuat split dengan Hugging Face Datasets:
44
+
45
+ ```python
46
+ from datasets import load_dataset
47
+
48
+ data = load_dataset("json", data_files={
49
+ "train": "data/train.jsonl",
50
+ "validation": "data/validation.jsonl",
51
+ "test": "data/test.jsonl",
52
+ "challenge_fix": "data/challenge_fix.jsonl",
53
+ "reference": "data/reference.jsonl",
54
+ })
55
+ ```
56
+
57
+ `challenge_fix` sengaja dipisahkan dari train/test Juliet: pilihan alternatif dan solusi resmi berasal dari kelompok challenge yang sama, sehingga tidak layak diperlakukan sebagai evaluasi independen. `reference` juga bukan data evaluasi keamanan.
58
+
59
+ ## Batas label dan penggunaan
60
+
61
+ **Juliet** adalah benchmark sintetis untuk kelemahan tertentu. Label metode `Bad` dan `Good*` mengikuti penanda eksplisit pada berkas uji; label `Good` bukan jaminan bahwa keseluruhan program aman atau siap produksi. Sampel dapat mengandalkan kelas pendukung yang tidak termasuk dalam subset.
62
+
63
+ **Juice Shop** menyediakan beberapa alternatif code-fix dan file yang berakhiran `_correct`. Label hanya menyatakan bahwa upstream menandai satu alternatif sebagai benar dalam challenge tersebut. Alternatif lain diberi label `not_marked_correct`, **bukan** otomatis “vulnerable”; solusi challenge juga bukan jaminan keamanan universal. Metadata penjelasan diambil dari `.info.yml`. Tidak ada CWE yang direka untuk sampel ini.
64
+
65
+ **OpenZeppelin** memuat lima berkas library MIT sebagai referensi pola kontrak. Rekaman ini bukan contoh rentan, bukan aplikasi lengkap, dan bukan audit sistem yang mengintegrasikannya.
66
+
67
+ ## Lisensi dan provenance
68
+
69
+ Tidak ada satu lisensi untuk seluruh gabungan. Juliet Java 1.3 #111 dan C# 1.3 #110 dinyatakan NIST berada di public domain di AS, serta CC0 1.0 sejauh NIST mungkin memiliki hak di luar AS. OpenZeppelin Contracts v5.7.0 dan subset Juice Shop yang dipilih memakai MIT; salinan teks MIT sumber disertakan di `OPENZEPPELIN-MIT.txt` dan `LICENSES/OWASP-JUICE-SHOP-MIT.txt`. Lihat `DATA_SOURCES.md`, `CURATION_DECISIONS.md`, `NON_JULIET_AUDIT.md`, serta metadata setiap rekaman sebelum memakai atau membagikan subset.
70
+
71
+ Juice Shop dipatok ke commit `c9f99228d9d56afb5f5ca7925376292f7fa44b13`. Companion guide OWASP Juice Shop yang berlisensi berbeda tidak disalin. Audit sumber yang belum lolos atau hanya memberi hak terbatas dicatat di `NON_JULIET_AUDIT.md` dan dikeluarkan.
72
+
73
+ ## Reproduksi
74
+
75
+ `curate.py`, `scrape_juice_shop.py`, dan `build_release.py` mereproduksi seleksi serta split final dari arsip Juliet, berkas OpenZeppelin v5.7.0, dan commit Juice Shop yang dipatok. Sumber antara berada di `staging/` dan bukan berkas dataset final. Instruksi/tautan unduhan dan hash sumber tercatat di `DATA_SOURCES.md`; kebutuhan Python ada di `requirements.txt`.
build_release.py ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Normalize audited source-specific records into consistent Hugging Face JSONL splits."""
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import hashlib
7
+ import json
8
+ from collections import Counter, defaultdict
9
+ from pathlib import Path
10
+
11
+ SOURCE_FILES = (
12
+ "juliet_paired_review.jsonl",
13
+ "openzeppelin_solidity_references.jsonl",
14
+ "juice_shop_codefix_pairs.jsonl",
15
+ )
16
+ FIELDS = (
17
+ "id", "source", "task_type", "domain", "language", "instruction",
18
+ "input", "output", "split", "labels_json", "provenance_json",
19
+ )
20
+ CORE = {"id", "task_type", "domain", "language", "instruction", "input", "output", "split"}
21
+
22
+
23
+ def read_jsonl(path: Path) -> list[dict]:
24
+ rows = []
25
+ with path.open(encoding="utf-8") as handle:
26
+ for line_number, line in enumerate(handle, 1):
27
+ if not line.strip():
28
+ continue
29
+ value = json.loads(line)
30
+ if not isinstance(value, dict):
31
+ raise ValueError(f"{path}:{line_number}: expected a JSON object")
32
+ rows.append(value)
33
+ return rows
34
+
35
+
36
+ def parse_label_output(row: dict) -> object:
37
+ try:
38
+ parsed = json.loads(row["output"])
39
+ if isinstance(parsed, dict):
40
+ return parsed
41
+ except (json.JSONDecodeError, TypeError):
42
+ pass
43
+ return {"reference_summary": row["output"]}
44
+
45
+
46
+ def source_name(row: dict) -> str:
47
+ if "source_suite" in row:
48
+ return row["source_suite"]
49
+ if "source_repo" in row:
50
+ return "OWASP Juice Shop"
51
+ if "source_version" in row:
52
+ return f"OpenZeppelin Contracts {row['source_version']}"
53
+ raise ValueError(f"Cannot identify source for {row.get('id')}")
54
+
55
+
56
+ def validate_source_record(row: dict) -> None:
57
+ for key in CORE:
58
+ if key not in row:
59
+ raise ValueError(f"Record {row.get('id')} lacks {key}")
60
+ if not all(isinstance(row[key], str) for key in ("id", "input", "output", "language", "instruction")):
61
+ raise TypeError(f"Record {row['id']} has a non-string core field")
62
+ if "source_suite" in row:
63
+ if hashlib.sha256(row["input"].encode("utf-8")).hexdigest() != row["source_sha256"]:
64
+ raise ValueError(f"Juliet source hash mismatch: {row['id']}")
65
+ elif "source_version" in row:
66
+ if hashlib.sha256(row["input"].encode("utf-8")).hexdigest() != row["source_sha256"]:
67
+ raise ValueError(f"OpenZeppelin source hash mismatch: {row['id']}")
68
+ elif "source_repo" in row:
69
+ if hashlib.sha256(row["input"].encode("utf-8")).hexdigest() != row["candidate_sha256"]:
70
+ raise ValueError(f"Juice Shop candidate hash mismatch: {row['id']}")
71
+ output = json.loads(row["output"])
72
+ if hashlib.sha256(output["approved_code"].encode("utf-8")).hexdigest() != row["correct_sha256"]:
73
+ raise ValueError(f"Juice Shop approved-code hash mismatch: {row['id']}")
74
+
75
+
76
+ def normalize(row: dict) -> dict:
77
+ validate_source_record(row)
78
+ provenance = {key: value for key, value in row.items() if key not in CORE}
79
+ return {
80
+ "id": row["id"],
81
+ "source": source_name(row),
82
+ "task_type": row["task_type"],
83
+ "domain": row["domain"],
84
+ "language": row["language"],
85
+ "instruction": row["instruction"],
86
+ "input": row["input"],
87
+ "output": row["output"],
88
+ "split": row["split"],
89
+ "labels_json": json.dumps(parse_label_output(row), ensure_ascii=False, sort_keys=True),
90
+ "provenance_json": json.dumps(provenance, ensure_ascii=False, sort_keys=True),
91
+ }
92
+
93
+
94
+ def main() -> None:
95
+ parser = argparse.ArgumentParser()
96
+ parser.add_argument("--staging", type=Path, default=Path("staging"))
97
+ parser.add_argument("--out", type=Path, default=Path("data"))
98
+ args = parser.parse_args()
99
+
100
+ normalized = []
101
+ for filename in SOURCE_FILES:
102
+ source_path = args.staging / filename
103
+ if not source_path.exists():
104
+ raise FileNotFoundError(source_path)
105
+ normalized.extend(normalize(row) for row in read_jsonl(source_path))
106
+
107
+ ids = [row["id"] for row in normalized]
108
+ if len(ids) != len(set(ids)):
109
+ raise ValueError("Duplicate record IDs in merged dataset")
110
+ for row in normalized:
111
+ if set(row) != set(FIELDS):
112
+ raise ValueError(f"Schema mismatch in {row['id']}")
113
+
114
+ by_split: dict[str, list[dict]] = defaultdict(list)
115
+ for row in normalized:
116
+ by_split[row["split"]].append(row)
117
+ for split, rows in sorted(by_split.items()):
118
+ rows.sort(key=lambda item: item["id"])
119
+ path = args.out / f"{split}.jsonl"
120
+ path.parent.mkdir(parents=True, exist_ok=True)
121
+ with path.open("w", encoding="utf-8", newline="\n") as handle:
122
+ for row in rows:
123
+ handle.write(json.dumps(row, ensure_ascii=False, sort_keys=True) + "\n")
124
+
125
+ counts = Counter(row["source"] for row in normalized)
126
+ languages = Counter(row["language"] for row in normalized)
127
+ print(json.dumps({
128
+ "total_records": len(normalized),
129
+ "by_source": dict(sorted(counts.items())),
130
+ "by_language": dict(sorted(languages.items())),
131
+ "by_split": {split: len(rows) for split, rows in sorted(by_split.items())},
132
+ "schema_fields": list(FIELDS),
133
+ "output_dir": str(args.out),
134
+ }, ensure_ascii=False, indent=2))
135
+
136
+
137
+ if __name__ == "__main__":
138
+ main()
curate.py ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Build a small, provenance-preserving security-code dataset from audited sources.
3
+
4
+ Inputs are the original NIST SARD Juliet 1.3 Java/C# ZIPs and selected OpenZeppelin
5
+ Contracts v5.7.0 MIT source files. The script does not infer security labels: Juliet
6
+ labels are taken from explicit Bad/Good method names in one source file per CWE/language.
7
+ Intermediate source-specific JSONL files are written to `staging/` and normalized later.
8
+ """
9
+ from __future__ import annotations
10
+
11
+ import argparse
12
+ import hashlib
13
+ import json
14
+ import re
15
+ from pathlib import Path
16
+ from zipfile import ZipFile
17
+
18
+ METHOD_RE = re.compile(
19
+ r"\b(?:public|private|protected|internal)\s+"
20
+ r"(?:(?:static|override|virtual|async|final|synchronized|abstract|sealed)\s+)*"
21
+ r"[\w.$<>?,\[\] ]+?\s+"
22
+ r"(Bad|Good(?:G2B|B2G)?)\s*\(",
23
+ re.IGNORECASE,
24
+ )
25
+ CWE_RE = re.compile(r"(CWE)(\d+)_([^/]+)")
26
+ GOOD_PREFIXES = ("good",)
27
+
28
+ JULIET = {
29
+ "java": {
30
+ "archive": "juliet-java-1.3.zip",
31
+ "prefix": "Java/src/testcases/",
32
+ "extension": ".java",
33
+ "suite_id": "111",
34
+ "suite_name": "Juliet Java 1.3",
35
+ "suite_url": "https://samate.nist.gov/SARD/test-suites/111",
36
+ "download_url": "https://samate.nist.gov/SARD/downloads/test-suites/2017-10-01-juliet-test-suite-for-java-v1-3.zip",
37
+ "license": "US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page",
38
+ },
39
+ "csharp": {
40
+ "archive": "juliet-csharp-1.3.zip",
41
+ "prefix": "src/testcases/",
42
+ "extension": ".cs",
43
+ "suite_id": "110",
44
+ "suite_name": "Juliet C# 1.3",
45
+ "suite_url": "https://samate.nist.gov/SARD/test-suites/110",
46
+ "download_url": "https://samate.nist.gov/SARD/downloads/test-suites/2020-08-01-juliet-test-suite-for-csharp-v1-3.zip",
47
+ "license": "US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page",
48
+ },
49
+ }
50
+
51
+ OPENZEPPELIN = [
52
+ ("contracts/token/ERC20/ERC20.sol", "ERC20: fungible-token accounting and transfer/allowance interface"),
53
+ ("contracts/access/Ownable.sol", "Ownable: single-owner access-control pattern"),
54
+ ("contracts/access/AccessControl.sol", "AccessControl: role-based authorization primitives"),
55
+ ("contracts/utils/ReentrancyGuard.sol", "ReentrancyGuard: explicit nonReentrant execution guard"),
56
+ ("contracts/utils/Pausable.sol", "Pausable: emergency pause-state primitives; authorization must be supplied by integrating code"),
57
+ ]
58
+
59
+
60
+ def sha256(data: bytes) -> str:
61
+ return hashlib.sha256(data).hexdigest()
62
+
63
+
64
+ def stable_split(cwe_id: str) -> str:
65
+ """Keep the same CWE in the same split across languages."""
66
+ bucket = int(hashlib.sha256(("Juliet-1.3:" + cwe_id).encode()).hexdigest()[:8], 16) % 100
67
+ if bucket < 80:
68
+ return "train"
69
+ if bucket < 90:
70
+ return "validation"
71
+ return "test"
72
+
73
+
74
+ def method_roles(text: str) -> tuple[list[str], list[str]]:
75
+ bad, good = [], []
76
+ for match in METHOD_RE.finditer(text):
77
+ name = match.group(1)
78
+ (good if name.lower().startswith(GOOD_PREFIXES) else bad).append(name)
79
+ return sorted(set(bad)), sorted(set(good))
80
+
81
+
82
+ def cwe_from_path(path: str):
83
+ match = CWE_RE.search(path)
84
+ if not match:
85
+ return None
86
+ return f"CWE-{match.group(2)}", match.group(3).replace("_", " ")
87
+
88
+
89
+ def build_juliet_records(archive_dir: Path) -> list[dict]:
90
+ records = []
91
+ for language, spec in JULIET.items():
92
+ archive_path = archive_dir / spec["archive"]
93
+ if not archive_path.exists():
94
+ raise FileNotFoundError(archive_path)
95
+ candidates: dict[str, list[tuple[str, bytes, list[str], list[str], str]]] = {}
96
+ with ZipFile(archive_path) as zf:
97
+ bad_zip = zf.testzip()
98
+ if bad_zip:
99
+ raise ValueError(f"Corrupt archive member: {bad_zip}")
100
+ for member in sorted(zf.namelist()):
101
+ if not member.startswith(spec["prefix"]) or not member.lower().endswith(spec["extension"]):
102
+ continue
103
+ cwe = cwe_from_path(member)
104
+ if not cwe:
105
+ continue
106
+ raw = zf.read(member)
107
+ if len(raw) < 300 or len(raw) > 80_000:
108
+ continue
109
+ text = raw.decode("utf-8", "replace")
110
+ bad_methods, good_methods = method_roles(text)
111
+ if not bad_methods or not good_methods:
112
+ continue
113
+ # These suite test files are generated samples. If a selected source
114
+ # unexpectedly embeds a third-party copyright/SPDX statement, hold it.
115
+ top = "\n".join(text.splitlines()[:30]).lower()
116
+ if "spdx-license-identifier" in top or "copyright" in top:
117
+ continue
118
+ cwe_id, cwe_name = cwe
119
+ candidates.setdefault(cwe_id, []).append((member, raw, bad_methods, good_methods, cwe_name))
120
+ for cwe_id in sorted(candidates, key=lambda x: int(x.split("-")[1])):
121
+ member, raw, bad_methods, good_methods, cwe_name = candidates[cwe_id][0]
122
+ code = raw.decode("utf-8", "replace")
123
+ output = {
124
+ "target_cwe": cwe_id,
125
+ "bad_method_names": bad_methods,
126
+ "good_method_names": good_methods,
127
+ "label_scope": "Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment",
128
+ }
129
+ record_id = f"juliet-{language}-{cwe_id.lower()}-{sha256(raw)[:12]}"
130
+ records.append({
131
+ "id": record_id,
132
+ "task_type": "paired_security_review",
133
+ "domain": "secure_coding",
134
+ "language": "C#" if language == "csharp" else "Java",
135
+ "target_cwe": cwe_id,
136
+ "target_weakness": cwe_name,
137
+ "instruction": f"Tinjau kasus uji Juliet berikut untuk {cwe_id} ({cwe_name}). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.",
138
+ "input": code,
139
+ "output": json.dumps(output, ensure_ascii=False, sort_keys=True),
140
+ "ground_truth_basis": "Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.",
141
+ "source_file": member,
142
+ "source_suite": spec["suite_name"],
143
+ "source_suite_id": spec["suite_id"],
144
+ "source_url": spec["suite_url"],
145
+ "source_download_url": spec["download_url"],
146
+ "source_license": spec["license"],
147
+ "source_sha256": sha256(raw),
148
+ "selection_policy": "First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.",
149
+ "split": stable_split(cwe_id),
150
+ })
151
+ return records
152
+
153
+
154
+ def build_openzeppelin_records(source_dir: Path) -> list[dict]:
155
+ records = []
156
+ version = "v5.7.0"
157
+ base = f"https://github.com/OpenZeppelin/openzeppelin-contracts/blob/{version}/"
158
+ for relpath, summary in OPENZEPPELIN:
159
+ path = source_dir / relpath
160
+ raw = path.read_bytes()
161
+ code = raw.decode("utf-8")
162
+ if not code.startswith("// SPDX-License-Identifier: MIT"):
163
+ raise ValueError(f"No MIT SPDX identifier in {relpath}")
164
+ record_id = "openzeppelin-" + relpath.rsplit("/", 1)[-1].removesuffix(".sol").lower()
165
+ records.append({
166
+ "id": record_id,
167
+ "task_type": "secure_code_reference",
168
+ "domain": "smart_contract",
169
+ "language": "Solidity",
170
+ "instruction": "Gunakan berkas Solidity rujukan berikut untuk menjelaskan fungsi pola atau komponen yang disediakan. Bedakan kemampuan library dari jaminan keamanan seluruh sistem; jangan menganggap cuplikan ini sebagai audit atau aplikasi lengkap.",
171
+ "input": code,
172
+ "output": summary,
173
+ "source_file": relpath,
174
+ "source_version": version,
175
+ "source_url": base + relpath,
176
+ "source_license": "MIT (SPDX identifier present in the source file; repository LICENSE included)",
177
+ "source_sha256": sha256(raw),
178
+ "selection_policy": "Five specific Solidity files with SPDX-License-Identifier: MIT from the tagged OpenZeppelin Contracts v5.7.0 release.",
179
+ "split": "reference",
180
+ })
181
+ return records
182
+
183
+
184
+ def write_jsonl(path: Path, records: list[dict]) -> None:
185
+ path.parent.mkdir(parents=True, exist_ok=True)
186
+ with path.open("w", encoding="utf-8", newline="\n") as f:
187
+ for row in records:
188
+ f.write(json.dumps(row, ensure_ascii=False, sort_keys=True) + "\n")
189
+
190
+
191
+ def main():
192
+ parser = argparse.ArgumentParser()
193
+ parser.add_argument("--archives", type=Path, default=Path("../downloads"))
194
+ parser.add_argument("--openzeppelin", type=Path, default=Path("../work/openzeppelin-v5.7.0"))
195
+ parser.add_argument("--out", type=Path, default=Path("staging"))
196
+ args = parser.parse_args()
197
+ juliet = build_juliet_records(args.archives)
198
+ oz = build_openzeppelin_records(args.openzeppelin)
199
+ write_jsonl(args.out / "juliet_paired_review.jsonl", juliet)
200
+ write_jsonl(args.out / "openzeppelin_solidity_references.jsonl", oz)
201
+ print(json.dumps({
202
+ "juliet_records": len(juliet),
203
+ "juliet_by_language": {lang: sum(r["language"] == lang for r in juliet) for lang in ("Java", "C#")},
204
+ "juliet_by_split": {split: sum(r["split"] == split for r in juliet) for split in ("train", "validation", "test")},
205
+ "openzeppelin_reference_records": len(oz),
206
+ "files": [str(args.out / "juliet_paired_review.jsonl"), str(args.out / "openzeppelin_solidity_references.jsonl")],
207
+ }, ensure_ascii=False, indent=2))
208
+
209
+
210
+ if __name__ == "__main__":
211
+ main()
data/challenge_fix.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/reference.jsonl ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {"domain": "smart_contract", "id": "openzeppelin-accesscontrol", "input": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.7.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.20;\n\nimport {IAccessControl} from \"./IAccessControl.sol\";\nimport {Context} from \"../utils/Context.sol\";\nimport {ERC165} from \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account => bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /// @inheritdoc ERC165\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * Emits a {RoleRevoked} event if the calling account had `role` and this call successfully revoked it.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n", "instruction": "Gunakan berkas Solidity rujukan berikut untuk menjelaskan fungsi pola atau komponen yang disediakan. Bedakan kemampuan library dari jaminan keamanan seluruh sistem; jangan menganggap cuplikan ini sebagai audit atau aplikasi lengkap.", "labels_json": "{\"reference_summary\": \"AccessControl: role-based authorization primitives\"}", "language": "Solidity", "output": "AccessControl: role-based authorization primitives", "provenance_json": "{\"selection_policy\": \"Five specific Solidity files with SPDX-License-Identifier: MIT from the tagged OpenZeppelin Contracts v5.7.0 release.\", \"source_file\": \"contracts/access/AccessControl.sol\", \"source_license\": \"MIT (SPDX identifier present in the source file; repository LICENSE included)\", \"source_sha256\": \"a6893a46a6270c2016db590e3e597c32b004052dad63ccc929ad23ee2ec85473\", \"source_url\": \"https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.7.0/contracts/access/AccessControl.sol\", \"source_version\": \"v5.7.0\"}", "source": "OpenZeppelin Contracts v5.7.0", "split": "reference", "task_type": "secure_code_reference"}
2
+ {"domain": "smart_contract", "id": "openzeppelin-erc20", "input": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.5.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC-20\n * applications.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * Both values are immutable: they can only be set once during construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /// @inheritdoc IERC20\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /// @inheritdoc IERC20\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /// @inheritdoc IERC20\n function allowance(address owner, address spender) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Skips emitting an {Approval} event indicating an allowance update. This is not\n * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner`'s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation sets the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the `transferFrom` operation can force the flag to\n * true using the following override:\n *\n * ```solidity\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner`'s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance < type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n", "instruction": "Gunakan berkas Solidity rujukan berikut untuk menjelaskan fungsi pola atau komponen yang disediakan. Bedakan kemampuan library dari jaminan keamanan seluruh sistem; jangan menganggap cuplikan ini sebagai audit atau aplikasi lengkap.", "labels_json": "{\"reference_summary\": \"ERC20: fungible-token accounting and transfer/allowance interface\"}", "language": "Solidity", "output": "ERC20: fungible-token accounting and transfer/allowance interface", "provenance_json": "{\"selection_policy\": \"Five specific Solidity files with SPDX-License-Identifier: MIT from the tagged OpenZeppelin Contracts v5.7.0 release.\", \"source_file\": \"contracts/token/ERC20/ERC20.sol\", \"source_license\": \"MIT (SPDX identifier present in the source file; repository LICENSE included)\", \"source_sha256\": \"50f34ae16a067a41c2c1091445d11d63788e54c717677cb6d6b0e4cdea2ad21d\", \"source_url\": \"https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.7.0/contracts/token/ERC20/ERC20.sol\", \"source_version\": \"v5.7.0\"}", "source": "OpenZeppelin Contracts v5.7.0", "split": "reference", "task_type": "secure_code_reference"}
3
+ {"domain": "smart_contract", "id": "openzeppelin-ownable", "input": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n", "instruction": "Gunakan berkas Solidity rujukan berikut untuk menjelaskan fungsi pola atau komponen yang disediakan. Bedakan kemampuan library dari jaminan keamanan seluruh sistem; jangan menganggap cuplikan ini sebagai audit atau aplikasi lengkap.", "labels_json": "{\"reference_summary\": \"Ownable: single-owner access-control pattern\"}", "language": "Solidity", "output": "Ownable: single-owner access-control pattern", "provenance_json": "{\"selection_policy\": \"Five specific Solidity files with SPDX-License-Identifier: MIT from the tagged OpenZeppelin Contracts v5.7.0 release.\", \"source_file\": \"contracts/access/Ownable.sol\", \"source_license\": \"MIT (SPDX identifier present in the source file; repository LICENSE included)\", \"source_sha256\": \"38578bd71c0a909840e67202db527cc6b4e6b437e0f39f0c909da32c1e30cb81\", \"source_url\": \"https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.7.0/contracts/access/Ownable.sol\", \"source_version\": \"v5.7.0\"}", "source": "OpenZeppelin Contracts v5.7.0", "split": "reference", "task_type": "secure_code_reference"}
4
+ {"domain": "smart_contract", "id": "openzeppelin-pausable", "input": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n bool private _paused;\n\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n /**\n * @dev The operation failed because the contract is paused.\n */\n error EnforcedPause();\n\n /**\n * @dev The operation failed because the contract is not paused.\n */\n error ExpectedPause();\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n _requireNotPaused();\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n _requirePaused();\n _;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Throws if the contract is paused.\n */\n function _requireNotPaused() internal view virtual {\n if (paused()) {\n revert EnforcedPause();\n }\n }\n\n /**\n * @dev Throws if the contract is not paused.\n */\n function _requirePaused() internal view virtual {\n if (!paused()) {\n revert ExpectedPause();\n }\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n", "instruction": "Gunakan berkas Solidity rujukan berikut untuk menjelaskan fungsi pola atau komponen yang disediakan. Bedakan kemampuan library dari jaminan keamanan seluruh sistem; jangan menganggap cuplikan ini sebagai audit atau aplikasi lengkap.", "labels_json": "{\"reference_summary\": \"Pausable: emergency pause-state primitives; authorization must be supplied by integrating code\"}", "language": "Solidity", "output": "Pausable: emergency pause-state primitives; authorization must be supplied by integrating code", "provenance_json": "{\"selection_policy\": \"Five specific Solidity files with SPDX-License-Identifier: MIT from the tagged OpenZeppelin Contracts v5.7.0 release.\", \"source_file\": \"contracts/utils/Pausable.sol\", \"source_license\": \"MIT (SPDX identifier present in the source file; repository LICENSE included)\", \"source_sha256\": \"2c26130748f06552c65ca74d89eaf78c9324a3cbac3ba6fdbadaa8beba0cb0b4\", \"source_url\": \"https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.7.0/contracts/utils/Pausable.sol\", \"source_version\": \"v5.7.0\"}", "source": "OpenZeppelin Contracts v5.7.0", "split": "reference", "task_type": "secure_code_reference"}
5
+ {"domain": "smart_contract", "id": "openzeppelin-reentrancyguard", "input": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.5.0) (utils/ReentrancyGuard.sol)\n\npragma solidity ^0.8.20;\n\nimport {StorageSlot} from \"./StorageSlot.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,\n * consider using {ReentrancyGuardTransient} instead.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n *\n * IMPORTANT: Deprecated. This storage-based reentrancy guard will be removed and replaced\n * by the {ReentrancyGuardTransient} variant in v6.0.\n *\n * @custom:stateless\n */\nabstract contract ReentrancyGuard {\n using StorageSlot for bytes32;\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.ReentrancyGuard\")) - 1)) & ~bytes32(uint256(0xff))\n bytes32 private constant REENTRANCY_GUARD_STORAGE =\n 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;\n\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant NOT_ENTERED = 1;\n uint256 private constant ENTERED = 2;\n\n /**\n * @dev Unauthorized reentrant call.\n */\n error ReentrancyGuardReentrantCall();\n\n constructor() {\n _reentrancyGuardStorageSlot().getUint256Slot().value = NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n /**\n * @dev A `view` only version of {nonReentrant}. Use to block view functions\n * from being called, preventing reading from inconsistent contract state.\n *\n * CAUTION: This is a \"view\" modifier and does not change the reentrancy\n * status. Use it only on view functions. For payable or non-payable functions,\n * use the standard {nonReentrant} modifier instead.\n */\n modifier nonReentrantView() {\n _nonReentrantBeforeView();\n _;\n }\n\n function _nonReentrantBeforeView() private view {\n if (_reentrancyGuardEntered()) {\n revert ReentrancyGuardReentrantCall();\n }\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be NOT_ENTERED\n _nonReentrantBeforeView();\n\n // Any calls to nonReentrant after this point will fail\n _reentrancyGuardStorageSlot().getUint256Slot().value = ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _reentrancyGuardStorageSlot().getUint256Slot().value = NOT_ENTERED;\n }\n\n /**\n * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n * `nonReentrant` function in the call stack.\n */\n function _reentrancyGuardEntered() internal view returns (bool) {\n return _reentrancyGuardStorageSlot().getUint256Slot().value == ENTERED;\n }\n\n function _reentrancyGuardStorageSlot() internal pure virtual returns (bytes32) {\n return REENTRANCY_GUARD_STORAGE;\n }\n}\n", "instruction": "Gunakan berkas Solidity rujukan berikut untuk menjelaskan fungsi pola atau komponen yang disediakan. Bedakan kemampuan library dari jaminan keamanan seluruh sistem; jangan menganggap cuplikan ini sebagai audit atau aplikasi lengkap.", "labels_json": "{\"reference_summary\": \"ReentrancyGuard: explicit nonReentrant execution guard\"}", "language": "Solidity", "output": "ReentrancyGuard: explicit nonReentrant execution guard", "provenance_json": "{\"selection_policy\": \"Five specific Solidity files with SPDX-License-Identifier: MIT from the tagged OpenZeppelin Contracts v5.7.0 release.\", \"source_file\": \"contracts/utils/ReentrancyGuard.sol\", \"source_license\": \"MIT (SPDX identifier present in the source file; repository LICENSE included)\", \"source_sha256\": \"94e409e8f6e3184236651a6cc2b1a6a3ea0f0a25eb85b71e524ad5791bb2fbc8\", \"source_url\": \"https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.7.0/contracts/utils/ReentrancyGuard.sol\", \"source_version\": \"v5.7.0\"}", "source": "OpenZeppelin Contracts v5.7.0", "split": "reference", "task_type": "secure_code_reference"}
data/test.jsonl ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"domain": "secure_coding", "id": "juliet-csharp-cwe-259-4ad4ce69310c", "input": "/* TEMPLATE GENERATED TESTCASE FILE\r\nFilename: CWE259_Hard_Coded_Password__NetworkCredential_01.cs\r\nLabel Definition File: CWE259_Hard_Coded_Password.label.xml\r\nTemplate File: sources-sink-01.tmpl.cs\r\n*/\r\n/*\r\n* @description\r\n* CWE: 259 Hard Coded Password\r\n* BadSource: hardcodedPassword Set data to a hardcoded string\r\n* GoodSource: Read data from the console using readLine()\r\n* BadSink: NetworkCredential data used as password in NetworkCredential()\r\n* Flow Variant: 01 Baseline\r\n*\r\n* */\r\n\r\nusing TestCaseSupport;\r\nusing System;\r\n\r\nusing System.Net;\r\n\r\nusing System.IO;\r\n\r\nnamespace testcases.CWE259_Hard_Coded_Password\r\n{\r\n\r\nclass CWE259_Hard_Coded_Password__NetworkCredential_01 : AbstractTestCase\r\n{\r\n#if (!OMITBAD)\r\n /* uses badsource and badsink */\r\n public override void Bad()\r\n {\r\n string data;\r\n /* FLAW: Set data to a hardcoded string */\r\n data = \"7e5tc4s3\";\r\n if (data != null)\r\n {\r\n /* POTENTIAL FLAW: data used as password in NetworkCredential() */\r\n NetworkCredential credentials = new NetworkCredential(\"user\", data, \"domain\");\r\n IO.WriteLine(credentials.ToString());\r\n }\r\n }\r\n#endif //omitbad\r\n#if (!OMITGOOD)\r\n public override void Good()\r\n {\r\n GoodG2B();\r\n }\r\n\r\n /* goodG2B() - uses goodsource and badsink */\r\n private void GoodG2B()\r\n {\r\n string data;\r\n data = \"\"; /* init data */\r\n /* FIX: Read data from the console using ReadLine() */\r\n try\r\n {\r\n /* POTENTIAL FLAW: Read data from the console using ReadLine */\r\n data = Console.ReadLine();\r\n }\r\n catch (IOException exceptIO)\r\n {\r\n IO.Logger.Log(NLog.LogLevel.Warn, \"Error with stream reading\", exceptIO);\r\n }\r\n if (data != null)\r\n {\r\n /* POTENTIAL FLAW: data used as password in NetworkCredential() */\r\n NetworkCredential credentials = new NetworkCredential(\"user\", data, \"domain\");\r\n IO.WriteLine(credentials.ToString());\r\n }\r\n }\r\n#endif //omitgood\r\n}\r\n}\r\n", "instruction": "Tinjau kasus uji Juliet berikut untuk CWE-259 (Hard Coded Password). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.", "labels_json": "{\"bad_method_names\": [\"Bad\"], \"good_method_names\": [\"Good\", \"GoodG2B\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-259\"}", "language": "C#", "output": "{\"bad_method_names\": [\"Bad\"], \"good_method_names\": [\"Good\", \"GoodG2B\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-259\"}", "provenance_json": "{\"ground_truth_basis\": \"Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.\", \"selection_policy\": \"First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.\", \"source_download_url\": \"https://samate.nist.gov/SARD/downloads/test-suites/2020-08-01-juliet-test-suite-for-csharp-v1-3.zip\", \"source_file\": \"src/testcases/CWE259_Hard_Coded_Password/CWE259_Hard_Coded_Password__NetworkCredential_01.cs\", \"source_license\": \"US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page\", \"source_sha256\": \"4ad4ce69310ce980d29096017b684090ce93c55d1047f66b04a28477a44fea3c\", \"source_suite\": \"Juliet C# 1.3\", \"source_suite_id\": \"110\", \"source_url\": \"https://samate.nist.gov/SARD/test-suites/110\", \"target_cwe\": \"CWE-259\", \"target_weakness\": \"Hard Coded Password\"}", "source": "Juliet C# 1.3", "split": "test", "task_type": "paired_security_review"}
2
+ {"domain": "secure_coding", "id": "juliet-csharp-cwe-378-0c3bb5368966", "input": "/* TEMPLATE GENERATED TESTCASE FILE\r\nFilename: CWE378_Temporary_File_Creation_With_Insecure_Perms__basic_01.cs\r\nLabel Definition File: CWE378_Temporary_File_Creation_With_Insecure_Perms__basic.label.xml\r\nTemplate File: point-flaw-01.tmpl.cs\r\n*/\r\n/*\r\n* @description\r\n* CWE: 378 Explicitly set permissions on files\r\n* Sinks:\r\n* GoodSink: Restrict permissions on file\r\n* BadSink : Permissions never set on file\r\n* Flow Variant: 01 Baseline\r\n*\r\n* */\r\n\r\nusing TestCaseSupport;\r\nusing System;\r\n\r\nusing System.IO;\r\nusing System.Security.AccessControl;\r\n\r\nnamespace testcases.CWE378_Temporary_File_Creation_With_Insecure_Perms\r\n{\r\nclass CWE378_Temporary_File_Creation_With_Insecure_Perms__basic_01 : AbstractTestCase\r\n{\r\n#if (!OMITBAD)\r\n public override void Bad()\r\n {\r\n string tempPathB = Path.GetTempFileName();\r\n try\r\n {\r\n using (StreamWriter sw = new StreamWriter(tempPathB))\r\n {\r\n /* FLAW: Permissions never set on file */\r\n /* Write something to the file */\r\n sw.Write(42);\r\n }\r\n }\r\n catch (IOException exceptIO)\r\n {\r\n IO.Logger.Log(NLog.LogLevel.Warn, \"Error writing to temporary file\", exceptIO);\r\n }\r\n finally\r\n {\r\n /* Delete the temporary file */\r\n if (File.Exists(tempPathB))\r\n {\r\n File.Delete(tempPathB);\r\n }\r\n }\r\n }\r\n#endif //omitbad\r\n#if (!OMITGOOD)\r\n public override void Good()\r\n {\r\n Good1();\r\n }\r\n\r\n private void Good1()\r\n {\r\n string tempPathG = Path.GetTempFileName();\r\n try\r\n {\r\n using (StreamWriter sw = new StreamWriter(tempPathG))\r\n {\r\n FileSecurity fSecurity = File.GetAccessControl(tempPathG);\r\n /* FIX: Set file as writable by owner, readable by owner */\r\n File.SetAttributes(tempPathG, FileAttributes.Normal);\r\n /* Write something to the file */\r\n sw.Write(42);\r\n }\r\n }\r\n catch (IOException exceptIO)\r\n {\r\n IO.Logger.Log(NLog.LogLevel.Warn, \"Error writing to temporary file\", exceptIO);\r\n }\r\n finally\r\n {\r\n /* Delete the temporary file */\r\n if (File.Exists(tempPathG))\r\n {\r\n File.Delete(tempPathG);\r\n }\r\n }\r\n }\r\n#endif //omitgood\r\n}\r\n}\r\n", "instruction": "Tinjau kasus uji Juliet berikut untuk CWE-378 (Temporary File Creation With Insecure Perms). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.", "labels_json": "{\"bad_method_names\": [\"Bad\"], \"good_method_names\": [\"Good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-378\"}", "language": "C#", "output": "{\"bad_method_names\": [\"Bad\"], \"good_method_names\": [\"Good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-378\"}", "provenance_json": "{\"ground_truth_basis\": \"Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.\", \"selection_policy\": \"First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.\", \"source_download_url\": \"https://samate.nist.gov/SARD/downloads/test-suites/2020-08-01-juliet-test-suite-for-csharp-v1-3.zip\", \"source_file\": \"src/testcases/CWE378_Temporary_File_Creation_With_Insecure_Perms/CWE378_Temporary_File_Creation_With_Insecure_Perms__basic_01.cs\", \"source_license\": \"US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page\", \"source_sha256\": \"0c3bb53689662f11e80d9ab176b2de3c9c1379e3fc9dd275bfa09077722b6cbd\", \"source_suite\": \"Juliet C# 1.3\", \"source_suite_id\": \"110\", \"source_url\": \"https://samate.nist.gov/SARD/test-suites/110\", \"target_cwe\": \"CWE-378\", \"target_weakness\": \"Temporary File Creation With Insecure Perms\"}", "source": "Juliet C# 1.3", "split": "test", "task_type": "paired_security_review"}
3
+ {"domain": "secure_coding", "id": "juliet-csharp-cwe-477-7e950d345980", "input": "/* TEMPLATE GENERATED TESTCASE FILE\r\nFilename: CWE477_Obsolete_Functions__Dns_GetHostByAddress_01.cs\r\nLabel Definition File: CWE477_Obsolete_Functions.label.xml\r\nTemplate File: point-flaw-01.tmpl.cs\r\n*/\r\n/*\r\n* @description\r\n* CWE: 477 Use of Obsolete Functions\r\n* Sinks: Dns_GetHostByAddress\r\n* GoodSink: Use of preferred System.Net.Dns.GetHostEntry() method\r\n* BadSink : Use of deprecated System.Net.Dns.GetHostByAddress() method\r\n* Flow Variant: 01 Baseline\r\n*\r\n* */\r\n\r\nusing TestCaseSupport;\r\nusing System;\r\n\r\nusing System.Net;\r\n\r\nnamespace testcases.CWE477_Obsolete_Functions\r\n{\r\nclass CWE477_Obsolete_Functions__Dns_GetHostByAddress_01 : AbstractTestCase\r\n{\r\n#if (!OMITBAD)\r\n public override void Bad()\r\n {\r\n IPAddress hostIPAddress = IPAddress.Parse(\"8.8.8.8\");\r\n /* FLAW: Use of deprecated Dns.GetHostByAddress() method */\r\n IPHostEntry hostInfo = Dns.GetHostByAddress(hostIPAddress);\r\n IO.WriteLine(\"Host name : \" + hostInfo.HostName);\r\n }\r\n#endif //omitbad\r\n#if (!OMITGOOD)\r\n public override void Good()\r\n {\r\n Good1();\r\n }\r\n\r\n private void Good1()\r\n {\r\n IPAddress hostIPAddress = IPAddress.Parse(\"8.8.8.8\");\r\n /* FIX: Use preferred Dns.GetHostEntry() method */\r\n IPHostEntry hostInfo = Dns.GetHostEntry(hostIPAddress);\r\n IO.WriteLine(\"Host name : \" + hostInfo.HostName);\r\n }\r\n#endif //omitgood\r\n}\r\n}\r\n", "instruction": "Tinjau kasus uji Juliet berikut untuk CWE-477 (Obsolete Functions). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.", "labels_json": "{\"bad_method_names\": [\"Bad\"], \"good_method_names\": [\"Good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-477\"}", "language": "C#", "output": "{\"bad_method_names\": [\"Bad\"], \"good_method_names\": [\"Good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-477\"}", "provenance_json": "{\"ground_truth_basis\": \"Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.\", \"selection_policy\": \"First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.\", \"source_download_url\": \"https://samate.nist.gov/SARD/downloads/test-suites/2020-08-01-juliet-test-suite-for-csharp-v1-3.zip\", \"source_file\": \"src/testcases/CWE477_Obsolete_Functions/CWE477_Obsolete_Functions__Dns_GetHostByAddress_01.cs\", \"source_license\": \"US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page\", \"source_sha256\": \"7e950d3459804860f43c4e266c283977a6fddff704ed78b891082ec8da829c66\", \"source_suite\": \"Juliet C# 1.3\", \"source_suite_id\": \"110\", \"source_url\": \"https://samate.nist.gov/SARD/test-suites/110\", \"target_cwe\": \"CWE-477\", \"target_weakness\": \"Obsolete Functions\"}", "source": "Juliet C# 1.3", "split": "test", "task_type": "paired_security_review"}
4
+ {"domain": "secure_coding", "id": "juliet-csharp-cwe-511-7836fdd81ea0", "input": "/* TEMPLATE GENERATED TESTCASE FILE\r\nFilename: CWE511_Logic_Time_Bomb__counter_01.cs\r\nLabel Definition File: CWE511_Logic_Time_Bomb.label.xml\r\nTemplate File: point-flaw-01.tmpl.cs\r\n*/\r\n/*\r\n* @description\r\n* CWE: 511 Logic Time Bomb\r\n* Sinks: counter\r\n* GoodSink: If counter reaches a certain value, print to the console\r\n* BadSink : If counter reaches a certain value, launch an executable\r\n* Flow Variant: 01 Baseline\r\n*\r\n* */\r\n\r\nusing TestCaseSupport;\r\nusing System;\r\n\r\nusing System.Diagnostics;\r\n\r\nnamespace testcases.CWE511_Logic_Time_Bomb\r\n{\r\nclass CWE511_Logic_Time_Bomb__counter_01 : AbstractTestCase\r\n{\r\n#if (!OMITBAD)\r\n public override void Bad()\r\n {\r\n int count = 0;\r\n do\r\n {\r\n /* FLAW: counter triggered backdoor */\r\n if (count == 20000)\r\n {\r\n using (Process myProcess = new Process())\r\n {\r\n myProcess.StartInfo.UseShellExecute = false;\r\n myProcess.StartInfo.FileName = \"c:\\\\windows\\\\system32\\\\evil.exe\";\r\n myProcess.Start();\r\n }\r\n }\r\n count++;\r\n }\r\n while (count < int.MaxValue);\r\n }\r\n#endif //omitbad\r\n#if (!OMITGOOD)\r\n public override void Good()\r\n {\r\n Good1();\r\n }\r\n\r\n private void Good1()\r\n {\r\n int count = 0;\r\n do\r\n {\r\n /* FIX: no backdoor exists */\r\n if (count == 20000)\r\n {\r\n IO.WriteLine(\"Sorry, your license has expired. Please contact support.\");\r\n }\r\n count++;\r\n }\r\n while (count < int.MaxValue);\r\n }\r\n#endif //omitgood\r\n}\r\n}\r\n", "instruction": "Tinjau kasus uji Juliet berikut untuk CWE-511 (Logic Time Bomb). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.", "labels_json": "{\"bad_method_names\": [\"Bad\"], \"good_method_names\": [\"Good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-511\"}", "language": "C#", "output": "{\"bad_method_names\": [\"Bad\"], \"good_method_names\": [\"Good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-511\"}", "provenance_json": "{\"ground_truth_basis\": \"Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.\", \"selection_policy\": \"First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.\", \"source_download_url\": \"https://samate.nist.gov/SARD/downloads/test-suites/2020-08-01-juliet-test-suite-for-csharp-v1-3.zip\", \"source_file\": \"src/testcases/CWE511_Logic_Time_Bomb/CWE511_Logic_Time_Bomb__counter_01.cs\", \"source_license\": \"US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page\", \"source_sha256\": \"7836fdd81ea06e8ad7f62e834f0f4eeaa996f6b76e2c9959710b16ec464cde2d\", \"source_suite\": \"Juliet C# 1.3\", \"source_suite_id\": \"110\", \"source_url\": \"https://samate.nist.gov/SARD/test-suites/110\", \"target_cwe\": \"CWE-511\", \"target_weakness\": \"Logic Time Bomb\"}", "source": "Juliet C# 1.3", "split": "test", "task_type": "paired_security_review"}
5
+ {"domain": "secure_coding", "id": "juliet-csharp-cwe-606-16da114a49b1", "input": "/* TEMPLATE GENERATED TESTCASE FILE\r\nFilename: CWE606_Unchecked_Loop_Condition__Connect_tcp_01.cs\r\nLabel Definition File: CWE606_Unchecked_Loop_Condition.label.xml\r\nTemplate File: sources-sinks-01.tmpl.cs\r\n*/\r\n/*\r\n* @description\r\n* CWE: 606 Unchecked Input for Loop Condition\r\n* BadSource: Connect_tcp Read data using an outbound tcp connection\r\n* GoodSource: hardcoded int in string form\r\n* Sinks:\r\n* GoodSink: validate loop variable\r\n* BadSink : loop variable not validated\r\n* Flow Variant: 01 Baseline\r\n*\r\n* */\r\n\r\nusing TestCaseSupport;\r\nusing System;\r\n\r\nusing System.Web;\r\n\r\nusing System.IO;\r\nusing System.Net.Sockets;\r\n\r\nnamespace testcases.CWE606_Unchecked_Loop_Condition\r\n{\r\nclass CWE606_Unchecked_Loop_Condition__Connect_tcp_01 : AbstractTestCase\r\n{\r\n#if (!OMITBAD)\r\n public override void Bad()\r\n {\r\n string data;\r\n data = \"\"; /* Initialize data */\r\n /* Read data using an outbound tcp connection */\r\n {\r\n try\r\n {\r\n /* Read data using an outbound tcp connection */\r\n using (TcpClient tcpConn = new TcpClient(\"host.example.org\", 39544))\r\n {\r\n /* read input from socket */\r\n using (StreamReader sr = new StreamReader(tcpConn.GetStream()))\r\n {\r\n /* POTENTIAL FLAW: Read data using an outbound tcp connection */\r\n data = sr.ReadLine();\r\n }\r\n }\r\n }\r\n catch (IOException exceptIO)\r\n {\r\n IO.Logger.Log(NLog.LogLevel.Warn, exceptIO, \"Error with stream reading\");\r\n }\r\n }\r\n int numberOfLoops;\r\n try\r\n {\r\n numberOfLoops = int.Parse(data);\r\n }\r\n catch (FormatException exceptNumberFormat)\r\n {\r\n IO.WriteLine(\"Invalid response. Numeric input expected. Assuming 1.\");\r\n IO.Logger.Log(NLog.LogLevel.Warn, exceptNumberFormat, \"Invalid response. Numeric input expected. Assuming 1.\");\r\n numberOfLoops = 1;\r\n }\r\n for (int i = 0; i < numberOfLoops; i++)\r\n {\r\n /* POTENTIAL FLAW: user supplied input used for loop counter test */\r\n IO.WriteLine(\"hello world\");\r\n }\r\n }\r\n#endif //omitbad\r\n#if (!OMITGOOD)\r\n public override void Good()\r\n {\r\n GoodG2B();\r\n GoodB2G();\r\n }\r\n\r\n /* goodG2B() - use goodsource and badsink */\r\n private void GoodG2B()\r\n {\r\n string data;\r\n /* FIX: Use a hardcoded int as a string */\r\n data = \"5\";\r\n int numberOfLoops;\r\n try\r\n {\r\n numberOfLoops = int.Parse(data);\r\n }\r\n catch (FormatException exceptNumberFormat)\r\n {\r\n IO.WriteLine(\"Invalid response. Numeric input expected. Assuming 1.\");\r\n IO.Logger.Log(NLog.LogLevel.Warn, exceptNumberFormat, \"Invalid response. Numeric input expected. Assuming 1.\");\r\n numberOfLoops = 1;\r\n }\r\n for (int i = 0; i < numberOfLoops; i++)\r\n {\r\n /* POTENTIAL FLAW: user supplied input used for loop counter test */\r\n IO.WriteLine(\"hello world\");\r\n }\r\n }\r\n\r\n /* goodB2G() - use badsource and goodsink */\r\n private void GoodB2G()\r\n {\r\n string data;\r\n data = \"\"; /* Initialize data */\r\n /* Read data using an outbound tcp connection */\r\n {\r\n try\r\n {\r\n /* Read data using an outbound tcp connection */\r\n using (TcpClient tcpConn = new TcpClient(\"host.example.org\", 39544))\r\n {\r\n /* read input from socket */\r\n using (StreamReader sr = new StreamReader(tcpConn.GetStream()))\r\n {\r\n /* POTENTIAL FLAW: Read data using an outbound tcp connection */\r\n data = sr.ReadLine();\r\n }\r\n }\r\n }\r\n catch (IOException exceptIO)\r\n {\r\n IO.Logger.Log(NLog.LogLevel.Warn, exceptIO, \"Error with stream reading\");\r\n }\r\n }\r\n int numberOfLoops;\r\n try\r\n {\r\n numberOfLoops = int.Parse(data);\r\n }\r\n catch (FormatException exceptNumberFormat)\r\n {\r\n IO.WriteLine(\"Invalid response. Numeric input expected. Assuming 1.\");\r\n IO.Logger.Log(NLog.LogLevel.Warn, exceptNumberFormat, \"Invalid response. Numeric input expected. Assuming 1.\");\r\n numberOfLoops = 1;\r\n }\r\n /* FIX: loop number thresholds validated */\r\n if (numberOfLoops >= 0 && numberOfLoops <= 5)\r\n {\r\n for (int i = 0; i < numberOfLoops; i++)\r\n {\r\n IO.WriteLine(\"hello world\");\r\n }\r\n }\r\n }\r\n#endif //omitgood\r\n}\r\n}\r\n", "instruction": "Tinjau kasus uji Juliet berikut untuk CWE-606 (Unchecked Loop Condition). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.", "labels_json": "{\"bad_method_names\": [\"Bad\"], \"good_method_names\": [\"Good\", \"GoodB2G\", \"GoodG2B\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-606\"}", "language": "C#", "output": "{\"bad_method_names\": [\"Bad\"], \"good_method_names\": [\"Good\", \"GoodB2G\", \"GoodG2B\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-606\"}", "provenance_json": "{\"ground_truth_basis\": \"Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.\", \"selection_policy\": \"First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.\", \"source_download_url\": \"https://samate.nist.gov/SARD/downloads/test-suites/2020-08-01-juliet-test-suite-for-csharp-v1-3.zip\", \"source_file\": \"src/testcases/CWE606_Unchecked_Loop_Condition/CWE606_Unchecked_Loop_Condition__Connect_tcp_01.cs\", \"source_license\": \"US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page\", \"source_sha256\": \"16da114a49b1cb9ca9c3586561945bad96570919b4657bc12a86894134fc6f60\", \"source_suite\": \"Juliet C# 1.3\", \"source_suite_id\": \"110\", \"source_url\": \"https://samate.nist.gov/SARD/test-suites/110\", \"target_cwe\": \"CWE-606\", \"target_weakness\": \"Unchecked Loop Condition\"}", "source": "Juliet C# 1.3", "split": "test", "task_type": "paired_security_review"}
6
+ {"domain": "secure_coding", "id": "juliet-csharp-cwe-617-89e208ae9fd2", "input": "/* TEMPLATE GENERATED TESTCASE FILE\r\nFilename: CWE617_Reachable_Assertion__false_01.cs\r\nLabel Definition File: CWE617_Reachable_Assertion.label.xml\r\nTemplate File: point-flaw-01.tmpl.cs\r\n*/\r\n/*\r\n* @description\r\n* CWE: 617 Assertion is reachable\r\n* Sinks: false\r\n* GoodSink: assert true, which will never trigger\r\n* BadSink : assert false, which will always trigger\r\n* Flow Variant: 01 Baseline\r\n*\r\n* */\r\n\r\nusing TestCaseSupport;\r\nusing System;\r\n\r\nusing System.Diagnostics;\r\n\r\nnamespace testcases.CWE617_Reachable_Assertion\r\n{\r\nclass CWE617_Reachable_Assertion__false_01 : AbstractTestCase\r\n{\r\n#if (!OMITBAD)\r\n public override void Bad()\r\n {\r\n /* FLAW: this assertion can be reached, and will always trigger */\r\n Trace.Assert(false); /* INCIDENTAL: CWE 571 - expression is always true */\r\n }\r\n#endif //omitbad\r\n#if (!OMITGOOD)\r\n public override void Good()\r\n {\r\n Good1();\r\n }\r\n\r\n private void Good1()\r\n {\r\n /* FIX: ensure assertions cannot be triggered, in this case, to avoid an empty\r\n * function, assert true */\r\n Trace.Assert(true); /* INCIDENTAL: CWE 570 - expression is always false */\r\n }\r\n#endif //omitgood\r\n}\r\n}\r\n", "instruction": "Tinjau kasus uji Juliet berikut untuk CWE-617 (Reachable Assertion). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.", "labels_json": "{\"bad_method_names\": [\"Bad\"], \"good_method_names\": [\"Good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-617\"}", "language": "C#", "output": "{\"bad_method_names\": [\"Bad\"], \"good_method_names\": [\"Good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-617\"}", "provenance_json": "{\"ground_truth_basis\": \"Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.\", \"selection_policy\": \"First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.\", \"source_download_url\": \"https://samate.nist.gov/SARD/downloads/test-suites/2020-08-01-juliet-test-suite-for-csharp-v1-3.zip\", \"source_file\": \"src/testcases/CWE617_Reachable_Assertion/CWE617_Reachable_Assertion__false_01.cs\", \"source_license\": \"US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page\", \"source_sha256\": \"89e208ae9fd2657fd411a5a1cca51f0a584412ee471e59ad144e2f2fbb4a71c7\", \"source_suite\": \"Juliet C# 1.3\", \"source_suite_id\": \"110\", \"source_url\": \"https://samate.nist.gov/SARD/test-suites/110\", \"target_cwe\": \"CWE-617\", \"target_weakness\": \"Reachable Assertion\"}", "source": "Juliet C# 1.3", "split": "test", "task_type": "paired_security_review"}
7
+ {"domain": "secure_coding", "id": "juliet-csharp-cwe-667-a9f6e41eca7e", "input": "/*\r\n * @description Improper Locking\r\n * \r\n * */\r\n\r\nusing System;\r\nusing System.Threading;\r\nusing TestCaseSupport;\r\n\r\nnamespace testcases.CWE667_Improper_Locking\r\n{\r\n class CWE667_Improper_Locking__basic_01 : AbstractTestCase\r\n {\r\n static private int intBadNumber = 3;\r\n static private readonly object badLock = new object();\r\n\r\n#if (!OMITBAD)\r\n public override void Bad()\r\n {\r\n Monitor.Enter(badLock);\r\n\r\n intBadNumber++;\r\n\r\n IO.WriteLine(intBadNumber);\r\n\r\n /* FLAW: lock is not unlocked */\r\n }\r\n#endif // OMITBAD\r\n\r\n static private int intGood1Number = 3;\r\n static private readonly object goodLock = new object();\r\n\r\n#if (!OMITGOOD)\r\n public void Good1()\r\n {\r\n Monitor.Enter(goodLock);\r\n\r\n try\r\n {\r\n intGood1Number++;\r\n\r\n IO.WriteLine(intGood1Number);\r\n }\r\n finally\r\n {\r\n /* FIX: Unlock the lock within a finally block */\r\n Monitor.Exit(goodLock);\r\n }\r\n }\r\n\r\n public override void Good()\r\n {\r\n Good1();\r\n }\r\n#endif // OMITGOOD\r\n\r\n}\r\n}\r\n", "instruction": "Tinjau kasus uji Juliet berikut untuk CWE-667 (Improper Locking). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.", "labels_json": "{\"bad_method_names\": [\"Bad\"], \"good_method_names\": [\"Good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-667\"}", "language": "C#", "output": "{\"bad_method_names\": [\"Bad\"], \"good_method_names\": [\"Good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-667\"}", "provenance_json": "{\"ground_truth_basis\": \"Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.\", \"selection_policy\": \"First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.\", \"source_download_url\": \"https://samate.nist.gov/SARD/downloads/test-suites/2020-08-01-juliet-test-suite-for-csharp-v1-3.zip\", \"source_file\": \"src/testcases/CWE667_Improper_Locking/CWE667_Improper_Locking__basic_01.cs\", \"source_license\": \"US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page\", \"source_sha256\": \"a9f6e41eca7ec8e9d5d4bcff0c8c2fe8a48a358100df19cd7979e0c3fedeebd6\", \"source_suite\": \"Juliet C# 1.3\", \"source_suite_id\": \"110\", \"source_url\": \"https://samate.nist.gov/SARD/test-suites/110\", \"target_cwe\": \"CWE-667\", \"target_weakness\": \"Improper Locking\"}", "source": "Juliet C# 1.3", "split": "test", "task_type": "paired_security_review"}
8
+ {"domain": "secure_coding", "id": "juliet-java-cwe-259-49c2d44780e8", "input": "/* TEMPLATE GENERATED TESTCASE FILE\r\nFilename: CWE259_Hard_Coded_Password__driverManager_01.java\r\nLabel Definition File: CWE259_Hard_Coded_Password.label.xml\r\nTemplate File: sources-sink-01.tmpl.java\r\n*/\r\n/*\r\n* @description\r\n* CWE: 259 Hard Coded Password\r\n* BadSource: hardcodedPassword Set data to a hardcoded string\r\n* GoodSource: Read data from the console using readLine()\r\n* BadSink: driverManager data used as password in database connection\r\n* Flow Variant: 01 Baseline\r\n*\r\n* */\r\n\r\npackage testcases.CWE259_Hard_Coded_Password;\r\n\r\nimport testcasesupport.*;\r\n\r\nimport java.util.logging.Level;\r\nimport java.io.*;\r\n\r\nimport java.sql.*;\r\n\r\npublic class CWE259_Hard_Coded_Password__driverManager_01 extends AbstractTestCase\r\n{\r\n /* uses badsource and badsink */\r\n public void bad() throws Throwable\r\n {\r\n String data;\r\n\r\n /* FLAW: Set data to a hardcoded string */\r\n data = \"7e5tc4s3\";\r\n\r\n Connection connection = null;\r\n PreparedStatement preparedStatement = null;\r\n ResultSet resultSet = null;\r\n\r\n if (data != null)\r\n {\r\n try\r\n {\r\n /* POTENTIAL FLAW: data used as password in database connection */\r\n connection = DriverManager.getConnection(\"data-url\", \"root\", data);\r\n preparedStatement = connection.prepareStatement(\"select * from test_table\");\r\n resultSet = preparedStatement.executeQuery();\r\n }\r\n catch (SQLException exceptSql)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error with database connection\", exceptSql);\r\n }\r\n finally\r\n {\r\n try\r\n {\r\n if (resultSet != null)\r\n {\r\n resultSet.close();\r\n }\r\n }\r\n catch (SQLException exceptSql)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error closing ResultSet\", exceptSql);\r\n }\r\n\r\n try\r\n {\r\n if (preparedStatement != null)\r\n {\r\n preparedStatement.close();\r\n }\r\n }\r\n catch (SQLException exceptSql)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error closing PreparedStatement\", exceptSql);\r\n }\r\n\r\n try\r\n {\r\n if (connection != null)\r\n {\r\n connection.close();\r\n }\r\n }\r\n catch (SQLException exceptSql)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error closing Connection\", exceptSql);\r\n }\r\n }\r\n }\r\n\r\n }\r\n\r\n public void good() throws Throwable\r\n {\r\n goodG2B();\r\n }\r\n\r\n /* goodG2B() - uses goodsource and badsink */\r\n private void goodG2B() throws Throwable\r\n {\r\n String data;\r\n\r\n data = \"\"; /* init data */\r\n\r\n /* FIX: Read data from the console using readLine() */\r\n try\r\n {\r\n InputStreamReader readerInputStream = new InputStreamReader(System.in, \"UTF-8\");\r\n BufferedReader readerBuffered = new BufferedReader(readerInputStream);\r\n\r\n /* POTENTIAL FLAW: Read data from the console using readLine */\r\n data = readerBuffered.readLine();\r\n }\r\n catch (IOException exceptIO)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error with stream reading\", exceptIO);\r\n }\r\n\r\n /* NOTE: Tools may report a flaw here because readerBuffered and readerInputStream are not closed. Unfortunately, closing those will close System.in, which will cause any future attempts to read from the console to fail and throw an exception */\r\n\r\n Connection connection = null;\r\n PreparedStatement preparedStatement = null;\r\n ResultSet resultSet = null;\r\n\r\n if (data != null)\r\n {\r\n try\r\n {\r\n /* POTENTIAL FLAW: data used as password in database connection */\r\n connection = DriverManager.getConnection(\"data-url\", \"root\", data);\r\n preparedStatement = connection.prepareStatement(\"select * from test_table\");\r\n resultSet = preparedStatement.executeQuery();\r\n }\r\n catch (SQLException exceptSql)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error with database connection\", exceptSql);\r\n }\r\n finally\r\n {\r\n try\r\n {\r\n if (resultSet != null)\r\n {\r\n resultSet.close();\r\n }\r\n }\r\n catch (SQLException exceptSql)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error closing ResultSet\", exceptSql);\r\n }\r\n\r\n try\r\n {\r\n if (preparedStatement != null)\r\n {\r\n preparedStatement.close();\r\n }\r\n }\r\n catch (SQLException exceptSql)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error closing PreparedStatement\", exceptSql);\r\n }\r\n\r\n try\r\n {\r\n if (connection != null)\r\n {\r\n connection.close();\r\n }\r\n }\r\n catch (SQLException exceptSql)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error closing Connection\", exceptSql);\r\n }\r\n }\r\n }\r\n\r\n }\r\n\r\n /* Below is the main(). It is only used when building this testcase on\r\n * its own for testing or for building a binary to use in testing binary\r\n * analysis tools. It is not used when compiling all the testcases as one\r\n * application, which is how source code analysis tools are tested.\r\n */\r\n public static void main(String[] args) throws ClassNotFoundException,\r\n InstantiationException, IllegalAccessException\r\n {\r\n mainFromParent(args);\r\n }\r\n}\r\n\r\n", "instruction": "Tinjau kasus uji Juliet berikut untuk CWE-259 (Hard Coded Password). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.", "labels_json": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\", \"goodG2B\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-259\"}", "language": "Java", "output": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\", \"goodG2B\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-259\"}", "provenance_json": "{\"ground_truth_basis\": \"Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.\", \"selection_policy\": \"First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.\", \"source_download_url\": \"https://samate.nist.gov/SARD/downloads/test-suites/2017-10-01-juliet-test-suite-for-java-v1-3.zip\", \"source_file\": \"Java/src/testcases/CWE259_Hard_Coded_Password/CWE259_Hard_Coded_Password__driverManager_01.java\", \"source_license\": \"US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page\", \"source_sha256\": \"49c2d44780e8de1f5ba87f71a839b081dd546e60a0f501f47e25670d67ca8b24\", \"source_suite\": \"Juliet Java 1.3\", \"source_suite_id\": \"111\", \"source_url\": \"https://samate.nist.gov/SARD/test-suites/111\", \"target_cwe\": \"CWE-259\", \"target_weakness\": \"Hard Coded Password\"}", "source": "Juliet Java 1.3", "split": "test", "task_type": "paired_security_review"}
9
+ {"domain": "secure_coding", "id": "juliet-java-cwe-378-5da88d1c84a4", "input": "/* TEMPLATE GENERATED TESTCASE FILE\r\nFilename: CWE378_Temporary_File_Creation_With_Insecure_Perms__basic_01.java\r\nLabel Definition File: CWE378_Temporary_File_Creation_With_Insecure_Perms__basic.label.xml\r\nTemplate File: point-flaw-01.tmpl.java\r\n*/\r\n/*\r\n* @description\r\n* CWE: 378 Explicitly set permissions on files\r\n* Sinks:\r\n* GoodSink: Restrict permissions on file\r\n* BadSink : Permissions never set on file\r\n* Flow Variant: 01 Baseline\r\n*\r\n* */\r\n\r\npackage testcases.CWE378_Temporary_File_Creation_With_Insecure_Perms;\r\n\r\nimport testcasesupport.*;\r\n\r\nimport java.io.FileOutputStream;\r\nimport java.io.OutputStreamWriter;\r\nimport java.io.BufferedWriter;\r\nimport java.io.File;\r\nimport java.io.IOException;\r\n\r\nimport java.util.logging.Level;\r\n\r\npublic class CWE378_Temporary_File_Creation_With_Insecure_Perms__basic_01 extends AbstractTestCase\r\n{\r\n public void bad() throws Throwable\r\n {\r\n\r\n FileOutputStream streamFileOutput = null;\r\n OutputStreamWriter writerOutputStream = null;\r\n BufferedWriter writerBuffered = null;\r\n File tempFile = null;\r\n\r\n try\r\n {\r\n tempFile = File.createTempFile(\"temp\", \"1234\");\r\n\r\n /* FLAW: Permissions never set on file */\r\n\r\n /* Write something to the file */\r\n streamFileOutput = new FileOutputStream(tempFile);\r\n writerOutputStream = new OutputStreamWriter(streamFileOutput, \"UTF-8\");\r\n writerBuffered = new BufferedWriter(writerOutputStream);\r\n writerBuffered.write(42);\r\n }\r\n catch (IOException exceptIO)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error writing to temporary file\", exceptIO);\r\n }\r\n finally\r\n {\r\n /* Delete the temporary file */\r\n if (tempFile.exists())\r\n {\r\n tempFile.delete();\r\n }\r\n\r\n try\r\n {\r\n if (writerBuffered != null)\r\n {\r\n writerBuffered.close();\r\n }\r\n }\r\n catch (IOException exceptIO)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error closing BufferedWriter\", exceptIO);\r\n }\r\n\r\n try\r\n {\r\n if (writerOutputStream != null)\r\n {\r\n writerOutputStream.close();\r\n }\r\n }\r\n catch (IOException exceptIO)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error closing OutputStreamWriter\", exceptIO);\r\n }\r\n\r\n try\r\n {\r\n if (streamFileOutput != null)\r\n {\r\n streamFileOutput.close();\r\n }\r\n }\r\n catch (IOException exceptIO)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error closing FileOutputStream\", exceptIO);\r\n }\r\n }\r\n\r\n }\r\n\r\n public void good() throws Throwable\r\n {\r\n good1();\r\n }\r\n\r\n private void good1() throws Throwable\r\n {\r\n\r\n FileOutputStream streamFileOutput = null;\r\n OutputStreamWriter writerOutputStream = null;\r\n BufferedWriter writerBuffered = null;\r\n File tempFile = null;\r\n\r\n try\r\n {\r\n tempFile = File.createTempFile(\"temp\", \"1234\");\r\n\r\n /* FIX: Set file as writable by owner, readable by owner, not executable (if file system supports it) */\r\n if (!tempFile.setWritable(true, true))\r\n {\r\n IO.logger.log(Level.WARNING, \"Could not set Writable permissions\");\r\n }\r\n if (!tempFile.setReadable(true, true))\r\n {\r\n IO.logger.log(Level.WARNING, \"Could not set Readable permissions\");\r\n }\r\n if (!tempFile.setExecutable(false))\r\n {\r\n IO.logger.log(Level.WARNING, \"Could not set Executable permissions\");\r\n }\r\n\r\n /* Write something to the file */\r\n streamFileOutput = new FileOutputStream(tempFile);\r\n writerOutputStream = new OutputStreamWriter(streamFileOutput, \"UTF-8\");\r\n writerBuffered = new BufferedWriter(writerOutputStream);\r\n writerBuffered.write(42);\r\n }\r\n catch (IOException exceptIO)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error writing to temporary file\", exceptIO);\r\n }\r\n finally\r\n {\r\n /* Delete the temporary file */\r\n if (tempFile.exists())\r\n {\r\n tempFile.delete();\r\n }\r\n\r\n try\r\n {\r\n if (writerBuffered != null)\r\n {\r\n writerBuffered.close();\r\n }\r\n }\r\n catch (IOException exceptIO)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error closing BufferedWriter\", exceptIO);\r\n }\r\n\r\n try\r\n {\r\n if (writerOutputStream != null)\r\n {\r\n writerOutputStream.close();\r\n }\r\n }\r\n catch (IOException exceptIO)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error closing OutputStreamWriter\", exceptIO);\r\n }\r\n\r\n try\r\n {\r\n if (streamFileOutput != null)\r\n {\r\n streamFileOutput.close();\r\n }\r\n }\r\n catch (IOException exceptIO)\r\n {\r\n IO.logger.log(Level.WARNING, \"Error closing FileOutputStream\", exceptIO);\r\n }\r\n }\r\n\r\n }\r\n\r\n /* Below is the main(). It is only used when building this testcase on\r\n * its own for testing or for building a binary to use in testing binary\r\n * analysis tools. It is not used when compiling all the testcases as one\r\n * application, which is how source code analysis tools are tested.\r\n */\r\n public static void main(String[] args) throws ClassNotFoundException,\r\n InstantiationException, IllegalAccessException\r\n {\r\n mainFromParent(args);\r\n }\r\n}\r\n\r\n", "instruction": "Tinjau kasus uji Juliet berikut untuk CWE-378 (Temporary File Creation With Insecure Perms). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.", "labels_json": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-378\"}", "language": "Java", "output": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-378\"}", "provenance_json": "{\"ground_truth_basis\": \"Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.\", \"selection_policy\": \"First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.\", \"source_download_url\": \"https://samate.nist.gov/SARD/downloads/test-suites/2017-10-01-juliet-test-suite-for-java-v1-3.zip\", \"source_file\": \"Java/src/testcases/CWE378_Temporary_File_Creation_With_Insecure_Perms/CWE378_Temporary_File_Creation_With_Insecure_Perms__basic_01.java\", \"source_license\": \"US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page\", \"source_sha256\": \"5da88d1c84a47bc7630f3e7038633c24fce3bc17bd7e93cc115ead278ecefc29\", \"source_suite\": \"Juliet Java 1.3\", \"source_suite_id\": \"111\", \"source_url\": \"https://samate.nist.gov/SARD/test-suites/111\", \"target_cwe\": \"CWE-378\", \"target_weakness\": \"Temporary File Creation With Insecure Perms\"}", "source": "Juliet Java 1.3", "split": "test", "task_type": "paired_security_review"}
10
+ {"domain": "secure_coding", "id": "juliet-java-cwe-477-826c3aa6f0a9", "input": "/* TEMPLATE GENERATED TESTCASE FILE\r\nFilename: CWE477_Obsolete_Functions__DataInputStream_readLine_01.java\r\nLabel Definition File: CWE477_Obsolete_Functions.label.xml\r\nTemplate File: point-flaw-01.tmpl.java\r\n*/\r\n/*\r\n* @description\r\n* CWE: 477 Use of Obsolete Functions\r\n* Sinks: DataInputStream_readLine\r\n* GoodSink: Use of preferred BufferedReader.readLine() method\r\n* BadSink : Use deprecated DataInputStream.readLine() method\r\n* Flow Variant: 01 Baseline\r\n*\r\n* */\r\n\r\npackage testcases.CWE477_Obsolete_Functions;\r\n\r\nimport testcasesupport.*;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.InputStreamReader;\r\nimport java.io.DataInputStream;\r\n\r\npublic class CWE477_Obsolete_Functions__DataInputStream_readLine_01 extends AbstractTestCase\r\n{\r\n public void bad() throws Throwable\r\n {\r\n\r\n /* Read a line of user input from console with deprecated DataInputStream.readLine() method */\r\n {\r\n /* FLAW: Read input from the console using DataInputStream.readLine() */\r\n DataInputStream streamDataInput = new DataInputStream(System.in);\r\n String myString = streamDataInput.readLine();\r\n\r\n IO.writeLine(myString); /* Use myString */\r\n\r\n /* NOTE: Tools may report a flaw here because streamDataInput is not closed. Unfortunately, closing that will close System.in, which will cause any future attempts to read from the console to fail and throw an exception */\r\n }\r\n\r\n }\r\n\r\n public void good() throws Throwable\r\n {\r\n good1();\r\n }\r\n\r\n private void good1() throws Throwable\r\n {\r\n\r\n /* Read a line of user input from console with preferred BufferedReader.readLine() method */\r\n {\r\n InputStreamReader readerInputStream = new InputStreamReader(System.in, \"UTF-8\");\r\n BufferedReader readerBuffered = new BufferedReader(readerInputStream);\r\n\r\n /* FIX: Read input from the console using preferred method BufferedReader.readLine() */\r\n String myString = readerBuffered.readLine();\r\n\r\n IO.writeLine(myString); /* Use myString */\r\n\r\n /* NOTE: Tools may report a flaw here because readerBuffered and readerInputStream are not closed. Unfortunately, closing those will close System.in, which will cause any future attempts to read from the console to fail and throw an exception */\r\n }\r\n\r\n }\r\n\r\n /* Below is the main(). It is only used when building this testcase on\r\n * its own for testing or for building a binary to use in testing binary\r\n * analysis tools. It is not used when compiling all the testcases as one\r\n * application, which is how source code analysis tools are tested.\r\n */\r\n public static void main(String[] args) throws ClassNotFoundException,\r\n InstantiationException, IllegalAccessException\r\n {\r\n mainFromParent(args);\r\n }\r\n}\r\n\r\n", "instruction": "Tinjau kasus uji Juliet berikut untuk CWE-477 (Obsolete Functions). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.", "labels_json": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-477\"}", "language": "Java", "output": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-477\"}", "provenance_json": "{\"ground_truth_basis\": \"Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.\", \"selection_policy\": \"First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.\", \"source_download_url\": \"https://samate.nist.gov/SARD/downloads/test-suites/2017-10-01-juliet-test-suite-for-java-v1-3.zip\", \"source_file\": \"Java/src/testcases/CWE477_Obsolete_Functions/CWE477_Obsolete_Functions__DataInputStream_readLine_01.java\", \"source_license\": \"US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page\", \"source_sha256\": \"826c3aa6f0a9a68210b9fcc8b1d542a0aa4c2ecb3009121412bb395aa85be30b\", \"source_suite\": \"Juliet Java 1.3\", \"source_suite_id\": \"111\", \"source_url\": \"https://samate.nist.gov/SARD/test-suites/111\", \"target_cwe\": \"CWE-477\", \"target_weakness\": \"Obsolete Functions\"}", "source": "Juliet Java 1.3", "split": "test", "task_type": "paired_security_review"}
11
+ {"domain": "secure_coding", "id": "juliet-java-cwe-511-dae2fe38057c", "input": "/* TEMPLATE GENERATED TESTCASE FILE\r\nFilename: CWE511_Logic_Time_Bomb__counter_01.java\r\nLabel Definition File: CWE511_Logic_Time_Bomb.label.xml\r\nTemplate File: point-flaw-01.tmpl.java\r\n*/\r\n/*\r\n* @description\r\n* CWE: 511 Logic Time Bomb\r\n* Sinks: counter\r\n* GoodSink: If counter reaches a certain value, print to the console\r\n* BadSink : If counter reaches a certain value, launch an executable\r\n* Flow Variant: 01 Baseline\r\n*\r\n* */\r\n\r\npackage testcases.CWE511_Logic_Time_Bomb;\r\n\r\nimport testcasesupport.*;\r\n\r\npublic class CWE511_Logic_Time_Bomb__counter_01 extends AbstractTestCase\r\n{\r\n public void bad() throws Throwable\r\n {\r\n\r\n int count = 0;\r\n\r\n do\r\n {\r\n /* FLAW: counter triggered backdoor */\r\n if (count == 20000)\r\n {\r\n Runtime.getRuntime().exec(\"c:\\\\windows\\\\system32\\\\evil.exe\");\r\n }\r\n count++;\r\n }\r\n while (count < Integer.MAX_VALUE);\r\n\r\n }\r\n\r\n public void good() throws Throwable\r\n {\r\n good1();\r\n }\r\n\r\n private void good1() throws Throwable\r\n {\r\n\r\n int count = 0;\r\n\r\n do\r\n {\r\n /* FIX: no backdoor exists */\r\n if (count == 20000)\r\n {\r\n IO.writeLine(\"Sorry, your license has expired. Please contact support.\");\r\n }\r\n count++;\r\n }\r\n while (count < Integer.MAX_VALUE);\r\n\r\n }\r\n\r\n /* Below is the main(). It is only used when building this testcase on\r\n * its own for testing or for building a binary to use in testing binary\r\n * analysis tools. It is not used when compiling all the testcases as one\r\n * application, which is how source code analysis tools are tested.\r\n */\r\n public static void main(String[] args) throws ClassNotFoundException,\r\n InstantiationException, IllegalAccessException\r\n {\r\n mainFromParent(args);\r\n }\r\n}\r\n\r\n", "instruction": "Tinjau kasus uji Juliet berikut untuk CWE-511 (Logic Time Bomb). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.", "labels_json": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-511\"}", "language": "Java", "output": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-511\"}", "provenance_json": "{\"ground_truth_basis\": \"Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.\", \"selection_policy\": \"First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.\", \"source_download_url\": \"https://samate.nist.gov/SARD/downloads/test-suites/2017-10-01-juliet-test-suite-for-java-v1-3.zip\", \"source_file\": \"Java/src/testcases/CWE511_Logic_Time_Bomb/CWE511_Logic_Time_Bomb__counter_01.java\", \"source_license\": \"US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page\", \"source_sha256\": \"dae2fe38057c61ec2429dca75a322c507249dabca0accd40ef1f59829c476756\", \"source_suite\": \"Juliet Java 1.3\", \"source_suite_id\": \"111\", \"source_url\": \"https://samate.nist.gov/SARD/test-suites/111\", \"target_cwe\": \"CWE-511\", \"target_weakness\": \"Logic Time Bomb\"}", "source": "Juliet Java 1.3", "split": "test", "task_type": "paired_security_review"}
12
+ {"domain": "secure_coding", "id": "juliet-java-cwe-579-77d454858c10", "input": "/*\r\n * @description \r\n * bad case class is not serializable. \r\n * good case class is serializable.\r\n * \r\n * */\r\n\r\n/* note on servlets - when a new Servlet is created, it must be listed in the web.xml\r\n * file in order to run. The easy way to do this is in Eclipse:\r\n * - right click on testcases in package explorer\r\n * - select New->Servlet\r\n * - Check the box that says use an existing Servlet class or JSP\r\n * - Click browse and select the new Servlet class you have created\r\n * - Click OK, Next, then Finish \r\n * - You should now be able to test the servlet by clicking Run in eclipse \r\n */\r\n\r\npackage testcases.CWE579_Non_Serializable_in_Session;\r\n\r\nimport java.io.IOException;\r\nimport java.io.Serializable;\r\n\r\nimport javax.servlet.http.HttpServletRequest;\r\nimport javax.servlet.http.HttpServletResponse;\r\n\r\nimport testcasesupport.AbstractTestCaseServlet;\r\n\r\npublic class CWE579_Non_Serializable_in_Session__Servlet_01 extends AbstractTestCaseServlet \r\n{\r\n private static final long serialVersionUID = 1L;\r\n\r\n static class BadObject /* FLAW: non-serializable object being set in session */\r\n {\r\n public String badString = \"Bad\";\r\n }\r\n \r\n static class GoodObject implements Serializable /* FIX: serializable object being set in session */\r\n {\r\n private static final long serialVersionUID = 7925935052619185041L; \r\n public String goodString = \"Good\";\r\n }\r\n \r\n public void bad(HttpServletRequest request, HttpServletResponse response) throws IOException \r\n {\r\n\r\n BadObject badObject = new BadObject();\r\n request.getSession(true).setAttribute(\"BadObject\", badObject);\r\n \r\n response.getWriter().println(((BadObject)request.getSession().getAttribute(\"BadObject\")).badString);\r\n }\r\n\r\n private void good1(HttpServletRequest request, HttpServletResponse response) throws IOException \r\n {\r\n\r\n GoodObject goodObject = new GoodObject();\r\n request.getSession(true).setAttribute(\"GoodObject\", goodObject);\r\n \r\n response.getWriter().println(((GoodObject)request.getSession().getAttribute(\"GoodObject\")).goodString);\r\n }\r\n \r\n public void good(HttpServletRequest request, HttpServletResponse response) throws IOException \r\n {\r\n good1(request, response);\r\n }\r\n}\r\n", "instruction": "Tinjau kasus uji Juliet berikut untuk CWE-579 (Non Serializable in Session). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.", "labels_json": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-579\"}", "language": "Java", "output": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-579\"}", "provenance_json": "{\"ground_truth_basis\": \"Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.\", \"selection_policy\": \"First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.\", \"source_download_url\": \"https://samate.nist.gov/SARD/downloads/test-suites/2017-10-01-juliet-test-suite-for-java-v1-3.zip\", \"source_file\": \"Java/src/testcases/CWE579_Non_Serializable_in_Session/CWE579_Non_Serializable_in_Session__Servlet_01.java\", \"source_license\": \"US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page\", \"source_sha256\": \"77d454858c105da92e5be6dc3f0f435945dc59b80688d7717e7ea39b100f415f\", \"source_suite\": \"Juliet Java 1.3\", \"source_suite_id\": \"111\", \"source_url\": \"https://samate.nist.gov/SARD/test-suites/111\", \"target_cwe\": \"CWE-579\", \"target_weakness\": \"Non Serializable in Session\"}", "source": "Juliet Java 1.3", "split": "test", "task_type": "paired_security_review"}
13
+ {"domain": "secure_coding", "id": "juliet-java-cwe-606-7f32f8425830", "input": "/* TEMPLATE GENERATED TESTCASE FILE\r\nFilename: CWE606_Unchecked_Loop_Condition__Environment_01.java\r\nLabel Definition File: CWE606_Unchecked_Loop_Condition.label.xml\r\nTemplate File: sources-sinks-01.tmpl.java\r\n*/\r\n/*\r\n* @description\r\n* CWE: 606 Unchecked Input for Loop Condition\r\n* BadSource: Environment Read data from an environment variable\r\n* GoodSource: hardcoded int in string form\r\n* Sinks:\r\n* GoodSink: validate loop variable\r\n* BadSink : loop variable not validated\r\n* Flow Variant: 01 Baseline\r\n*\r\n* */\r\n\r\npackage testcases.CWE606_Unchecked_Loop_Condition;\r\n\r\nimport testcasesupport.*;\r\n\r\nimport javax.servlet.http.*;\r\n\r\npublic class CWE606_Unchecked_Loop_Condition__Environment_01 extends AbstractTestCase\r\n{\r\n public void bad() throws Throwable\r\n {\r\n String data;\r\n\r\n /* get environment variable ADD */\r\n /* POTENTIAL FLAW: Read data from an environment variable */\r\n data = System.getenv(\"ADD\");\r\n\r\n int numberOfLoops;\r\n try\r\n {\r\n numberOfLoops = Integer.parseInt(data);\r\n }\r\n catch (NumberFormatException exceptNumberFormat)\r\n {\r\n IO.writeLine(\"Invalid response. Numeric input expected. Assuming 1.\");\r\n numberOfLoops = 1;\r\n }\r\n\r\n for (int i=0; i < numberOfLoops; i++)\r\n {\r\n /* POTENTIAL FLAW: user supplied input used for loop counter test */\r\n IO.writeLine(\"hello world\");\r\n }\r\n\r\n }\r\n\r\n public void good() throws Throwable\r\n {\r\n goodG2B();\r\n goodB2G();\r\n }\r\n\r\n /* goodG2B() - use goodsource and badsink */\r\n private void goodG2B() throws Throwable\r\n {\r\n String data;\r\n\r\n /* FIX: Use a hardcoded int as a string */\r\n data = \"5\";\r\n\r\n int numberOfLoops;\r\n try\r\n {\r\n numberOfLoops = Integer.parseInt(data);\r\n }\r\n catch (NumberFormatException exceptNumberFormat)\r\n {\r\n IO.writeLine(\"Invalid response. Numeric input expected. Assuming 1.\");\r\n numberOfLoops = 1;\r\n }\r\n\r\n for (int i=0; i < numberOfLoops; i++)\r\n {\r\n /* POTENTIAL FLAW: user supplied input used for loop counter test */\r\n IO.writeLine(\"hello world\");\r\n }\r\n\r\n }\r\n\r\n /* goodB2G() - use badsource and goodsink */\r\n private void goodB2G() throws Throwable\r\n {\r\n String data;\r\n\r\n /* get environment variable ADD */\r\n /* POTENTIAL FLAW: Read data from an environment variable */\r\n data = System.getenv(\"ADD\");\r\n\r\n int numberOfLoops;\r\n try\r\n {\r\n numberOfLoops = Integer.parseInt(data);\r\n }\r\n catch (NumberFormatException exceptNumberFormat)\r\n {\r\n IO.writeLine(\"Invalid response. Numeric input expected. Assuming 1.\");\r\n numberOfLoops = 1;\r\n }\r\n\r\n /* FIX: loop number thresholds validated */\r\n if (numberOfLoops >= 0 && numberOfLoops <= 5)\r\n {\r\n for (int i=0; i < numberOfLoops; i++)\r\n {\r\n IO.writeLine(\"hello world\");\r\n }\r\n }\r\n\r\n }\r\n\r\n /* Below is the main(). It is only used when building this testcase on\r\n * its own for testing or for building a binary to use in testing binary\r\n * analysis tools. It is not used when compiling all the testcases as one\r\n * application, which is how source code analysis tools are tested.\r\n */\r\n public static void main(String[] args) throws ClassNotFoundException,\r\n InstantiationException, IllegalAccessException\r\n {\r\n mainFromParent(args);\r\n }\r\n}\r\n\r\n", "instruction": "Tinjau kasus uji Juliet berikut untuk CWE-606 (Unchecked Loop Condition). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.", "labels_json": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\", \"goodB2G\", \"goodG2B\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-606\"}", "language": "Java", "output": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\", \"goodB2G\", \"goodG2B\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-606\"}", "provenance_json": "{\"ground_truth_basis\": \"Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.\", \"selection_policy\": \"First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.\", \"source_download_url\": \"https://samate.nist.gov/SARD/downloads/test-suites/2017-10-01-juliet-test-suite-for-java-v1-3.zip\", \"source_file\": \"Java/src/testcases/CWE606_Unchecked_Loop_Condition/CWE606_Unchecked_Loop_Condition__Environment_01.java\", \"source_license\": \"US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page\", \"source_sha256\": \"7f32f8425830b1aeec65e3078b1c72cae6c48b9e8fa8e04048f12d30f2f5f4b6\", \"source_suite\": \"Juliet Java 1.3\", \"source_suite_id\": \"111\", \"source_url\": \"https://samate.nist.gov/SARD/test-suites/111\", \"target_cwe\": \"CWE-606\", \"target_weakness\": \"Unchecked Loop Condition\"}", "source": "Juliet Java 1.3", "split": "test", "task_type": "paired_security_review"}
14
+ {"domain": "secure_coding", "id": "juliet-java-cwe-617-d33883927ebb", "input": "/* TEMPLATE GENERATED TESTCASE FILE\r\nFilename: CWE617_Reachable_Assertion__false_01.java\r\nLabel Definition File: CWE617_Reachable_Assertion.label.xml\r\nTemplate File: point-flaw-01.tmpl.java\r\n*/\r\n/*\r\n* @description\r\n* CWE: 617 Assertion is reachable\r\n* Sinks: false\r\n* GoodSink: assert true, which will never trigger\r\n* BadSink : assert false, which will always trigger\r\n* Flow Variant: 01 Baseline\r\n*\r\n* */\r\n\r\npackage testcases.CWE617_Reachable_Assertion;\r\n\r\nimport testcasesupport.*;\r\n\r\npublic class CWE617_Reachable_Assertion__false_01 extends AbstractTestCase\r\n{\r\n public void bad() throws Throwable\r\n {\r\n\r\n /* FLAW: this assertion can be reached, and will always trigger (if code is compiled using -ea option to enable assert) */\r\n assert false; /* INCIDENTAL: CWE 571 - expression is always true - it's \"true\" because assert(e) basically does if (!(e)) */\r\n\r\n }\r\n\r\n public void good() throws Throwable\r\n {\r\n good1();\r\n }\r\n\r\n private void good1() throws Throwable\r\n {\r\n\r\n /* FIX: ensure assertions cannot be triggered, in this case, to avoid an empty\r\n * function, assert true */\r\n assert true; /* INCIDENTAL: CWE 570 - expression is always false - it's \"false\" because assert(e) basically does if (!(e)) */\r\n\r\n }\r\n\r\n /* Below is the main(). It is only used when building this testcase on\r\n * its own for testing or for building a binary to use in testing binary\r\n * analysis tools. It is not used when compiling all the testcases as one\r\n * application, which is how source code analysis tools are tested.\r\n */\r\n public static void main(String[] args) throws ClassNotFoundException,\r\n InstantiationException, IllegalAccessException\r\n {\r\n mainFromParent(args);\r\n }\r\n}\r\n\r\n", "instruction": "Tinjau kasus uji Juliet berikut untuk CWE-617 (Reachable Assertion). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.", "labels_json": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-617\"}", "language": "Java", "output": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-617\"}", "provenance_json": "{\"ground_truth_basis\": \"Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.\", \"selection_policy\": \"First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.\", \"source_download_url\": \"https://samate.nist.gov/SARD/downloads/test-suites/2017-10-01-juliet-test-suite-for-java-v1-3.zip\", \"source_file\": \"Java/src/testcases/CWE617_Reachable_Assertion/CWE617_Reachable_Assertion__false_01.java\", \"source_license\": \"US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page\", \"source_sha256\": \"d33883927ebb8becde8f7f52f567945bcf990e8d39d90746afa230c3434ffcb2\", \"source_suite\": \"Juliet Java 1.3\", \"source_suite_id\": \"111\", \"source_url\": \"https://samate.nist.gov/SARD/test-suites/111\", \"target_cwe\": \"CWE-617\", \"target_weakness\": \"Reachable Assertion\"}", "source": "Juliet Java 1.3", "split": "test", "task_type": "paired_security_review"}
15
+ {"domain": "secure_coding", "id": "juliet-java-cwe-667-5111de76d83c", "input": "/*\r\n * @description Improper Locking\r\n * \r\n * */\r\npackage testcases.CWE667_Improper_Locking;\r\n\r\nimport java.util.concurrent.locks.ReentrantLock;\r\n\r\nimport testcasesupport.AbstractTestCase;\r\nimport testcasesupport.IO;\r\n\r\npublic class CWE667_Improper_Locking__basic_01 extends AbstractTestCase \r\n{\r\n static private int intBadNumber = 3;\r\n static private final ReentrantLock BAD_REENTRANT_LOCK = new ReentrantLock();\r\n\r\n static public void helperBad()\r\n {\r\n BAD_REENTRANT_LOCK.lock();\r\n \r\n intBadNumber++;\r\n \r\n IO.writeLine(intBadNumber);\r\n \r\n /* FLAW: lock is not unlocked */\r\n }\r\n \r\n public void bad() throws Throwable \r\n {\r\n helperBad();\r\n }\r\n\r\n static private int intGood1Number = 3;\r\n static private final ReentrantLock GOOD1_REENTRANT_LOCK = new ReentrantLock();\r\n\r\n static public void helperGood1()\r\n {\r\n GOOD1_REENTRANT_LOCK.lock();\r\n \r\n try\r\n {\r\n intGood1Number++;\r\n \r\n IO.writeLine(intGood1Number);\r\n }\r\n finally\r\n {\r\n /* FIX: Unlock the lock within a finally block */\r\n GOOD1_REENTRANT_LOCK.unlock();\r\n }\r\n }\r\n \r\n public void good1() throws Throwable \r\n {\r\n helperGood1();\r\n }\r\n\r\n public void good() throws Throwable \r\n {\r\n good1();\r\n }\r\n\r\n /* Below is the main(). It is only used when building this testcase on \r\n * its own for testing or for building a binary to use in testing binary \r\n * analysis tools. It is not used when compiling all the testcases as one \r\n * application, which is how source code analysis tools are tested. \r\n\t */ \r\n public static void main(String[] args) \r\n throws ClassNotFoundException, InstantiationException, IllegalAccessException \r\n {\r\n mainFromParent(args);\r\n }\r\n}\r\n", "instruction": "Tinjau kasus uji Juliet berikut untuk CWE-667 (Improper Locking). Identifikasi metode berlabel Bad dan Good menurut struktur kasus uji, lalu kembalikan JSON dengan nama metode dan cakupan label. Jangan menyimpulkan bahwa seluruh program aman di produksi hanya dari label Juliet.", "labels_json": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-667\"}", "language": "Java", "output": "{\"bad_method_names\": [\"bad\"], \"good_method_names\": [\"good\"], \"label_scope\": \"Juliet's intended target-weakness test-case roles; not a claim that the entire program is production-secure or exploitable in every environment\", \"target_cwe\": \"CWE-667\"}", "provenance_json": "{\"ground_truth_basis\": \"Explicit Bad/Good method names in the selected Juliet test-case source file; labels are source-derived, not LLM-generated.\", \"selection_policy\": \"First lexicographic test-case file per language and CWE containing explicit Bad and Good* methods; excludes support libraries, binaries, and files with explicit third-party SPDX/copyright headers.\", \"source_download_url\": \"https://samate.nist.gov/SARD/downloads/test-suites/2017-10-01-juliet-test-suite-for-java-v1-3.zip\", \"source_file\": \"Java/src/testcases/CWE667_Improper_Locking/CWE667_Improper_Locking__basic_01.java\", \"source_license\": \"US public domain; CC0 1.0 to the extent NIST may claim foreign rights, as stated on the official suite page\", \"source_sha256\": \"5111de76d83c9ef2e5e56f3d9a4cbf01158e508bf8176e60ed642d493123bdb1\", \"source_suite\": \"Juliet Java 1.3\", \"source_suite_id\": \"111\", \"source_url\": \"https://samate.nist.gov/SARD/test-suites/111\", \"target_cwe\": \"CWE-667\", \"target_weakness\": \"Improper Locking\"}", "source": "Juliet Java 1.3", "split": "test", "task_type": "paired_security_review"}
data/train.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/validation.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ requests>=2.31.0
2
+ PyYAML>=6.0
scrape_juice_shop.py ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Scrape curated Juice Shop code-fix challenge pairs from a pinned public commit.
3
+
4
+ Labels are deliberately narrow: the source file ending in `_correct` is marked as
5
+ correct by the upstream challenge. Other options are only `not_marked_correct`, not
6
+ asserted to be vulnerable. Only codefix challenge files are considered.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import hashlib
11
+ import json
12
+ import re
13
+ from concurrent.futures import ThreadPoolExecutor, as_completed
14
+ from pathlib import Path
15
+
16
+ import requests
17
+ import yaml
18
+
19
+ REPO = "juice-shop/juice-shop"
20
+ COMMIT = "c9f99228d9d56afb5f5ca7925376292f7fa44b13"
21
+ CODEFIX_ROOT = "data/static/codefixes/"
22
+ RAW = f"https://raw.githubusercontent.com/{REPO}/{COMMIT}/"
23
+ TREE_URL = f"https://api.github.com/repos/{REPO}/git/trees/{COMMIT}?recursive=1"
24
+ FILE_RE = re.compile(r"^data/static/codefixes/(.+)_(\d+)(_correct)?\.(ts|yml)$")
25
+ SECRET_RE = re.compile(
26
+ r"AKIA[0-9A-Z]{16}|gh[pousr]_[A-Za-z0-9_]{20,}|github_pat_[A-Za-z0-9_]{20,}|"
27
+ r"xox[baprs]-[A-Za-z0-9-]{20,}|-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|"
28
+ r"sk-[A-Za-z0-9]{32,}"
29
+ )
30
+
31
+
32
+ def sha256(data: bytes) -> str:
33
+ return hashlib.sha256(data).hexdigest()
34
+
35
+
36
+ def fetch(url: str) -> bytes:
37
+ response = requests.get(url, timeout=45)
38
+ response.raise_for_status()
39
+ return response.content
40
+
41
+
42
+ def read_fix_explanations(raw: bytes) -> dict[int, str]:
43
+ info = yaml.safe_load(raw.decode("utf-8")) or {}
44
+ fixes = info.get("fixes", [])
45
+ if not isinstance(fixes, list):
46
+ return {}
47
+ result = {}
48
+ for item in fixes:
49
+ if isinstance(item, dict) and "id" in item:
50
+ result[int(item["id"])] = str(item.get("explanation", ""))
51
+ return result
52
+
53
+
54
+ def main() -> None:
55
+ output_path = Path("staging/juice_shop_codefix_pairs.jsonl")
56
+ license_path = Path("LICENSES/OWASP-JUICE-SHOP-MIT.txt")
57
+ output_path.parent.mkdir(parents=True, exist_ok=True)
58
+ license_path.parent.mkdir(parents=True, exist_ok=True)
59
+
60
+ tree_response = requests.get(TREE_URL, timeout=60)
61
+ tree_response.raise_for_status()
62
+ tree = tree_response.json()
63
+ if tree.get("truncated"):
64
+ raise RuntimeError("GitHub tree response was truncated; refusing partial scraping")
65
+ paths = sorted(x["path"] for x in tree["tree"] if x["path"].startswith(CODEFIX_ROOT))
66
+
67
+ groups: dict[tuple[str, str], dict[str, dict[int, str]]] = {}
68
+ for path in paths:
69
+ match = FILE_RE.match(path)
70
+ if not match:
71
+ continue
72
+ stem, number, correct_marker, extension = match.groups()
73
+ key = (stem, extension)
74
+ group = groups.setdefault(key, {"candidates": {}, "correct": {}})
75
+ bucket = "correct" if correct_marker else "candidates"
76
+ group[bucket][int(number)] = path
77
+
78
+ selected = []
79
+ for (stem, extension), group in sorted(groups.items()):
80
+ if not group["correct"] or not group["candidates"]:
81
+ continue
82
+ info_path = f"{CODEFIX_ROOT}{stem}.info.yml"
83
+ if info_path not in paths:
84
+ continue
85
+ correct_id = min(group["correct"])
86
+ correct_path = group["correct"][correct_id]
87
+ # Pair each non-correct option with the explicitly source-marked correct one.
88
+ for candidate_id, candidate_path in sorted(group["candidates"].items()):
89
+ selected.append((stem, extension, candidate_id, candidate_path,
90
+ correct_id, correct_path, info_path))
91
+
92
+ # Download only the pinned challenge metadata and code samples; no repository-wide clone.
93
+ needed = sorted({p for row in selected for p in (row[3], row[5], row[6])})
94
+ needed.append("LICENSE")
95
+ fetched: dict[str, bytes] = {}
96
+ with ThreadPoolExecutor(max_workers=8) as pool:
97
+ future_map = {pool.submit(fetch, RAW + path): path for path in needed}
98
+ for future in as_completed(future_map):
99
+ fetched[future_map[future]] = future.result()
100
+
101
+ # Preserve the exact upstream MIT license text beside the redistributed samples.
102
+ license_path.write_bytes(fetched["LICENSE"])
103
+ license_text = fetched["LICENSE"].decode("utf-8", "replace")
104
+ if "Permission is hereby granted, free of charge" not in license_text:
105
+ raise RuntimeError("Pinned repository LICENSE did not contain MIT License")
106
+
107
+ records = []
108
+ for stem, extension, candidate_id, candidate_path, correct_id, correct_path, info_path in selected:
109
+ candidate_raw = fetched[candidate_path]
110
+ correct_raw = fetched[correct_path]
111
+ info_raw = fetched[info_path]
112
+ candidate = candidate_raw.decode("utf-8", "replace")
113
+ correct = correct_raw.decode("utf-8", "replace")
114
+ if len(candidate_raw) < 20 or len(correct_raw) < 20 or len(candidate_raw) > 40_000 or len(correct_raw) > 40_000:
115
+ continue
116
+ # File-level holdbacks: explicit third-party copyright/SPDX or secret-like material.
117
+ for raw in (candidate_raw, correct_raw):
118
+ top = "\n".join(raw.decode("utf-8", "replace").splitlines()[:30]).lower()
119
+ if "spdx-license-identifier" in top or "copyright" in top:
120
+ break
121
+ if SECRET_RE.search(raw.decode("utf-8", "replace")):
122
+ break
123
+ else:
124
+ explanations = read_fix_explanations(info_raw)
125
+ if candidate_id not in explanations or correct_id not in explanations:
126
+ continue
127
+ label = {
128
+ "challenge_id": stem,
129
+ "candidate_fix_id": candidate_id,
130
+ "candidate_label": "not_marked_correct_by_upstream_challenge",
131
+ "approved_fix_id": correct_id,
132
+ "approved_label": "marked_correct_by_upstream_challenge",
133
+ "candidate_explanation": explanations[candidate_id],
134
+ "approved_explanation": explanations[correct_id],
135
+ "label_scope": "Correctness is relative to the upstream Juice Shop code-fix challenge; the candidate is not asserted to be exploitable, and the approved snippet is not a universal security guarantee.",
136
+ "approved_code": correct,
137
+ }
138
+ identifier = f"juice-shop-{stem.lower()}-{candidate_id}-to-{correct_id}-{sha256(candidate_raw)[:10]}"
139
+ records.append({
140
+ "id": identifier,
141
+ "task_type": "review_code_fix_candidate",
142
+ "domain": "web_application_security",
143
+ "language": "TypeScript" if extension == "ts" else "YAML",
144
+ "instruction": "Tinjau kandidat perubahan kode dari tantangan OWASP Juice Shop berikut. Bandingkan dengan solusi yang ditandai benar oleh tantangan, lalu kembalikan JSON yang menyebutkan ID solusi resmi, kode solusi, dan batas cakupan label. Jangan menyimpulkan bahwa kandidat pasti dapat dieksploitasi atau solusi resmi pasti aman untuk semua sistem.",
145
+ "input": candidate,
146
+ "output": json.dumps(label, ensure_ascii=False, sort_keys=True),
147
+ "challenge_id": stem,
148
+ "candidate_fix_id": candidate_id,
149
+ "approved_fix_id": correct_id,
150
+ "source_repo": REPO,
151
+ "source_commit": COMMIT,
152
+ "candidate_source_file": candidate_path,
153
+ "correct_source_file": correct_path,
154
+ "metadata_source_file": info_path,
155
+ "candidate_source_url": RAW + candidate_path,
156
+ "correct_source_url": RAW + correct_path,
157
+ "metadata_source_url": RAW + info_path,
158
+ "source_license": "MIT (root LICENSE at the pinned Juice Shop commit; codefix files were checked for explicit SPDX/copyright headers)",
159
+ "candidate_sha256": sha256(candidate_raw),
160
+ "correct_sha256": sha256(correct_raw),
161
+ "metadata_sha256": sha256(info_raw),
162
+ "selection_policy": "All TypeScript/YAML code-fix alternatives with a corresponding `_correct` file and challenge explanation at the pinned commit; excluded files with explicit top-of-file SPDX/copyright headers or secret-like material.",
163
+ "split": "challenge_fix",
164
+ })
165
+
166
+ records.sort(key=lambda r: (r["challenge_id"], r["candidate_fix_id"]))
167
+ with output_path.open("w", encoding="utf-8", newline="\n") as f:
168
+ for record in records:
169
+ f.write(json.dumps(record, ensure_ascii=False, sort_keys=True) + "\n")
170
+ print(json.dumps({
171
+ "repo": REPO,
172
+ "commit": COMMIT,
173
+ "challenge_groups_seen": len(groups),
174
+ "candidate_pairs_included": len(records),
175
+ "by_language": {
176
+ language: sum(r["language"] == language for r in records)
177
+ for language in ("TypeScript", "YAML")
178
+ },
179
+ "output": str(output_path),
180
+ "license": str(license_path),
181
+ }, ensure_ascii=False, indent=2))
182
+
183
+
184
+ if __name__ == "__main__":
185
+ main()