Skip to content

Commit 38bfd4a

Browse files
committed
feat [task-05]: Display CWE annotation in web UI Reports view
1 parent b78c7f4 commit 38bfd4a

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

web/server/vue-cli/src/views/Reports.vue

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,17 @@
162162
:title="item.$detectionStatusTitle"
163163
/>
164164
</template>
165+
166+
<template #item.cwe="{ item }">
167+
<a
168+
v-if="item.cwe"
169+
:href="getCweUrl(item.cwe)"
170+
target="_blank"
171+
rel="noopener noreferrer"
172+
>
173+
{{ item.cwe }}
174+
</a>
175+
</template>
165176
</v-data-table>
166177
</pane>
167178
</splitpanes>
@@ -287,13 +298,20 @@ export default {
287298
value: "testcase",
288299
align: "center",
289300
sortable: true
301+
},
302+
{
303+
text: "CWE",
304+
value: "cwe",
305+
align: "center",
306+
sortable: true
290307
}
291308
],
292309
reports: [],
293310
sameReports: {},
294311
hasTimeStamp: true,
295312
hasTestCase : true,
296313
hasChronologicalOrder: true,
314+
hasCwe: true,
297315
selected: [],
298316
namespace: namespace,
299317
pagination: {
@@ -351,6 +369,11 @@ export default {
351369
!this.reportFilter.isUnique;
352370
}
353371
372+
if (header.value === "cwe") {
373+
return this.hasCwe &&
374+
!this.reportFilter.isUnique;
375+
}
376+
354377
return true;
355378
});
356379
},
@@ -380,7 +403,8 @@ export default {
380403
"sameReports": report.sameReports,
381404
"timestamp": report.annotations["timestamp"],
382405
"testcase": report.annotations["testcase"],
383-
"chronological_order": report.annotations["chronological_order"]
406+
"chronological_order": report.annotations["chronological_order"],
407+
"cwe": report.annotations["cwe"]
384408
};
385409
});
386410
}
@@ -406,6 +430,9 @@ export default {
406430
407431
this.hasChronologicalOrder =
408432
this.formattedReports.some(report => report["chronological_order"]);
433+
434+
this.hasCwe =
435+
this.formattedReports.some(report => report.cwe);
409436
}
410437
}
411438
},
@@ -464,6 +491,15 @@ export default {
464491
this.checkerDocDialog = true;
465492
},
466493
494+
getCweUrl(cwe) {
495+
// Extract CWE number from strings like "CWE-79"
496+
const match = cwe.match(/CWE-(\d+)/i);
497+
if (match) {
498+
return `https://cwe.mitre.org/data/definitions/${match[1]}.html`;
499+
}
500+
return null;
501+
},
502+
467503
updateUrl() {
468504
const defaultItemsPerPage = this.footerProps.itemsPerPageOptions[0];
469505
const itemsPerPage =

0 commit comments

Comments
 (0)