Zreby commited on
Commit
dad87de
·
1 Parent(s): 488852d

Add audited OWASP BenchmarkJava samples

Browse files

Add 22 pinned BenchmarkJava v1.2 review cases with per-sample GPL notices, expected-results labels, provenance, tests, and manifest updates. Existing records remain unchanged.

CURATION_DECISIONS.md CHANGED
@@ -10,7 +10,9 @@ This candidate update keeps existing subsets unchanged and adds only material wh
10
 
11
  **OWASP WebGoat:** Three complete Java files, each carrying a file-level `GPL-2.0-or-later` notice and WebGoat authors' copyright notice, from commit `4e98f1cbbf896fdd06edcc9930515ebe0ade7c69`. The upstream license notice and full GPLv2 text are included. Two samples are intentionally vulnerable SQL-injection review examples, and one is a narrow parameterized-query reference. Upstream test files and their SHA-256 hashes are preserved as evidence in per-record provenance, but the tests themselves are not copied. Remediation snippets and labels are curator-authored, not upstream-validated patches; the records say so explicitly.
12
 
13
- The three subsets retain separate license terms. No single license is asserted for all code in the dataset. The WebGoat subset is redistributed under its applicable GPL terms, not relicensed under the MIT licenses used by other subsets. No AI/ML-specific clause was found in the reviewed WebGoat notices; this is not a separate legal determination about training rights.
 
 
14
 
15
  ## Sources held out
16
 
 
10
 
11
  **OWASP WebGoat:** Three complete Java files, each carrying a file-level `GPL-2.0-or-later` notice and WebGoat authors' copyright notice, from commit `4e98f1cbbf896fdd06edcc9930515ebe0ade7c69`. The upstream license notice and full GPLv2 text are included. Two samples are intentionally vulnerable SQL-injection review examples, and one is a narrow parameterized-query reference. Upstream test files and their SHA-256 hashes are preserved as evidence in per-record provenance, but the tests themselves are not copied. Remediation snippets and labels are curator-authored, not upstream-validated patches; the records say so explicitly.
12
 
13
+ **OWASP BenchmarkJava v1.2:** Twenty-two Java test cases from commit `10dfcc54ad02dcfcb358b0ba4a0fef8c919a6d17`, selected as one expected-vulnerable and one expected-not-vulnerable case from each of the benchmark's 11 categories. The exact test IDs, category, expected result, and CWE are preserved in the records and summarized in `DATA_SOURCES.md`. Each selected source file carries its own explicit GNU GPL version 2 redistribution/modification notice; the matching upstream license text is included. Expected labels are copied from the version-pinned `expectedresults-1.2.csv`, not inferred by the curator. Negative labels are limited to the matching benchmark test/category and do not mean the entire file or application is safe. The files are not paired fixes, and the small set is not intended for performance evaluation.
14
+
15
+ The four subsets retain separate license terms. No single license is asserted for all code in the dataset. The Java subsets are distributed under their respective GPL terms, not relicensed under the MIT licenses used by other subsets. No AI/ML-specific clause was found in the selected BenchmarkJava notices or GPLv2 text; this is not a separate legal determination about a particular training workflow or downstream model distribution.
16
 
17
  ## Sources held out
18
 
DATA_SOURCES.md CHANGED
@@ -1,6 +1,6 @@
1
  # Data sources and provenance
2
 
3
- This release combines three source subsets. `MANIFEST.json` gives the record totals and SHA-256 of each distributed JSONL file. Every record carries its source URL/path, source revision, source-code checksum, license metadata, and selection policy in `provenance_json`. No blanket license is applied to the complete repository.
4
 
5
  ## OWASP Juice Shop code-fix challenges
6
 
