File size: 12,609 Bytes
28b9920
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b329c79
28b9920
 
 
 
 
 
b329c79
 
28b9920
b329c79
 
 
 
28b9920
 
 
b329c79
28b9920
 
b329c79
 
28b9920
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b329c79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28b9920
b329c79
 
 
 
 
 
 
 
28b9920
b329c79
 
 
 
 
 
 
 
28b9920
 
b329c79
 
 
28b9920
b329c79
28b9920
b329c79
 
 
 
28b9920
b329c79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28b9920
b329c79
 
 
 
 
 
 
 
 
 
 
 
 
 
28b9920
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
{
  "target_cwes": [
    "safe",
    "CWE-20",
    "CWE-22",
    "CWE-78",
    "CWE-79",
    "CWE-89",
    "CWE-94",
    "CWE-119",
    "CWE-125",
    "CWE-190",
    "CWE-200",
    "CWE-264",
    "CWE-269",
    "CWE-276",
    "CWE-284",
    "CWE-287",
    "CWE-310",
    "CWE-327",
    "CWE-330",
    "CWE-352",
    "CWE-362",
    "CWE-399",
    "CWE-401",
    "CWE-416",
    "CWE-434",
    "CWE-476",
    "CWE-502",
    "CWE-601",
    "CWE-787",
    "CWE-798",
    "CWE-918"
  ],
  "cwe_names": {
    "safe": "Safe Code",
    "CWE-20": "Improper Input Validation",
    "CWE-22": "Path Traversal",
    "CWE-78": "OS Command Injection",
    "CWE-79": "XSS",
    "CWE-89": "SQL Injection",
    "CWE-94": "Code Injection",
    "CWE-119": "Buffer Overflow",
    "CWE-125": "Out-of-bounds Read",
    "CWE-190": "Integer Overflow",
    "CWE-200": "Information Exposure",
    "CWE-264": "Permissions",
    "CWE-269": "Privilege Management",
    "CWE-276": "Incorrect Permissions",
    "CWE-284": "Access Control",
    "CWE-287": "Authentication",
    "CWE-310": "Crypto Issues",
    "CWE-327": "Broken Crypto",
    "CWE-330": "Insufficient Randomness",
    "CWE-352": "CSRF",
    "CWE-362": "Race Condition",
    "CWE-399": "Resource Management",
    "CWE-401": "Memory Leak",
    "CWE-416": "Use After Free",
    "CWE-434": "File Upload",
    "CWE-476": "NULL Pointer Deref",
    "CWE-502": "Insecure Deserialization",
    "CWE-601": "Open Redirect",
    "CWE-787": "Out-of-bounds Write",
    "CWE-798": "Hardcoded Credentials",
    "CWE-918": "SSRF"
  },
  "num_labels": 31,
  "cwe_to_owasp": {
    "CWE-22": "A01",
    "CWE-200": "A01",
    "CWE-264": "A01",
    "CWE-276": "A01",
    "CWE-284": "A01",
    "CWE-352": "A01",
    "CWE-601": "A01",
    "CWE-269": "A01",
    "CWE-310": "A02",
    "CWE-327": "A02",
    "CWE-330": "A02",
    "CWE-20": "A03",
    "CWE-78": "A03",
    "CWE-79": "A03",
    "CWE-89": "A03",
    "CWE-94": "A03",
    "CWE-119": "A03",
    "CWE-125": "A03",
    "CWE-190": "A03",
    "CWE-416": "A03",
    "CWE-476": "A03",
    "CWE-401": "A03",
    "CWE-787": "A03",
    "CWE-434": "A04",
    "CWE-362": "A04",
    "CWE-399": "A04",
    "CWE-287": "A07",
    "CWE-798": "A07",
    "CWE-502": "A08",
    "CWE-918": "A10"
  },
  "optimized_thresholds": {
    "safe": 0.5750000000000002,
    "CWE-20": 0.8750000000000003,
    "CWE-22": 0.7750000000000002,
    "CWE-78": 0.7500000000000002,
    "CWE-79": 0.5750000000000002,
    "CWE-89": 0.5250000000000001,
    "CWE-94": 0.7750000000000002,
    "CWE-119": 0.6000000000000002,
    "CWE-125": 0.7000000000000003,
    "CWE-190": 0.8750000000000003,
    "CWE-200": 0.7500000000000002,
    "CWE-264": 0.8250000000000003,
    "CWE-269": 0.5500000000000003,
    "CWE-276": 0.5,
    "CWE-284": 0.6000000000000002,
    "CWE-287": 0.4250000000000001,
    "CWE-310": 0.8000000000000003,
    "CWE-327": 0.5,
    "CWE-330": 0.7250000000000003,
    "CWE-352": 0.5,
    "CWE-362": 0.6250000000000002,
    "CWE-399": 0.9250000000000004,
    "CWE-401": 0.4250000000000001,
    "CWE-416": 0.6000000000000002,
    "CWE-434": 0.3000000000000001,
    "CWE-476": 0.8000000000000003,
    "CWE-502": 0.8750000000000003,
    "CWE-601": 0.47500000000000014,
    "CWE-787": 0.6000000000000002,
    "CWE-798": 0.25000000000000006,
    "CWE-918": 0.5
  },
  "temperature": 0.6163493394851685,
  "eval_metrics": {
    "eval_macro_f1": 0.47583485129569136,
    "eval_micro_f1": 0.9426379247351114,
    "eval_weighted_f1": 0.945370829629837,
    "eval_macro_precision": 0.4824943179864961,
    "eval_macro_recall": 0.5278332334756789,
    "eval_f1_safe": 0.9820306051177853,
    "eval_f1_CWE-20": 0.5721153846153846,
    "eval_f1_CWE-22": 0.5,
    "eval_f1_CWE-78": 0.0,
    "eval_f1_CWE-79": 0.5932203389830508,
    "eval_f1_CWE-89": 0.7916666666666666,
    "eval_f1_CWE-94": 0.7068273092369478,
    "eval_f1_CWE-119": 0.7054610564010743,
    "eval_f1_CWE-125": 0.5844748858447488,
    "eval_f1_CWE-190": 0.7704918032786885,
    "eval_f1_CWE-200": 0.7046632124352331,
    "eval_f1_CWE-264": 0.697986577181208,
    "eval_f1_CWE-269": 0.0,
    "eval_f1_CWE-276": 0.0,
    "eval_f1_CWE-284": 0.5128205128205128,
    "eval_f1_CWE-287": 0.25,
    "eval_f1_CWE-310": 0.5,
    "eval_f1_CWE-327": 0.0,
    "eval_f1_CWE-330": 0.5,
    "eval_f1_CWE-352": 0.0,
    "eval_f1_CWE-362": 0.7010309278350515,
    "eval_f1_CWE-399": 0.6783625730994152,
    "eval_f1_CWE-401": 0.5909090909090909,
    "eval_f1_CWE-416": 0.48484848484848486,
    "eval_f1_CWE-434": 0.0,
    "eval_f1_CWE-476": 0.5483870967741935,
    "eval_f1_CWE-502": 0.9,
    "eval_f1_CWE-601": 0.8571428571428571,
    "eval_f1_CWE-787": 0.47558386411889597,
    "eval_f1_CWE-798": 0.14285714285714285,
    "eval_f1_CWE-918": 0.0
  },
  "per_class_metrics": {
    "safe": {
      "f1": 0.9820306051177853,
      "precision": 0.976204001767342,
      "recall": 0.9879271798147556,
      "threshold": 0.5750000000000002,
      "support": 15655
    },
    "CWE-20": {
      "f1": 0.5721153846153846,
      "precision": 0.7,
      "recall": 0.483739837398374,
      "threshold": 0.8750000000000003,
      "support": 246
    },
    "CWE-22": {
      "f1": 0.5,
      "precision": 1.0,
      "recall": 0.3333333333333333,
      "threshold": 0.7750000000000002,
      "support": 6
    },
    "CWE-78": {
      "f1": 0.0,
      "precision": 0.0,
      "recall": 0.0,
      "threshold": 0.7500000000000002,
      "support": 7
    },
    "CWE-79": {
      "f1": 0.5932203389830508,
      "precision": 0.4861111111111111,
      "recall": 0.7608695652173914,
      "threshold": 0.5750000000000002,
      "support": 46
    },
    "CWE-89": {
      "f1": 0.7916666666666666,
      "precision": 0.6846846846846847,
      "recall": 0.9382716049382716,
      "threshold": 0.5250000000000001,
      "support": 81
    },
    "CWE-94": {
      "f1": 0.7068273092369478,
      "precision": 0.676923076923077,
      "recall": 0.7394957983193278,
      "threshold": 0.7750000000000002,
      "support": 119
    },
    "CWE-119": {
      "f1": 0.7054610564010743,
      "precision": 0.6127527216174183,
      "recall": 0.8312236286919831,
      "threshold": 0.6000000000000002,
      "support": 474
    },
    "CWE-125": {
      "f1": 0.5844748858447488,
      "precision": 0.5245901639344263,
      "recall": 0.6597938144329897,
      "threshold": 0.7000000000000003,
      "support": 97
    },
    "CWE-190": {
      "f1": 0.7704918032786885,
      "precision": 0.9038461538461539,
      "recall": 0.6714285714285714,
      "threshold": 0.8750000000000003,
      "support": 70
    },
    "CWE-200": {
      "f1": 0.7046632124352331,
      "precision": 0.6938775510204082,
      "recall": 0.7157894736842105,
      "threshold": 0.7500000000000002,
      "support": 95
    },
    "CWE-264": {
      "f1": 0.697986577181208,
      "precision": 0.7027027027027027,
      "recall": 0.6933333333333334,
      "threshold": 0.8250000000000003,
      "support": 75
    },
    "CWE-269": {
      "f1": 0.0,
      "precision": 0.0,
      "recall": 0.0,
      "threshold": 0.5500000000000003,
      "support": 2
    },
    "CWE-276": {
      "f1": 0.0,
      "precision": 0.0,
      "recall": 0.0,
      "threshold": 0.5,
      "support": 0
    },
    "CWE-284": {
      "f1": 0.5128205128205128,
      "precision": 0.43478260869565216,
      "recall": 0.625,
      "threshold": 0.6000000000000002,
      "support": 16
    },
    "CWE-287": {
      "f1": 0.25,
      "precision": 0.25,
      "recall": 0.25,
      "threshold": 0.4250000000000001,
      "support": 4
    },
    "CWE-310": {
      "f1": 0.5,
      "precision": 0.7142857142857143,
      "recall": 0.38461538461538464,
      "threshold": 0.8000000000000003,
      "support": 13
    },
    "CWE-327": {
      "f1": 0.0,
      "precision": 0.0,
      "recall": 0.0,
      "threshold": 0.5,
      "support": 2
    },
    "CWE-330": {
      "f1": 0.5,
      "precision": 0.6,
      "recall": 0.42857142857142855,
      "threshold": 0.7250000000000003,
      "support": 7
    },
    "CWE-352": {
      "f1": 0.0,
      "precision": 0.0,
      "recall": 0.0,
      "threshold": 0.5,
      "support": 1
    },
    "CWE-362": {
      "f1": 0.7010309278350515,
      "precision": 0.6538461538461539,
      "recall": 0.7555555555555555,
      "threshold": 0.6250000000000002,
      "support": 45
    },
    "CWE-399": {
      "f1": 0.6783625730994152,
      "precision": 0.7837837837837838,
      "recall": 0.5979381443298969,
      "threshold": 0.9250000000000004,
      "support": 97
    },
    "CWE-401": {
      "f1": 0.5909090909090909,
      "precision": 0.4482758620689655,
      "recall": 0.8666666666666667,
      "threshold": 0.4250000000000001,
      "support": 15
    },
    "CWE-416": {
      "f1": 0.48484848484848486,
      "precision": 0.4266666666666667,
      "recall": 0.5614035087719298,
      "threshold": 0.6000000000000002,
      "support": 57
    },
    "CWE-434": {
      "f1": 0.0,
      "precision": 0.0,
      "recall": 0.0,
      "threshold": 0.3000000000000001,
      "support": 0
    },
    "CWE-476": {
      "f1": 0.5483870967741935,
      "precision": 0.5862068965517241,
      "recall": 0.5151515151515151,
      "threshold": 0.8000000000000003,
      "support": 99
    },
    "CWE-502": {
      "f1": 0.9,
      "precision": 0.9,
      "recall": 0.9,
      "threshold": 0.8750000000000003,
      "support": 40
    },
    "CWE-601": {
      "f1": 0.8571428571428571,
      "precision": 0.75,
      "recall": 1.0,
      "threshold": 0.47500000000000014,
      "support": 3
    },
    "CWE-787": {
      "f1": 0.47558386411889597,
      "precision": 0.3708609271523179,
      "recall": 0.6627218934911243,
      "threshold": 0.6000000000000002,
      "support": 169
    },
    "CWE-798": {
      "f1": 0.14285714285714285,
      "precision": 0.07692307692307693,
      "recall": 1.0,
      "threshold": 0.25000000000000006,
      "support": 1
    },
    "CWE-918": {
      "f1": 0.0,
      "precision": 0.0,
      "recall": 0.0,
      "threshold": 0.5,
      "support": 0
    }
  },
  "classification_report": "              precision    recall  f1-score   support\n\n        safe     0.9762    0.9879    0.9820     15655\n      CWE-20     0.7000    0.4837    0.5721       246\n      CWE-22     1.0000    0.3333    0.5000         6\n      CWE-78     0.0000    0.0000    0.0000         7\n      CWE-79     0.4861    0.7609    0.5932        46\n      CWE-89     0.6847    0.9383    0.7917        81\n      CWE-94     0.6769    0.7395    0.7068       119\n     CWE-119     0.6128    0.8312    0.7055       474\n     CWE-125     0.5246    0.6598    0.5845        97\n     CWE-190     0.9038    0.6714    0.7705        70\n     CWE-200     0.6939    0.7158    0.7047        95\n     CWE-264     0.7027    0.6933    0.6980        75\n     CWE-269     0.0000    0.0000    0.0000         2\n     CWE-276     0.0000    0.0000    0.0000         0\n     CWE-284     0.4348    0.6250    0.5128        16\n     CWE-287     0.2500    0.2500    0.2500         4\n     CWE-310     0.7143    0.3846    0.5000        13\n     CWE-327     0.0000    0.0000    0.0000         2\n     CWE-330     0.6000    0.4286    0.5000         7\n     CWE-352     0.0000    0.0000    0.0000         1\n     CWE-362     0.6538    0.7556    0.7010        45\n     CWE-399     0.7838    0.5979    0.6784        97\n     CWE-401     0.4483    0.8667    0.5909        15\n     CWE-416     0.4267    0.5614    0.4848        57\n     CWE-434     0.0000    0.0000    0.0000         0\n     CWE-476     0.5862    0.5152    0.5484        99\n     CWE-502     0.9000    0.9000    0.9000        40\n     CWE-601     0.7500    1.0000    0.8571         3\n     CWE-787     0.3709    0.6627    0.4756       169\n     CWE-798     0.0769    1.0000    0.1429         1\n     CWE-918     0.0000    0.0000    0.0000         0\n\n   micro avg     0.9297    0.9560    0.9426     17542\n   macro avg     0.4825    0.5278    0.4758     17542\nweighted avg     0.9383    0.9560    0.9454     17542\n samples avg     0.9437    0.9560    0.9477     17542\n",
  "improvements": [
    "GraphCodeBERT-base (125M, 12 layers) vs CodeBERTa-small (83M, 6 layers)",
    "Asymmetric Loss (ASL) gamma_neg=4, gamma_pos=0, clip=0.05",
    "Two-phase training: 4 epochs frozen + up to 9 epochs full fine-tune",
    "Per-class threshold optimization on validation set",
    "Temperature scaling calibration (T=0.6163)",
    "Classification head bias initialization for imbalanced classes"
  ],
  "baseline_comparison": {
    "baseline_macro_f1": 0.1157,
    "new_macro_f1": 0.47583485129569136,
    "improvement_pct": 311.2660771786442
  }
}