@@ -29,3 +29,27 @@ Source repository: [WebGoat/WebGoat](https://github.com/WebGoat/WebGoat), pinned
29
  The pinned upstream [`LICENSE.txt`](https://raw.githubusercontent.com/WebGoat/WebGoat/4e98f1cbbf896fdd06edcc9930515ebe0ade7c69/LICENSE.txt) identifies `GPL-2.0-or-later`; its SHA-256 is `2fea812568866fdb6ff99671ad70465bfc25ab77f86129795d08d961c30d2ca1`. An exact copy is included at [`LICENSES/WEBGOAT-UPSTREAM-LICENSE.txt`](LICENSES/WEBGOAT-UPSTREAM-LICENSE.txt). The full GPLv2 text is included at [`LICENSES/GPL-2.0-or-later.txt`](LICENSES/GPL-2.0-or-later.txt), copied from the SPDX license-list repository pinned to commit [`ab9b0904b43db6f4b67431efd8821feb821f1c8b`](https://github.com/spdx/license-list-data/tree/ab9b0904b43db6f4b67431efd8821feb821f1c8b); its SHA-256 is `aaf135472f81c5b4a0dca9367e5bb5e9750032b5bebe5442b36e4c0a47430df3`.
30
 
31
  Only the three listed WebGoat source files are copied into the new subset. Their source code is included verbatim, with original SPDX/copyright headers; test files are linked and hashed but not copied. The labels, instructions, explanatory text, and any remediation snippet are curator-authored and clearly identified as such. No AI/ML-specific grant or restriction was found in the inspected source notices or upstream license. That absence does not create separate training permission; the code remains subject to the applicable GPL terms.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # Data sources and provenance
2
 
3
+ This release combines four source subsets. `MANIFEST.json` gives the record totals and SHA-256 of each distributed JSONL file. Every record carries its source URL/path, source revision, source-code checksum, license metadata, and selection policy in `provenance_json`. No blanket license is applied to the complete repository.
4
 
5
  ## OWASP Juice Shop code-fix challenges
6
 
 
29
  The pinned upstream [`LICENSE.txt`](https://raw.githubusercontent.com/WebGoat/WebGoat/4e98f1cbbf896fdd06edcc9930515ebe0ade7c69/LICENSE.txt) identifies `GPL-2.0-or-later`; its SHA-256 is `2fea812568866fdb6ff99671ad70465bfc25ab77f86129795d08d961c30d2ca1`. An exact copy is included at [`LICENSES/WEBGOAT-UPSTREAM-LICENSE.txt`](LICENSES/WEBGOAT-UPSTREAM-LICENSE.txt). The full GPLv2 text is included at [`LICENSES/GPL-2.0-or-later.txt`](LICENSES/GPL-2.0-or-later.txt), copied from the SPDX license-list repository pinned to commit [`ab9b0904b43db6f4b67431efd8821feb821f1c8b`](https://github.com/spdx/license-list-data/tree/ab9b0904b43db6f4b67431efd8821feb821f1c8b); its SHA-256 is `aaf135472f81c5b4a0dca9367e5bb5e9750032b5bebe5442b36e4c0a47430df3`.
30
 
31
  Only the three listed WebGoat source files are copied into the new subset. Their source code is included verbatim, with original SPDX/copyright headers; test files are linked and hashed but not copied. The labels, instructions, explanatory text, and any remediation snippet are curator-authored and clearly identified as such. No AI/ML-specific grant or restriction was found in the inspected source notices or upstream license. That absence does not create separate training permission; the code remains subject to the applicable GPL terms.
32
+
33
+ ## OWASP BenchmarkJava v1.2 security test cases
34
+
35
+ Source repository: [OWASP-Benchmark/BenchmarkJava](https://github.com/OWASP-Benchmark/BenchmarkJava), pinned to commit [`10dfcc54ad02dcfcb358b0ba4a0fef8c919a6d17`](https://github.com/OWASP-Benchmark/BenchmarkJava/tree/10dfcc54ad02dcfcb358b0ba4a0fef8c919a6d17). The subset contains 22 complete Java source files from `src/main/java/org/owasp/benchmark/testcode/`. Each selected file has a file-level notice identifying the OWASP Benchmark Project and expressly permitting redistribution and modification under GNU GPL version 2. The matching full GPLv2 license from that pinned commit is included at [`LICENSES/OWASP-BENCHMARK-GPL-2.0.txt`](LICENSES/OWASP-BENCHMARK-GPL-2.0.txt); its SHA-256 is `c03cea027b4b40e4402fabd08557736727ec3d5bc54ad64ab6472de432198cad`.
36
+
37
+ Labels are taken directly from the pinned [`expectedresults-1.2.csv`](https://raw.githubusercontent.com/OWASP-Benchmark/BenchmarkJava/10dfcc54ad02dcfcb358b0ba4a0fef8c919a6d17/expectedresults-1.2.csv), whose SHA-256 is `1809f6a690c6cf7dd6685df6ebe2eef8fe3ca93d19a7ca0ce45987ca4f5d78e1`. The 22 selected test IDs, categories, and CWE values are:
38
+
39
+ | Category | Expected vulnerable | Expected not vulnerable | CWE |
40
+ |---|---|---|---|
41
+ | `cmdi` | `BenchmarkTest02613` | `BenchmarkTest02714` | CWE-78 |
42
+ | `crypto` | `BenchmarkTest02663` | `BenchmarkTest02662` | CWE-327 |
43
+ | `hash` | `BenchmarkTest02677` | `BenchmarkTest02678` | CWE-328 |
44
+ | `ldapi` | `BenchmarkTest02472` | `BenchmarkTest02572` | CWE-90 |
45
+ | `pathtraver` | `BenchmarkTest02569` | `BenchmarkTest02669` | CWE-22 |
46
+ | `securecookie` | `BenchmarkTest02710` | `BenchmarkTest02711` | CWE-614 |
47
+ | `sqli` | `BenchmarkTest02656` | `BenchmarkTest02740` | CWE-89 |
48
+ | `trustbound` | `BenchmarkTest02624` | `BenchmarkTest02726` | CWE-501 |
49
+ | `weakrand` | `BenchmarkTest02708` | `BenchmarkTest02721` | CWE-330 |
50
+ | `xpathi` | `BenchmarkTest02189` | `BenchmarkTest02457` | CWE-643 |
51
+ | `xss` | `BenchmarkTest02608` | `BenchmarkTest02712` | CWE-79 |
52
+
53
+ This is a small balanced review subset: one expected-positive and one expected-negative test for each of the 11 benchmark categories. Every record includes the source path and URL, source commit, code SHA-256, license-file SHA-256, expected-results URL and SHA-256, category, expected status, and CWE. These are benchmark test labels, not paired fixes or production incident assessments. A negative result means only that the benchmark does not expect that specific test case to trigger its designated vulnerability; it is not a general safety claim about the full file or application.
54
+
55
+ The selected source files and GPLv2 text contain no AI/ML-specific grant or restriction. The files themselves state the GPLv2 redistribution/modification terms, which remain applicable. This is not a separate legal determination about a particular model-training workflow or downstream distribution. The code is copied verbatim and has not been compiled or executed.
LICENSES/OWASP-BENCHMARK-GPL-2.0.txt ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ {description}
294
+ Copyright (C) {year} {fullname}
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ {signature of Ty Coon}, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
340
+
MANIFEST.json CHANGED
@@ -1,17 +1,22 @@
1
  {
2
  "by_language": {
3
- "Java": 3,
4
  "Solidity": 5,
5
  "TypeScript": 71,
6
  "YAML": 12
7
  },
8
  "by_split": {
 
9
  "challenge_fix": 83,
10
  "reference": 5,
11
  "webgoat_review": 3
12
  },
13
  "dataset": "security-code-curated-v1",
14
  "files": {
 
 
 
 
15
  "data/challenge_fix.jsonl": {
16
  "records": 83,
17
  "sha256": "67f75ff9743827aaf5c875edb94f6bb44430dfacf17f2f6ba44051016c583161"
@@ -26,7 +31,7 @@
26
  }
27
  },
28
  "license_scope": "Each source subset retains its own license and provenance; no single license is asserted for the complete dataset.",
29
- "record_count": 91,
30
  "schema_fields": [
31
  "id",
32
  "source",
@@ -41,6 +46,35 @@
41
  "provenance_json"
42
  ],
43
  "sources": {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  "OWASP Juice Shop": {
45
  "commit": "c9f99228d9d56afb5f5ca7925376292f7fa44b13",
46
  "languages": {
 
1
  {
2
  "by_language": {
3
+ "Java": 25,
4
  "Solidity": 5,
5
  "TypeScript": 71,
6
  "YAML": 12
7
  },
8
  "by_split": {
9
+ "benchmarkjava_review": 22,
10
  "challenge_fix": 83,
11
  "reference": 5,
12
  "webgoat_review": 3
13
  },
14
  "dataset": "security-code-curated-v1",
15
  "files": {
16
+ "data/benchmarkjava_review.jsonl": {
17
+ "records": 22,
18
+ "sha256": "c580ffa8efac7cdf0813216aa0a6b23898d888c77458bad6aee24164f61ca224"
19
+ },
20
  "data/challenge_fix.jsonl": {
21
  "records": 83,
22
  "sha256": "67f75ff9743827aaf5c875edb94f6bb44430dfacf17f2f6ba44051016c583161"
 
31
  }
32
  },
33
  "license_scope": "Each source subset retains its own license and provenance; no single license is asserted for the complete dataset.",
34
+ "record_count": 113,
35
  "schema_fields": [
36
  "id",
37
  "source",
 
46
  "provenance_json"
47
  ],
48
  "sources": {
49
+ "OWASP BenchmarkJava v1.2": {
50
+ "ai_ml_terms_review": "No AI/ML-specific grant or restriction was located in the selected sample headers or GPL-2.0 text; applicable GPL conditions remain in force, and this is not a separate legal determination about training.",
51
+ "categories": [
52
+ "cmdi",
53
+ "crypto",
54
+ "hash",
55
+ "ldapi",
56
+ "pathtraver",
57
+ "securecookie",
58
+ "sqli",
59
+ "trustbound",
60
+ "weakrand",
61
+ "xpathi",
62
+ "xss"
63
+ ],
64
+ "commit": "10dfcc54ad02dcfcb358b0ba4a0fef8c919a6d17",
65
+ "expected_results_file": "expectedresults-1.2.csv",
66
+ "expected_results_sha256": "1809f6a690c6cf7dd6685df6ebe2eef8fe3ca93d19a7ca0ce45987ca4f5d78e1",
67
+ "labels": {
68
+ "expected_not_vulnerable": 11,
69
+ "expected_vulnerable": 11
70
+ },
71
+ "language": "Java",
72
+ "license": "GPL-2.0-only",
73
+ "license_file": "LICENSES/OWASP-BENCHMARK-GPL-2.0.txt",
74
+ "license_file_sha256": "c03cea027b4b40e4402fabd08557736727ec3d5bc54ad64ab6472de432198cad",
75
+ "records": 22,
76
+ "split": "benchmarkjava_review"
77
+ },
78
  "OWASP Juice Shop": {
79
  "commit": "c9f99228d9d56afb5f5ca7925376292f7fa44b13",
80
  "languages": {
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- pretty_name: "Curated Secure-Coding Dataset: OWASP Juice Shop, OpenZeppelin, and WebGoat"
3
  language:
4
  - en
5
  - id
@@ -14,6 +14,7 @@ tags:
14
  - code-review
15
  - code-fix
16
  - owasp-juice-shop
 
17
  - openzeppelin
18
  - webgoat
19
  - smart-contracts
@@ -25,7 +26,7 @@ tags:
25
  ---
26
  # Curated Secure-Coding Dataset
27
 
28
- This release contains **91 records** from three separately licensed source subsets: **83 OWASP Juice Shop challenge records** (71 TypeScript and 12 YAML), **5 OpenZeppelin Contracts Solidity references**, and **3 Java code-review/reference records** selected from OWASP WebGoat.
29
 
30
  ## Files and splits
31
 
@@ -34,20 +35,22 @@ This release contains **91 records** from three separately licensed source subse
34
  | `data/challenge_fix.jsonl` | 83 | Candidate/fix challenge records from OWASP Juice Shop. |
35
  | `data/reference.jsonl` | 5 | Solidity library-component references from OpenZeppelin Contracts v5.7.0. |
36
  | `data/webgoat_review.jsonl` | 3 | Two intentionally vulnerable SQL-injection review examples and one parameterized-query reference from WebGoat. |
 
37
 
38
- These split names identify record types; they are **not** conventional train, validation, or test partitions. The WebGoat examples are not an upstream paired-fix benchmark. Two labels and their remediation guidance were written by the curator; they are identified as such in the record metadata.
39
 
40
  ## Sources and selection
41
 
42
  - **OWASP Juice Shop:** First-party TypeScript and YAML code-fix challenge material with accompanying metadata, pinned to [commit `c9f99228d9d56afb5f5ca7925376292f7fa44b13`](https://github.com/juice-shop/juice-shop/tree/c9f99228d9d56afb5f5ca7925376292f7fa44b13).
43
  - **OpenZeppelin Contracts:** Five Solidity components from [version v5.7.0](https://github.com/OpenZeppelin/openzeppelin-contracts/tree/v5.7.0).
44
  - **OWASP WebGoat:** Three complete Java source files with file-level `GPL-2.0-or-later` and WebGoat copyright notices, pinned to [commit `4e98f1cbbf896fdd06edcc9930515ebe0ade7c69`](https://github.com/WebGoat/WebGoat/tree/4e98f1cbbf896fdd06edcc9930515ebe0ade7c69). The associated upstream tests are linked and hashed in record provenance but are not copied into the data.
 
45
 
46
  See [data sources and provenance](DATA_SOURCES.md), [curation decisions](CURATION_DECISIONS.md), and [source audit and evidence](SOURCE_AUDIT.md). `MANIFEST.json` records the record totals and SHA-256 checksums for each JSONL subset. Each record also retains its source path/URL, revision, applicable license metadata, and source checksum.
47
 
48
  ## Record format and loading
49
 
50
- Each record contains `id`, `source`, `task_type`, `domain`, `language`, `instruction`, `input`, `output`, `split`, `labels_json`, and `provenance_json`. The labels and provenance fields preserve structured annotations and source-level licensing details. Instructions in this release are in Indonesian; code samples include TypeScript, YAML, Solidity, and Java.
51
 
52
  ```python
53
  from datasets import load_dataset
@@ -56,18 +59,24 @@ data = load_dataset("json", data_files={
56
  "challenge_fix": "data/challenge_fix.jsonl",
57
  "reference": "data/reference.jsonl",
58
  "webgoat_review": "data/webgoat_review.jsonl",
 
59
  })
60
  ```
61
 
 
 
 
 
62
  ## Label interpretation and limits
63
 
64
  - In the Juice Shop records, an upstream `*_correct` solution is marked correct for its specific challenge. Other alternatives are labeled as not marked correct by that challenge; they are not automatically vulnerable.
65
  - The WebGoat review labels are curator assessments of intentionally insecure training code or a narrow prepared-statement pattern. They are not presented as upstream fixed pairs or production incident evidence. The dynamic `ORDER BY` remediation is a curator-authored allowlist example; the `SqlInjectionLesson5a` source has no directly paired fixed version in the pinned revision.
 
66
  - Challenge labels describe their upstream exercises, not universal security guarantees. The OpenZeppelin records are library references, not safe/unsafe labels or application audits.
67
- - Related challenge records are not independent evaluation examples. The release does not provide conventional train/validation/test partitions.
68
 
69
  ## Licensing and reuse
70
 
71
- No single license is asserted for the entire repository. The selected Juice Shop and OpenZeppelin subsets are MIT-licensed and include their applicable license texts. The WebGoat code subset is licensed **GPL-2.0-or-later**; the selected source files retain their SPDX and copyright headers, and both the upstream license notice and the full GPLv2 text are included under `LICENSES/`. Preserve the applicable notices and follow the license attached to each subset before redistributing or adapting its code. Do not apply a new blanket license to all records.
72
 
73
- The inspected WebGoat license and selected file headers contain no AI/ML-specific grant or restriction. That absence is not a separate training-rights determination; the applicable GPL terms still govern redistribution of the copied WebGoat code. See the [source audit](SOURCE_AUDIT.md) for rights scope and the sources held out because their copied code was not cleared at file level.
 
1
  ---
2
+ pretty_name: "Curated Secure-Coding Dataset: OWASP Juice Shop, OpenZeppelin, WebGoat, and BenchmarkJava"
3
  language:
4
  - en
5
  - id
 
14
  - code-review
15
  - code-fix
16
  - owasp-juice-shop
17
+ - owasp-benchmark
18
  - openzeppelin
19
  - webgoat
20
  - smart-contracts
 
26
  ---
27
  # Curated Secure-Coding Dataset
28
 
29
+ This release contains **113 records** from four separately licensed source subsets: **83 OWASP Juice Shop challenge records** (71 TypeScript and 12 YAML), **5 OpenZeppelin Contracts Solidity references**, **3 Java code-review/reference records** from OWASP WebGoat, and **22 Java security benchmark test cases** from OWASP BenchmarkJava v1.2.
30
 
31
  ## Files and splits
32
 
 
35
  | `data/challenge_fix.jsonl` | 83 | Candidate/fix challenge records from OWASP Juice Shop. |
36
  | `data/reference.jsonl` | 5 | Solidity library-component references from OpenZeppelin Contracts v5.7.0. |
37
  | `data/webgoat_review.jsonl` | 3 | Two intentionally vulnerable SQL-injection review examples and one parameterized-query reference from WebGoat. |
38
+ | `data/benchmarkjava_review.jsonl` | 22 | One expected-vulnerable and one expected-not-vulnerable case in each of 11 OWASP BenchmarkJava v1.2 categories. |
39
 
40
+ These split names identify record types; they are **not** conventional train, validation, or test partitions. The WebGoat examples are not an upstream paired-fix benchmark. Two WebGoat labels and their remediation guidance were written by the curator. The BenchmarkJava examples are labeled test cases, not vulnerable/fixed source pairs.
41
 
42
  ## Sources and selection
43
 
44
  - **OWASP Juice Shop:** First-party TypeScript and YAML code-fix challenge material with accompanying metadata, pinned to [commit `c9f99228d9d56afb5f5ca7925376292f7fa44b13`](https://github.com/juice-shop/juice-shop/tree/c9f99228d9d56afb5f5ca7925376292f7fa44b13).
45
  - **OpenZeppelin Contracts:** Five Solidity components from [version v5.7.0](https://github.com/OpenZeppelin/openzeppelin-contracts/tree/v5.7.0).
46
  - **OWASP WebGoat:** Three complete Java source files with file-level `GPL-2.0-or-later` and WebGoat copyright notices, pinned to [commit `4e98f1cbbf896fdd06edcc9930515ebe0ade7c69`](https://github.com/WebGoat/WebGoat/tree/4e98f1cbbf896fdd06edcc9930515ebe0ade7c69). The associated upstream tests are linked and hashed in record provenance but are not copied into the data.
47
+ - **OWASP BenchmarkJava:** Twenty-two complete Java test-case files pinned to [commit `10dfcc54ad02dcfcb358b0ba4a0fef8c919a6d17`](https://github.com/OWASP-Benchmark/BenchmarkJava/tree/10dfcc54ad02dcfcb358b0ba4a0fef8c919a6d17). The expected-result labels are joined to `expectedresults-1.2.csv` at that same commit. Each selected file's own header states that it may be redistributed and modified under GNU GPL version 2; the full upstream license text is included.
48
 
49
  See [data sources and provenance](DATA_SOURCES.md), [curation decisions](CURATION_DECISIONS.md), and [source audit and evidence](SOURCE_AUDIT.md). `MANIFEST.json` records the record totals and SHA-256 checksums for each JSONL subset. Each record also retains its source path/URL, revision, applicable license metadata, and source checksum.
50
 
51
  ## Record format and loading
52
 
53
+ Each record contains `id`, `source`, `task_type`, `domain`, `language`, `instruction`, `input`, `output`, `split`, `labels_json`, and `provenance_json`. The labels and provenance fields preserve structured annotations and source-level licensing details. Existing instructions are in Indonesian; instructions for the BenchmarkJava records are in English. Code samples include TypeScript, YAML, Solidity, and Java.
54
 
55
  ```python
56
  from datasets import load_dataset
 
59
  "challenge_fix": "data/challenge_fix.jsonl",
60
  "reference": "data/reference.jsonl",
61
  "webgoat_review": "data/webgoat_review.jsonl",
62
+ "benchmarkjava_review": "data/benchmarkjava_review.jsonl",
63
  })
64
  ```
65
 
66
+ ## Rebuilding and tests
67
+
68
+ `python3 prepare_benchmarkjava.py --staging staging --licenses LICENSES` fetches only the pinned BenchmarkJava files and checks the source, label-file, and license hashes before writing the staging JSONL. After preparing the other source subsets, run `python3 build_release.py --staging staging --out data` to normalize the records and refresh the manifest. Run `python3 -m unittest discover -s tests` to check the selected cases, labels, provenance, license text, and manifest. The sample source code is not compiled or executed by these steps.
69
+
70
  ## Label interpretation and limits
71
 
72
  - In the Juice Shop records, an upstream `*_correct` solution is marked correct for its specific challenge. Other alternatives are labeled as not marked correct by that challenge; they are not automatically vulnerable.
73
  - The WebGoat review labels are curator assessments of intentionally insecure training code or a narrow prepared-statement pattern. They are not presented as upstream fixed pairs or production incident evidence. The dynamic `ORDER BY` remediation is a curator-authored allowlist example; the `SqlInjectionLesson5a` source has no directly paired fixed version in the pinned revision.
74
+ - BenchmarkJava labels are the benchmark's expected results for an individual test case and its named vulnerability category. A negative expected result is not a general claim that the full file or application is safe. The 22 examples are a small, deliberately balanced subset, not a representative sample of production software.
75
  - Challenge labels describe their upstream exercises, not universal security guarantees. The OpenZeppelin records are library references, not safe/unsafe labels or application audits.
76
+ - Related challenge or benchmark cases can be highly similar. Do not treat these records as independent evaluation examples or infer benchmark performance from this small subset. The release does not provide conventional train/validation/test partitions.
77
 
78
  ## Licensing and reuse
79
 
80
+ No single license is asserted for the entire repository. The selected Juice Shop and OpenZeppelin subsets are MIT-licensed and include their applicable license texts. The WebGoat code subset is licensed **GPL-2.0-or-later**. The BenchmarkJava subset is licensed **GPL-2.0-only** based on explicit notices in the selected source files. Both Java subsets preserve their original source headers, and the applicable upstream license texts are included under `LICENSES/`. Preserve the applicable notices and follow the license attached to each subset before redistributing or adapting its code. Do not apply a new blanket license to all records.
81
 
82
+ No AI/ML-specific grant or restriction was identified in the selected BenchmarkJava file headers or GPLv2 text. This is not a separate legal determination about a particular training workflow or downstream model distribution; GPL obligations continue to apply to copying, redistribution, and modification of the covered code. See the [source audit](SOURCE_AUDIT.md) for the evidence and scope.
SOURCE_AUDIT.md CHANGED
@@ -24,6 +24,14 @@ The new subset is pinned to [WebGoat commit `4e98f1cbbf896fdd06edcc9930515ebe0ad
24
 
25
  No AI/ML-specific grant or restriction was found in the inspected WebGoat license or selected source headers. This is not a separate determination of training rights. The copied code remains subject to the GPL terms, and no single license is applied to the entire dataset.
26
 
 
 
 
 
 
 
 
 
27
  ## Other candidates held out
28
 
29
  **Semgrep Rules Registry.** The attachment describes Semgrep's rules as LGPL-2.1. The official [Semgrep licensing documentation](https://docs.semgrep.dev/licensing) and [Rules License](https://semgrep.dev/legal/rules-license/) instead state that Semgrep-maintained rules in `semgrep-rules` are under Semgrep Rules License v1.0, available for internal business use, and may not be distributed. Semgrep's [2024 licensing update](https://semgrep.dev/blog/2024/important-updates-to-semgrep-oss/) describes the change. The inspected terms do not supply a separate AI/ML grant, and distribution is expressly barred, so no Semgrep-maintained rule or snippet was copied.
@@ -40,6 +48,12 @@ No AI/ML-specific grant or restriction was found in the inspected WebGoat licens
40
 
41
  **DiverseVul.** The official [repository](https://github.com/wagner-group/diversevul) does not provide a dataset-content license in the inspected files. The paper's [CC BY 4.0 notice](https://surrealyz.github.io/files/pubs/raid23-diversevul.pdf) applies to the paper; the opened sources do not establish that every extracted upstream code snippet is licensed the same way. No code rows were copied.
42
 
43
- **CVEfixes.** The official [Zenodo record](https://zenodo.org/records/13118970) declares CC BY 4.0 for the dataset deposit, while the [GitHub repository license](https://github.com/secureIT-project/CVEfixes/blob/main/LICENSE.txt) is MIT for the collection software/documentation. The dataset mines code from many project repositories, and the inspected materials do not establish the upstream license for every individual snippet. No code rows were copied pending per-record clearance.
 
 
 
 
 
 
44
 
45
  These exclusions are source-specific curation decisions, not claims that every listed source is unusable. Exact file-level rights and applicable notices would need to be established before any future code selection. No generated rewrite was used as a substitute for checking the license of copied code.
 
24
 
25
  No AI/ML-specific grant or restriction was found in the inspected WebGoat license or selected source headers. This is not a separate determination of training rights. The copied code remains subject to the GPL terms, and no single license is applied to the entire dataset.
26
 
27
+ ## OWASP BenchmarkJava v1.2
28
+
29
+ The subset is pinned to [BenchmarkJava commit `10dfcc54ad02dcfcb358b0ba4a0fef8c919a6d17`](https://github.com/OWASP-Benchmark/BenchmarkJava/tree/10dfcc54ad02dcfcb358b0ba4a0fef8c919a6d17). Unlike a wrapper-only license claim, each selected Java test file carries its own OWASP Benchmark header stating that the program may be redistributed and modified under GNU GPL version 2. For example, the selected [BenchmarkTest02613.java](https://raw.githubusercontent.com/OWASP-Benchmark/BenchmarkJava/10dfcc54ad02dcfcb358b0ba4a0fef8c919a6d17/src/main/java/org/owasp/benchmark/testcode/BenchmarkTest02613.java) contains that notice in its opening comment. The matching upstream [`LICENSE`](https://raw.githubusercontent.com/OWASP-Benchmark/BenchmarkJava/10dfcc54ad02dcfcb358b0ba4a0fef8c919a6d17/LICENSE) is included as [`LICENSES/OWASP-BENCHMARK-GPL-2.0.txt`](LICENSES/OWASP-BENCHMARK-GPL-2.0.txt), SHA-256 `c03cea027b4b40e4402fabd08557736727ec3d5bc54ad64ab6472de432198cad`.
30
+
31
+ The [official BenchmarkJava documentation](https://github.com/OWASP/www-project-benchmark/blob/master/tab_java_test_cases.md) describes test cases and expected results by category. The copied labels are joined by test name to the [pinned `expectedresults-1.2.csv`](https://raw.githubusercontent.com/OWASP-Benchmark/BenchmarkJava/10dfcc54ad02dcfcb358b0ba4a0fef8c919a6d17/expectedresults-1.2.csv), SHA-256 `1809f6a690c6cf7dd6685df6ebe2eef8fe3ca93d19a7ca0ce45987ca4f5d78e1`. The 22-file subset contains one expected-vulnerable and one expected-not-vulnerable case for each of 11 categories. Per-record provenance stores source URL/path, commit, code hash, license hash, expected-results URL/hash, category, expected status, and CWE. A negative result is scoped to that exact benchmark case/category, not a claim that the whole file is safe.
32
+
33
+ No AI/ML-specific grant or restriction was identified in the selected file headers or GPLv2 text. The code is explicitly redistributable under GPLv2 subject to its conditions; this does not decide how those terms apply to every model-training or downstream-distribution scenario. The source files are included verbatim and were not compiled or executed.
34
+
35
  ## Other candidates held out
36
 
37
  **Semgrep Rules Registry.** The attachment describes Semgrep's rules as LGPL-2.1. The official [Semgrep licensing documentation](https://docs.semgrep.dev/licensing) and [Rules License](https://semgrep.dev/legal/rules-license/) instead state that Semgrep-maintained rules in `semgrep-rules` are under Semgrep Rules License v1.0, available for internal business use, and may not be distributed. Semgrep's [2024 licensing update](https://semgrep.dev/blog/2024/important-updates-to-semgrep-oss/) describes the change. The inspected terms do not supply a separate AI/ML grant, and distribution is expressly barred, so no Semgrep-maintained rule or snippet was copied.
 
48
 
49
  **DiverseVul.** The official [repository](https://github.com/wagner-group/diversevul) does not provide a dataset-content license in the inspected files. The paper's [CC BY 4.0 notice](https://surrealyz.github.io/files/pubs/raid23-diversevul.pdf) applies to the paper; the opened sources do not establish that every extracted upstream code snippet is licensed the same way. No code rows were copied.
50
 
51
+ **CVEfixes.** The official [Zenodo record](https://zenodo.org/records/13118970) describes the dataset as CC BY 4.0, while the [GitHub MIT license](https://raw.githubusercontent.com/secureIT-project/CVEfixes/main/LICENSE.txt) covers the collection software. Its [data dictionary](https://raw.githubusercontent.com/secureIT-project/CVEfixes/main/Doc/DataDictionary.md) exposes code before/after changes from many upstream repositories but does not document a per-sample upstream license field. The dataset-level and wrapper licenses therefore do not establish redistribution rights for every embedded source sample. No CVEfixes code was copied.
52
+
53
+ **NIST Software Assurance Reference Dataset (SARD).** NIST's [dataset paper](https://pmc.ncbi.nlm.nih.gov/articles/PMC7339570/) says sample licenses vary and that many cases are public domain; it does not grant one license for all contributed code. An inspected [DSpace case](https://samate.nist.gov/SARD/test-cases/501362/versions/1.0.1) directs users to the upstream project's own LICENSE and NOTICE files. Public access and case metadata do not clear a sample for redistribution or AI/ML use. No SARD code was copied.
54
+
55
+ **PrimeVul.** Its [repository license](https://raw.githubusercontent.com/DLVulDet/PrimeVul/main/LICENSE) covers the repository's software, while the [README](https://raw.githubusercontent.com/DLVulDet/PrimeVul/main/README.md) describes vulnerable/benign snippets and copied project files from upstream repositories without a blanket sample-code license or per-sample license field. Provenance links alone do not establish redistribution rights. No PrimeVul code was copied.
56
+
57
+ **VulDeePecker Code Gadget Database.** The root [Apache-2.0 license](https://github.com/cgcl-codes/vuldeepecker/blob/master/LICENSE) does not by itself clear the C/C++ snippets; the [README](https://github.com/cgcl-codes/vuldeepecker) describes data sourced from NVD-associated projects and SARD but provides no common sample-code grant. No CGD code was copied.
58
 
59
  These exclusions are source-specific curation decisions, not claims that every listed source is unusable. Exact file-level rights and applicable notices would need to be established before any future code selection. No generated rewrite was used as a substitute for checking the license of copied code.
build_release.py CHANGED
@@ -8,10 +8,19 @@ import json
8
  from collections import Counter, defaultdict
9
  from pathlib import Path
10
 
 
 
 
 
 
 
 
 
11
  SOURCE_FILES = (
12
  "openzeppelin_solidity_references.jsonl",
13
  "juice_shop_codefix_pairs.jsonl",
14
  "webgoat_review_examples.jsonl",
 
15
  )
16
  FIELDS = (
17
  "id", "source", "task_type", "domain", "language", "instruction",
@@ -22,8 +31,14 @@ EXPECTED_SOURCE_COUNTS = {
22
  "OWASP Juice Shop": 83,
23
  "OpenZeppelin Contracts v5.7.0": 5,
24
  "OWASP WebGoat": 3,
 
 
 
 
 
 
 
25
  }
26
- EXPECTED_SPLIT_COUNTS = {"challenge_fix": 83, "reference": 5, "webgoat_review": 3}
27
  WEBGOAT_COMMIT = "4e98f1cbbf896fdd06edcc9930515ebe0ade7c69"
28
  WEBGOAT_LICENSE_SHA256 = "2fea812568866fdb6ff99671ad70465bfc25ab77f86129795d08d961c30d2ca1"
29
  WEBGOAT_LICENSE_TEXT_SHA256 = "aaf135472f81c5b4a0dca9367e5bb5e9750032b5bebe5442b36e4c0a47430df3"
@@ -64,6 +79,11 @@ def source_name(row: dict) -> str:
64
  return "OpenZeppelin Contracts v5.7.0"
65
  if row.get("source_repo") == "WebGoat/WebGoat" and row.get("source_commit") == WEBGOAT_COMMIT:
66
  return "OWASP WebGoat"
 
 
 
 
 
67
  raise ValueError(f"Unsupported source record: {row.get('id')}")
68
 
69
 
@@ -122,6 +142,39 @@ def validate_source_record(row: dict, source: str) -> None:
122
  raise ValueError(f"Unexpected WebGoat label: {row['id']}")
123
  if row["id"] == "webgoat-sqli-dynamic-order-by" and not output.get("fix_snippet"):
124
  raise ValueError("Dynamic ORDER BY sample lacks its curator-authored fix snippet")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
 
126
 
127
  def normalize(row: dict) -> dict:
@@ -164,6 +217,13 @@ def main() -> None:
164
  raise ValueError(f"Unexpected source counts; expected {EXPECTED_SOURCE_COUNTS}, got {dict(counts)}")
165
  if {row["id"] for row in normalized if row["source"] == "OWASP WebGoat"} != set(WEBGOAT_EXPECTED):
166
  raise ValueError("Unexpected WebGoat record set")
 
 
 
 
 
 
 
167
  for row in normalized:
168
  if set(row) != set(FIELDS):
169
  raise ValueError(f"Schema mismatch in {row['id']}")
@@ -224,6 +284,20 @@ def main() -> None:
224
  ],
225
  "ai_ml_terms_review": "No AI/ML-specific grant or restriction was located in the inspected upstream license and selected file headers; applicable GPL conditions remain in force.",
226
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  },
228
  "by_language": dict(sorted(languages.items())),
229
  "by_split": {split: len(rows) for split, rows in sorted(by_split.items())},
 
8
  from collections import Counter, defaultdict
9
  from pathlib import Path
10
 
11
+ from prepare_benchmarkjava import (
12
+ CASES as BENCHMARKJAVA_CASES,
13
+ COMMIT as BENCHMARKJAVA_COMMIT,
14
+ EXPECTED_RESULTS_SHA256 as BENCHMARKJAVA_RESULTS_SHA256,
15
+ LICENSE_SHA256 as BENCHMARKJAVA_LICENSE_SHA256,
16
+ check_sample_license,
17
+ )
18
+
19
  SOURCE_FILES = (
20
  "openzeppelin_solidity_references.jsonl",
21
  "juice_shop_codefix_pairs.jsonl",
22
  "webgoat_review_examples.jsonl",
23
+ "benchmarkjava_review_examples.jsonl",
24
  )
25
  FIELDS = (
26
  "id", "source", "task_type", "domain", "language", "instruction",
 
31
  "OWASP Juice Shop": 83,
32
  "OpenZeppelin Contracts v5.7.0": 5,
33
  "OWASP WebGoat": 3,
34
+ "OWASP BenchmarkJava v1.2": 22,
35
+ }
36
+ EXPECTED_SPLIT_COUNTS = {
37
+ "challenge_fix": 83,
38
+ "reference": 5,
39
+ "webgoat_review": 3,
40
+ "benchmarkjava_review": 22,
41
  }
 
42
  WEBGOAT_COMMIT = "4e98f1cbbf896fdd06edcc9930515ebe0ade7c69"
43
  WEBGOAT_LICENSE_SHA256 = "2fea812568866fdb6ff99671ad70465bfc25ab77f86129795d08d961c30d2ca1"
44
  WEBGOAT_LICENSE_TEXT_SHA256 = "aaf135472f81c5b4a0dca9367e5bb5e9750032b5bebe5442b36e4c0a47430df3"
 
79
  return "OpenZeppelin Contracts v5.7.0"
80
  if row.get("source_repo") == "WebGoat/WebGoat" and row.get("source_commit") == WEBGOAT_COMMIT:
81
  return "OWASP WebGoat"
82
+ if (
83
+ row.get("source_repo") == "OWASP-Benchmark/BenchmarkJava"
84
+ and row.get("source_commit") == BENCHMARKJAVA_COMMIT
85
+ ):
86
+ return "OWASP BenchmarkJava v1.2"
87
  raise ValueError(f"Unsupported source record: {row.get('id')}")
88
 
89
 
 
142
  raise ValueError(f"Unexpected WebGoat label: {row['id']}")
143
  if row["id"] == "webgoat-sqli-dynamic-order-by" and not output.get("fix_snippet"):
144
  raise ValueError("Dynamic ORDER BY sample lacks its curator-authored fix snippet")
145
+ elif source == "OWASP BenchmarkJava v1.2":
146
+ test_name = Path(row.get("source_file", "")).stem
147
+ spec = BENCHMARKJAVA_CASES.get(test_name)
148
+ if spec is None:
149
+ raise ValueError(f"Unexpected BenchmarkJava source file: {row.get('source_file')}")
150
+ category, expected_vulnerable, cwe, expected_hash = spec
151
+ actual_hash = hashlib.sha256(row["input"].encode("utf-8")).hexdigest()
152
+ if actual_hash != expected_hash or actual_hash != row.get("source_sha256"):
153
+ raise ValueError(f"BenchmarkJava source hash mismatch: {row['id']}")
154
+ if row.get("source_license") != "GPL-2.0-only" or row.get("source_spdx") != "GPL-2.0-only":
155
+ raise ValueError(f"Unexpected BenchmarkJava sample license: {row['id']}")
156
+ if row.get("source_license_file_sha256") != BENCHMARKJAVA_LICENSE_SHA256:
157
+ raise ValueError(f"BenchmarkJava GPLv2 license hash mismatch: {row['id']}")
158
+ if row.get("expected_results_sha256") != BENCHMARKJAVA_RESULTS_SHA256:
159
+ raise ValueError(f"BenchmarkJava expected-results hash mismatch: {row['id']}")
160
+ check_sample_license(row["input"], test_name)
161
+ if row.get("source_version") != "v1.2":
162
+ raise ValueError(f"Unexpected BenchmarkJava version: {row['id']}")
163
+ if row["split"] != "benchmarkjava_review" or row["language"] != "Java":
164
+ raise ValueError(f"Unexpected BenchmarkJava split/language: {row['id']}")
165
+ if row["id"] != f"owasp-benchmarkjava-{test_name.lower()}":
166
+ raise ValueError(f"BenchmarkJava record ID does not match source file: {row['id']}")
167
+ output = json.loads(row["output"])
168
+ expected_classification = (
169
+ "benchmark_expected_vulnerable" if expected_vulnerable else "benchmark_expected_not_vulnerable"
170
+ )
171
+ if (
172
+ output.get("classification") != expected_classification
173
+ or output.get("expected_vulnerability") is not expected_vulnerable
174
+ or output.get("benchmark_category") != category
175
+ or output.get("cwe") != f"CWE-{cwe}"
176
+ ):
177
+ raise ValueError(f"BenchmarkJava label mismatch: {row['id']}")
178
 
179
 
180
  def normalize(row: dict) -> dict:
 
217
  raise ValueError(f"Unexpected source counts; expected {EXPECTED_SOURCE_COUNTS}, got {dict(counts)}")
218
  if {row["id"] for row in normalized if row["source"] == "OWASP WebGoat"} != set(WEBGOAT_EXPECTED):
219
  raise ValueError("Unexpected WebGoat record set")
220
+ expected_benchmarkjava_ids = {
221
+ f"owasp-benchmarkjava-{test_name.lower()}" for test_name in BENCHMARKJAVA_CASES
222
+ }
223
+ if {
224
+ row["id"] for row in normalized if row["source"] == "OWASP BenchmarkJava v1.2"
225
+ } != expected_benchmarkjava_ids:
226
+ raise ValueError("Unexpected BenchmarkJava record set")
227
  for row in normalized:
228
  if set(row) != set(FIELDS):
229
  raise ValueError(f"Schema mismatch in {row['id']}")
 
284
  ],
285
  "ai_ml_terms_review": "No AI/ML-specific grant or restriction was located in the inspected upstream license and selected file headers; applicable GPL conditions remain in force.",
286
  },
287
+ "OWASP BenchmarkJava v1.2": {
288
+ "records": 22,
289
+ "commit": BENCHMARKJAVA_COMMIT,
290
+ "language": "Java",
291
+ "split": "benchmarkjava_review",
292
+ "license": "GPL-2.0-only",
293
+ "license_file": "LICENSES/OWASP-BENCHMARK-GPL-2.0.txt",
294
+ "license_file_sha256": BENCHMARKJAVA_LICENSE_SHA256,
295
+ "expected_results_file": "expectedresults-1.2.csv",
296
+ "expected_results_sha256": BENCHMARKJAVA_RESULTS_SHA256,
297
+ "labels": {"expected_vulnerable": 11, "expected_not_vulnerable": 11},
298
+ "categories": sorted({spec[0] for spec in BENCHMARKJAVA_CASES.values()}),
299
+ "ai_ml_terms_review": "No AI/ML-specific grant or restriction was located in the selected sample headers or GPL-2.0 text; applicable GPL conditions remain in force, and this is not a separate legal determination about training.",
300
+ },
301
  },
302
  "by_language": dict(sorted(languages.items())),
303
  "by_split": {split: len(rows) for split, rows in sorted(by_split.items())},
data/benchmarkjava_review.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
prepare_benchmarkjava.py ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Prepare a small, provenance-preserving OWASP BenchmarkJava v1.2 subset.
3
+
4
+ Only the 22 pinned Java test cases below are copied, and each file's own GPLv2
5
+ notice is checked before it is included. No source code is compiled or executed.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import argparse
10
+ import csv
11
+ import hashlib
12
+ import json
13
+ from pathlib import Path
14
+
15
+ REPO = "OWASP-Benchmark/BenchmarkJava"
16
+ COMMIT = "10dfcc54ad02dcfcb358b0ba4a0fef8c919a6d17"
17
+ VERSION = "v1.2"
18
+ RAW = f"https://raw.githubusercontent.com/{REPO}/{COMMIT}/"
19
+ LICENSE_PATH = "LICENSE"
20
+ LICENSE_SHA256 = "c03cea027b4b40e4402fabd08557736727ec3d5bc54ad64ab6472de432198cad"
21
+ EXPECTED_RESULTS_PATH = "expectedresults-1.2.csv"
22
+ EXPECTED_RESULTS_SHA256 = "1809f6a690c6cf7dd6685df6ebe2eef8fe3ca93d19a7ca0ce45987ca4f5d78e1"
23
+ EXPECTED_RESULTS_URL = RAW + EXPECTED_RESULTS_PATH
24
+ LICENSE_OUTPUT = "OWASP-BENCHMARK-GPL-2.0.txt"
25
+
26
+ # One expected-vulnerable and one expected-not-vulnerable case per v1.2 category.
27
+ # Source hashes pin the exact file contents in addition to the repository commit.
28
+ CASES = {
29
+ "BenchmarkTest02613": ("cmdi", True, "78", "ee0f005015b5a8afa0a4e7af66b603bee30d88caccf4b7bc7b3967bab7923621"),
30
+ "BenchmarkTest02714": ("cmdi", False, "78", "60fa63cb288b2c6103dd897272d7e918df2deced54974d2f59a94c39ad9c616c"),
31
+ "BenchmarkTest02663": ("crypto", True, "327", "011b93cc1dddbdc90c846d4b2ad77c9c87141a6f0cd09c8bb1233fb5fd91a17f"),
32
+ "BenchmarkTest02662": ("crypto", False, "327", "a5256d29eaa1f6038c56a944ed9d589e75fdd261661157f85d920298d123636d"),
33
+ "BenchmarkTest02677": ("hash", True, "328", "5a7f56ba0dab2c57068f7aca2a8d60d96fc7523293808b08d8e58044b41b5c90"),
34
+ "BenchmarkTest02678": ("hash", False, "328", "014c28bc6f5b933415766c634ab6d0cd2de58f90051e2053b623d32266900654"),
35
+ "BenchmarkTest02472": ("ldapi", True, "90", "0e701ce82d7093d2655debe295bf364e44bab6298fa8c1eedab3a99d4a82f798"),
36
+ "BenchmarkTest02572": ("ldapi", False, "90", "5d377a3d3ed7e15c55e93901f5c211b02831443a1401575f696db5066804315a"),
37
+ "BenchmarkTest02569": ("pathtraver", True, "22", "a3dfe0cf46f8aa6f7e69f71f1df7117fe58466b35eb931d3c728dca9f69dd023"),
38
+ "BenchmarkTest02669": ("pathtraver", False, "22", "2780eac2f1bf34aff43dca66e355917cbb823fa85595651b220c2ec1faebeddc"),
39
+ "BenchmarkTest02710": ("securecookie", True, "614", "f30e31957b18d18cec7de465260bdb7e786f0e96b2f7dc50beab07223fd2f96b"),
40
+ "BenchmarkTest02711": ("securecookie", False, "614", "65831fa3b1be50ad088972399c2ff54ef7fb84551c1c42c7a93545db00180b33"),
41
+ "BenchmarkTest02656": ("sqli", True, "89", "bc933bf5913303a3526cbeab9714139334cafa6eebb9f5437a7a93f64dedda7b"),
42
+ "BenchmarkTest02740": ("sqli", False, "89", "c6ae0ee13166dc706178828ae8d9bdbdd7461cedcd37b8f4ce35a764ac40aa59"),
43
+ "BenchmarkTest02624": ("trustbound", True, "501", "f13bd9caf25b98242c80e830a4004f7a84e6af98f52c5df5c9ed65e75ea73641"),
44
+ "BenchmarkTest02726": ("trustbound", False, "501", "4a3ed0b365445020289f03b038775cdb0af078dedc988736b56f8105b3592e4a"),
45
+ "BenchmarkTest02708": ("weakrand", True, "330", "1e8e464b8db864639164081de466b2ab72ebb42c39a661efc15f5e97e2706c70"),
46
+ "BenchmarkTest02721": ("weakrand", False, "330", "eddf1069da360f0a612164bed500520b271944188c0471792d784017263058ec"),
47
+ "BenchmarkTest02189": ("xpathi", True, "643", "7dad2393712ed1520ae660080c8e09461999eee81ebd6cf04a182d5674033bfe"),
48
+ "BenchmarkTest02457": ("xpathi", False, "643", "a46a076b44a193aebf8e413ddb82f3dc84437f65504aabfaca9acb70b842c7b3"),
49
+ "BenchmarkTest02608": ("xss", True, "79", "7999e879497173727b3fa2e95fa287d8261e5da421f8050b46bf28d195ef0ed3"),
50
+ "BenchmarkTest02712": ("xss", False, "79", "3de2c3635152c46252dbf1ad3bfd81f828b8a538f157198a09e921425a6dfa76"),
51
+ }
52
+
53
+
54
+ def sha256(data: bytes) -> str:
55
+ return hashlib.sha256(data).hexdigest()
56
+
57
+
58
+ def get_bytes(source_root: Path | None, path: str) -> bytes:
59
+ if source_root is not None:
60
+ return (source_root / path).read_bytes()
61
+ try:
62
+ import requests
63
+ except ImportError as exc: # pragma: no cover - environment dependent
64
+ raise RuntimeError("Install requests or pass --source-root with a pinned checkout") from exc
65
+ response = requests.get(RAW + path, timeout=45)
66
+ response.raise_for_status()
67
+ return response.content
68
+
69
+
70
+ def verify_hash(data: bytes, expected: str, what: str) -> None:
71
+ actual = sha256(data)
72
+ if actual != expected:
73
+ raise ValueError(f"{what} SHA-256 mismatch: expected {expected}, got {actual}")
74
+
75
+
76
+ def parse_expected_rows(csv_bytes: bytes) -> dict[str, dict[str, str]]:
77
+ text = csv_bytes.decode("utf-8-sig")
78
+ rows = []
79
+ for raw in csv.DictReader(text.splitlines()):
80
+ rows.append({(key or "").strip(): (value or "").strip() for key, value in raw.items()})
81
+ mapped = {row["# test name"]: row for row in rows if row.get("# test name")}
82
+ if len(rows) != 2740 or len(mapped) != 2740:
83
+ raise ValueError(f"Unexpected v1.2 expected-results inventory: {len(rows)} rows")
84
+ return mapped
85
+
86
+
87
+ def check_sample_license(text: str, test_name: str) -> None:
88
+ header = "\n".join(text.splitlines()[:20])
89
+ required = (
90
+ "part of the Open Web Application Security Project (OWASP) Benchmark Project",
91
+ "you can redistribute it and/or modify it under the terms",
92
+ "GNU General Public License",
93
+ "version 2",
94
+ )
95
+ missing = [fragment for fragment in required if fragment not in header]
96
+ if missing:
97
+ raise ValueError(f"{test_name} lacks required file-level GPLv2 language: {missing}")
98
+
99
+
100
+ def make_record(
101
+ test_name: str,
102
+ spec: tuple[str, bool, str, str],
103
+ code: bytes,
104
+ label_row: dict[str, str],
105
+ ) -> dict:
106
+ category, expected_vulnerable, cwe, expected_hash = spec
107
+ verify_hash(code, expected_hash, test_name)
108
+ source_text = code.decode("utf-8")
109
+ check_sample_license(source_text, test_name)
110
+ if label_row.get("category") != category:
111
+ raise ValueError(f"Category mismatch for {test_name}: {label_row.get('category')}")
112
+ if label_row.get("real vulnerability", "").lower() != str(expected_vulnerable).lower():
113
+ raise ValueError(f"Expected-result mismatch for {test_name}")
114
+ if label_row.get("cwe") != cwe:
115
+ raise ValueError(f"CWE mismatch for {test_name}")
116
+
117
+ relative_path = f"src/main/java/org/owasp/benchmark/testcode/{test_name}.java"
118
+ source_url = RAW + relative_path
119
+ expected_result_url = EXPECTED_RESULTS_URL
120
+ label = {
121
+ "classification": "benchmark_expected_vulnerable" if expected_vulnerable else "benchmark_expected_not_vulnerable",
122
+ "expected_vulnerability": expected_vulnerable,
123
+ "benchmark_category": category,
124
+ "cwe": f"CWE-{cwe}",
125
+ "label_basis": "OWASP BenchmarkJava v1.2 expectedresults-1.2.csv row for this exact test case.",
126
+ "label_scope": (
127
+ "The expected result applies to this benchmark test case and its designated category. "
128
+ "A false result means the benchmark does not expect this specific test case to trigger "
129
+ "the designated vulnerability; it is not a general claim that the file or application is safe."
130
+ ),
131
+ }
132
+ provenance = {
133
+ "source_repo": REPO,
134
+ "source_commit": COMMIT,
135
+ "source_version": VERSION,
136
+ "source_file": relative_path,
137
+ "source_url": source_url,
138
+ "source_sha256": sha256(code),
139
+ "source_license": "GPL-2.0-only",
140
+ "source_spdx": "GPL-2.0-only",
141
+ "source_license_basis": "The selected Java source file itself carries an explicit OWASP Benchmark GPL version 2 redistribution/modification notice.",
142
+ "source_license_file": f"LICENSES/{LICENSE_OUTPUT}",
143
+ "source_license_file_url": RAW + LICENSE_PATH,
144
+ "source_license_file_sha256": LICENSE_SHA256,
145
+ "expected_results_file": EXPECTED_RESULTS_PATH,
146
+ "expected_results_url": expected_result_url,
147
+ "expected_results_sha256": EXPECTED_RESULTS_SHA256,
148
+ "expected_result_category": category,
149
+ "expected_result_vulnerable": expected_vulnerable,
150
+ "expected_result_cwe": f"CWE-{cwe}",
151
+ "ai_ml_terms_review": (
152
+ "No AI/ML-specific grant or restriction was located in the selected source header or GPL-2.0 text. "
153
+ "The source permits copying and distribution subject to GPL-2.0 conditions; this is not a separate "
154
+ "legal determination about model training or downstream model distribution."
155
+ ),
156
+ "selection_policy": (
157
+ "A small balanced review subset: one expected-vulnerable and one expected-not-vulnerable case "
158
+ "from each of the 11 categories in the pinned v1.2 expected-results file. Cases were selected by "
159
+ "explicit ID and included only after verifying their own GPLv2 header and exact source hash."
160
+ ),
161
+ "curation_transformation": (
162
+ "The full Java source file is copied verbatim with its original GPLv2 header. Labels are copied "
163
+ "from the matching expected-results CSV fields; code is not modified, compiled, or executed."
164
+ ),
165
+ "curation_modified_at": "2026-11-24",
166
+ }
167
+ instruction = (
168
+ "Classify this OWASP BenchmarkJava v1.2 test case using the benchmark's expected-result label for its "
169
+ "category. Return the expected vulnerability status and CWE, and cite relevant code evidence. Interpret "
170
+ "a negative benchmark result only for the designated test case and category; do not claim that the whole "
171
+ "file or application is generally secure."
172
+ )
173
+ return {
174
+ "id": f"owasp-benchmarkjava-{test_name.lower()}",
175
+ "task_type": "classify_benchmark_security_case",
176
+ "domain": "web_application_security",
177
+ "language": "Java",
178
+ "instruction": instruction,
179
+ "input": source_text,
180
+ "output": json.dumps(label, ensure_ascii=False, sort_keys=True),
181
+ "split": "benchmarkjava_review",
182
+ **provenance,
183
+ }
184
+
185
+
186
+ def main() -> None:
187
+ parser = argparse.ArgumentParser()
188
+ parser.add_argument("--source-root", type=Path, help="Local checkout at the pinned commit; avoids network access")
189
+ parser.add_argument("--staging", type=Path, default=Path("staging"))
190
+ parser.add_argument("--licenses", type=Path, default=Path("LICENSES"))
191
+ args = parser.parse_args()
192
+
193
+ license_bytes = get_bytes(args.source_root, LICENSE_PATH)
194
+ verify_hash(license_bytes, LICENSE_SHA256, "BenchmarkJava GPLv2 license")
195
+ if b"GNU GENERAL PUBLIC LICENSE" not in license_bytes or b"Version 2, June 1991" not in license_bytes:
196
+ raise ValueError("The pinned upstream license is not the expected GPL version 2 text")
197
+
198
+ expected_bytes = get_bytes(args.source_root, EXPECTED_RESULTS_PATH)
199
+ verify_hash(expected_bytes, EXPECTED_RESULTS_SHA256, "BenchmarkJava v1.2 expected-results CSV")
200
+ expected_rows = parse_expected_rows(expected_bytes)
201
+
202
+ args.staging.mkdir(parents=True, exist_ok=True)
203
+ args.licenses.mkdir(parents=True, exist_ok=True)
204
+ (args.licenses / LICENSE_OUTPUT).write_bytes(license_bytes)
205
+
206
+ records = []
207
+ for test_name, spec in sorted(CASES.items()):
208
+ relative_path = f"src/main/java/org/owasp/benchmark/testcode/{test_name}.java"
209
+ code = get_bytes(args.source_root, relative_path)
210
+ if test_name not in expected_rows:
211
+ raise ValueError(f"No expected-results row for {test_name}")
212
+ records.append(make_record(test_name, spec, code, expected_rows[test_name]))
213
+
214
+ if len(records) != 22:
215
+ raise ValueError(f"Expected exactly 22 BenchmarkJava records, got {len(records)}")
216
+ output = args.staging / "benchmarkjava_review_examples.jsonl"
217
+ with output.open("w", encoding="utf-8", newline="\n") as handle:
218
+ for record in records:
219
+ handle.write(json.dumps(record, ensure_ascii=False, sort_keys=True) + "\n")
220
+
221
+ print(json.dumps({
222
+ "source_repo": REPO,
223
+ "source_commit": COMMIT,
224
+ "source_version": VERSION,
225
+ "records": len(records),
226
+ "vulnerable": sum(json.loads(row["output"])["expected_vulnerability"] for row in records),
227
+ "not_vulnerable": sum(not json.loads(row["output"])["expected_vulnerability"] for row in records),
228
+ "categories": sorted({CASES[name][0] for name in CASES}),
229
+ "staging_file": str(output),
230
+ "license_file": str(args.licenses / LICENSE_OUTPUT),
231
+ "source_hashes": {row["id"]: row["source_sha256"] for row in records},
232
+ }, ensure_ascii=False, indent=2))
233
+
234
+
235
+ if __name__ == "__main__":
236
+ main()
tests/test_benchmarkjava_subset.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import hashlib
4
+ import json
5
+ import unittest
6
+ from collections import Counter
7
+ from pathlib import Path
8
+
9
+ from prepare_benchmarkjava import (
10
+ CASES,
11
+ COMMIT,
12
+ EXPECTED_RESULTS_SHA256,
13
+ LICENSE_SHA256,
14
+ check_sample_license,
15
+ )
16
+
17
+ ROOT = Path(__file__).resolve().parents[1]
18
+ DATA_FILE = ROOT / "data" / "benchmarkjava_review.jsonl"
19
+ LICENSE_FILE = ROOT / "LICENSES" / "OWASP-BENCHMARK-GPL-2.0.txt"
20
+ MANIFEST_FILE = ROOT / "MANIFEST.json"
21
+ EXPECTED_SCHEMA = {
22
+ "id", "source", "task_type", "domain", "language", "instruction",
23
+ "input", "output", "split", "labels_json", "provenance_json",
24
+ }
25
+
26
+
27
+ def read_jsonl(path: Path) -> list[dict]:
28
+ with path.open(encoding="utf-8") as handle:
29
+ return [json.loads(line) for line in handle if line.strip()]
30
+
31
+
32
+ class BenchmarkJavaSubsetTests(unittest.TestCase):
33
+ @classmethod
34
+ def setUpClass(cls) -> None:
35
+ cls.records = read_jsonl(DATA_FILE)
36
+ cls.manifest = json.loads(MANIFEST_FILE.read_text(encoding="utf-8"))
37
+
38
+ def test_subset_is_exactly_22_cases_across_11_balanced_categories(self) -> None:
39
+ self.assertEqual(len(self.records), 22)
40
+ self.assertEqual(len({row["id"] for row in self.records}), 22)
41
+ labels = [json.loads(row["labels_json"]) for row in self.records]
42
+ self.assertEqual(sum(label["expected_vulnerability"] is True for label in labels), 11)
43
+ self.assertEqual(sum(label["expected_vulnerability"] is False for label in labels), 11)
44
+ category_labels: dict[str, Counter] = {}
45
+ for label in labels:
46
+ category_labels.setdefault(label["benchmark_category"], Counter())[label["expected_vulnerability"]] += 1
47
+ self.assertEqual(len(category_labels), 11)
48
+ for counts in category_labels.values():
49
+ self.assertEqual(counts[True], 1)
50
+ self.assertEqual(counts[False], 1)
51
+
52
+ def test_records_match_pinned_sources_labels_and_sample_level_license(self) -> None:
53
+ expected_ids = {f"owasp-benchmarkjava-{name.lower()}" for name in CASES}
54
+ self.assertEqual({row["id"] for row in self.records}, expected_ids)
55
+ for row in self.records:
56
+ self.assertEqual(set(row), EXPECTED_SCHEMA)
57
+ self.assertEqual(row["source"], "OWASP BenchmarkJava v1.2")
58
+ self.assertEqual(row["language"], "Java")
59
+ self.assertEqual(row["split"], "benchmarkjava_review")
60
+ provenance = json.loads(row["provenance_json"])
61
+ label = json.loads(row["labels_json"])
62
+ test_name = Path(provenance["source_file"]).stem
63
+ category, expected_vulnerable, cwe, expected_hash = CASES[test_name]
64
+ self.assertEqual(provenance["source_commit"], COMMIT)
65
+ self.assertEqual(provenance["source_version"], "v1.2")
66
+ self.assertEqual(provenance["source_sha256"], expected_hash)
67
+ self.assertEqual(hashlib.sha256(row["input"].encode("utf-8")).hexdigest(), expected_hash)
68
+ self.assertEqual(provenance["source_license"], "GPL-2.0-only")
69
+ self.assertEqual(provenance["source_spdx"], "GPL-2.0-only")
70
+ self.assertEqual(provenance["source_license_file_sha256"], LICENSE_SHA256)
71
+ self.assertEqual(provenance["expected_results_sha256"], EXPECTED_RESULTS_SHA256)
72
+ self.assertEqual(
73
+ provenance["source_url"],
74
+ f"https://raw.githubusercontent.com/OWASP-Benchmark/BenchmarkJava/{COMMIT}/{provenance['source_file']}",
75
+ )
76
+ self.assertEqual(
77
+ provenance["expected_results_url"],
78
+ f"https://raw.githubusercontent.com/OWASP-Benchmark/BenchmarkJava/{COMMIT}/expectedresults-1.2.csv",
79
+ )
80
+ self.assertEqual(provenance["expected_result_category"], category)
81
+ self.assertIs(provenance["expected_result_vulnerable"], expected_vulnerable)
82
+ self.assertEqual(provenance["expected_result_cwe"], f"CWE-{cwe}")
83
+ self.assertEqual(label["benchmark_category"], category)
84
+ self.assertIs(label["expected_vulnerability"], expected_vulnerable)
85
+ self.assertEqual(label["cwe"], f"CWE-{cwe}")
86
+ self.assertIn("benchmark_expected_", label["classification"])
87
+ check_sample_license(row["input"], test_name)
88
+
89
+ def test_gpl_text_is_present_and_exactly_matches_pinned_upstream(self) -> None:
90
+ license_bytes = LICENSE_FILE.read_bytes()
91
+ self.assertEqual(hashlib.sha256(license_bytes).hexdigest(), LICENSE_SHA256)
92
+ self.assertIn(b"GNU GENERAL PUBLIC LICENSE", license_bytes)
93
+ self.assertIn(b"Version 2, June 1991", license_bytes)
94
+
95
+ def test_manifest_counts_and_jsonl_checksum_match(self) -> None:
96
+ self.assertEqual(self.manifest["record_count"], 113)
97
+ self.assertEqual(
98
+ self.manifest["files"]["data/challenge_fix.jsonl"]["sha256"],
99
+ "67f75ff9743827aaf5c875edb94f6bb44430dfacf17f2f6ba44051016c583161",
100
+ )
101
+ self.assertEqual(
102
+ self.manifest["files"]["data/reference.jsonl"]["sha256"],
103
+ "a2dd20ab6e65cf09b6665df6c951d87772e005da78d8d0589f5f394480c340a8",
104
+ )
105
+ self.assertEqual(
106
+ self.manifest["files"]["data/webgoat_review.jsonl"]["sha256"],
107
+ "c27efd241c8b3dbeaf2427e26ea617829127e30478d99aecac2672988cd97812",
108
+ )
109
+ self.assertEqual(self.manifest["sources"]["OWASP BenchmarkJava v1.2"]["records"], 22)
110
+ self.assertEqual(self.manifest["by_split"]["benchmarkjava_review"], 22)
111
+ self.assertEqual(
112
+ self.manifest["sources"]["OWASP BenchmarkJava v1.2"]["license_file_sha256"],
113
+ LICENSE_SHA256,
114
+ )
115
+ file_info = self.manifest["files"]["data/benchmarkjava_review.jsonl"]
116
+ self.assertEqual(file_info["records"], 22)
117
+ self.assertEqual(file_info["sha256"], hashlib.sha256(DATA_FILE.read_bytes()).hexdigest())
118
+
119
+
120
+ if __name__ == "__main__":
121
+ unittest.main()