|
1 | 1 | <!-- SPDX-License-Identifier: MIT -->
|
2 | 2 | <template>
|
3 | 3 |
|
4 |
| - <JobReportToolBar |
5 |
| - :scan-type="scantype" |
6 |
| - :project-id="projectId" |
| 4 | + <JobReportToolBar |
7 | 5 | :job-u-u-i-d="jobUUID"
|
8 |
| - :traffic-light="report.trafficLight || ''" /> |
| 6 | + :project-id="projectId" |
| 7 | + :scan-type="scantype" |
| 8 | + :traffic-light="report.trafficLight || ''" |
| 9 | + /> |
9 | 10 |
|
10 |
| - <v-data-table |
11 |
| - :group-by=groupBy |
| 11 | + <v-data-table |
| 12 | + :group-by="groupBy" |
12 | 13 | :headers="headers"
|
13 |
| - :items="sortedFindings" |
14 | 14 | item-key="id"
|
| 15 | + :items="sortedFindings" |
15 | 16 | show-expand
|
16 | 17 | >
|
17 |
| - |
18 |
| - <template v-slot:group-header="{ item, columns, toggleGroup, isGroupOpen }"> |
| 18 | + |
| 19 | + <template #group-header="{ item, columns, toggleGroup, isGroupOpen }"> |
19 | 20 | <tr>
|
20 | 21 | <td :colspan="columns.length">
|
21 | 22 | <div class="d-flex align-center">
|
22 | 23 | <v-btn
|
23 |
| - :icon="isGroupOpen(item) ? '$expand' : '$next'" |
24 | 24 | color="medium-emphasis"
|
25 | 25 | density="comfortable"
|
| 26 | + :icon="isGroupOpen(item) ? '$expand' : '$next'" |
26 | 27 | size="small"
|
27 | 28 | variant="outlined"
|
28 | 29 | @click="toggleGroup(item)"
|
29 |
| - ></v-btn> |
| 30 | + /> |
30 | 31 |
|
31 |
| - <span class="ms-4"> |
| 32 | + <span class="ms-4"> |
32 | 33 | <div>
|
33 | 34 | <v-icon
|
34 |
| - :color="calculateColor(item.value)" |
35 |
| - :icon="calculateIcon(item.value)" |
36 |
| - left |
37 |
| - class="ma-2"> |
38 |
| - </v-icon> |
| 35 | + class="ma-2" |
| 36 | + :color="calculateColor(item.value)" |
| 37 | + :icon="calculateIcon(item.value)" |
| 38 | + left |
| 39 | + /> |
39 | 40 | <span>{{ item.value }}</span>
|
40 | 41 | </div>
|
41 | 42 | </span>
|
|
44 | 45 | </tr>
|
45 | 46 | </template>
|
46 | 47 |
|
47 |
| - <template v-slot:item.severity="{ value }"> |
48 |
| - <div> |
49 |
| - <v-icon |
50 |
| - :color="calculateColor(value)" |
51 |
| - :icon="calculateIcon(value)" |
52 |
| - left |
53 |
| - class="ma-2"> |
54 |
| - </v-icon> |
55 |
| - <span>{{ value }}</span> |
56 |
| - </div> |
| 48 | + <template #item.severity="{ value }"> |
| 49 | + <div> |
| 50 | + <v-icon |
| 51 | + class="ma-2" |
| 52 | + :color="calculateColor(value)" |
| 53 | + :icon="calculateIcon(value)" |
| 54 | + left |
| 55 | + /> |
| 56 | + <span>{{ value }}</span> |
| 57 | + </div> |
57 | 58 | </template>
|
58 | 59 |
|
59 |
| - <template v-slot:item.cweId="{ value }"> |
60 |
| - <div> |
61 |
| - <a :href="`https://cwe.mitre.org/data/definitions/${value}.html`">CWE-{{ value }}</a> |
62 |
| - </div> |
| 60 | + <template #item.cweId="{ value }"> |
| 61 | + <div> |
| 62 | + <a :href="`https://cwe.mitre.org/data/definitions/${value}.html`">CWE-{{ value }}</a> |
| 63 | + </div> |
63 | 64 | </template>
|
64 | 65 |
|
65 |
| - <template v-slot:item.data-table-expand="{ internalItem, isExpanded, toggleExpand }"> |
| 66 | + <template #item.data-table-expand="{ internalItem, isExpanded, toggleExpand }"> |
66 | 67 | <v-btn
|
67 | 68 | :append-icon="isExpanded(internalItem) ? 'mdi-chevron-up' : 'mdi-chevron-down'"
|
68 |
| - :text="isExpanded(internalItem) ? $t('REPORT_COLLAPS_FINDING') : $t('REPORT_SHOW_FINDING')" |
69 | 69 | class="text-none"
|
70 | 70 | color="primary"
|
| 71 | + :text="isExpanded(internalItem) ? $t('REPORT_COLLAPS_FINDING') : $t('REPORT_SHOW_FINDING')" |
71 | 72 | variant="text"
|
72 | 73 | @click="toggleExpand(internalItem)"
|
73 |
| - ></v-btn> |
| 74 | + /> |
74 | 75 | </template>
|
75 | 76 |
|
76 |
| - <template v-slot:expanded-row="{ columns, item }"> |
| 77 | + <template #expanded-row="{ columns, item }"> |
77 | 78 | <tr>
|
78 |
| - <td :colspan="columns.length" class="py-2"> |
79 |
| - <v-sheet v-if="item.type !== 'webScan'" rounded="lg" > |
80 |
| - <JobReportCodescanDetails |
81 |
| - :item="item"/> |
| 79 | + <td class="py-2" :colspan="columns.length"> |
| 80 | + <v-sheet v-if="item.type !== 'webScan'" rounded="lg"> |
| 81 | + <JobReportCodescanDetails |
| 82 | + :item="item" |
| 83 | + /> |
82 | 84 | </v-sheet>
|
83 |
| - <v-sheet v-else rounded="lg" > |
| 85 | + <v-sheet v-else rounded="lg"> |
84 | 86 | <JobReportWebscanDetails
|
85 |
| - :item="item"/> |
| 87 | + :item="item" |
| 88 | + /> |
86 | 89 | </v-sheet>
|
87 | 90 | </td>
|
88 | 91 | </tr>
|
|
92 | 95 | <script lang="ts">
|
93 | 96 | import { useRoute, useRouter } from 'vue-router'
|
94 | 97 | import { useI18n } from 'vue-i18n'
|
95 |
| - import { SecHubReport } from '@/generated-sources/openapi' |
| 98 | + import { SecHubFinding, SecHubReport } from '@/generated-sources/openapi' |
96 | 99 | import { useReportStore } from '@/stores/reportStore'
|
97 | 100 | import '@/styles/sechub.scss'
|
98 | 101 |
|
|
123 | 126 | projectId.value = route.params.id
|
124 | 127 | }
|
125 | 128 |
|
126 |
| - if ('jobId' in route.params){ |
| 129 | + if ('jobId' in route.params) { |
127 | 130 | jobUUID.value = route.params.jobId
|
128 | 131 | }
|
129 | 132 |
|
130 | 133 | const query = route.query.scantype as string
|
131 | 134 | const scantype = ref('')
|
132 | 135 | scantype.value = query
|
133 |
| - |
| 136 | + |
134 | 137 | const filteredFindings = computed(() => {
|
135 |
| - if (report.value.result?.findings){ |
| 138 | + if (report.value.result?.findings) { |
136 | 139 | return report.value.result?.findings.filter(finding => finding.type?.toLocaleLowerCase() === scantype.value) || []
|
| 140 | + } else { |
| 141 | + return report.value.result?.findings |
137 | 142 | }
|
138 | 143 | })
|
139 | 144 |
|
140 | 145 | const severityOrder = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW', 'INFO']
|
141 |
| - const sortedFindings = computed(() => { |
| 146 | + |
| 147 | + const sortedFindings = computed<SecHubFinding[]>(() => { |
142 | 148 | if (!filteredFindings.value) {
|
143 | 149 | return []
|
144 | 150 | }
|
145 |
| - return filteredFindings.value.sort((a, b) => { |
146 |
| - return severityOrder.indexOf(a.severity || '') - severityOrder.indexOf(b.severity || '') |
| 151 | + return [...filteredFindings.value].sort((a, b) => { |
| 152 | + return severityOrder.indexOf(a.severity || 'INFO') - severityOrder.indexOf(b.severity || 'INFO') |
147 | 153 | })
|
148 | 154 | })
|
149 | 155 |
|
150 | 156 | onMounted(async () => {
|
151 | 157 | const reportFromStore = store.getReportByUUID(jobUUID.value)
|
152 | 158 | if (!reportFromStore) {
|
153 |
| - router.push({ |
154 |
| - path: '/projects', |
155 |
| - }) |
156 |
| - } else { |
157 |
| - report.value = reportFromStore |
158 |
| - } |
159 |
| - }) |
160 |
| - |
161 |
| - function calculateIcon(severity :string){ |
| 159 | + router.push({ |
| 160 | + path: '/projects', |
| 161 | + }) |
| 162 | + } else { |
| 163 | + report.value = reportFromStore |
| 164 | + } |
| 165 | + }) |
| 166 | + |
| 167 | + function calculateIcon (severity :string) { |
162 | 168 | switch (severity) {
|
163 | 169 | case 'CRITICAL':
|
164 | 170 | case 'HIGH':
|
165 |
| - return 'mdi-alert-circle-outline'; |
| 171 | + return 'mdi-alert-circle-outline' |
166 | 172 | case 'MEDIUM':
|
167 |
| - return 'mdi-alert-circle-outline'; |
| 173 | + return 'mdi-alert-circle-outline' |
168 | 174 | case 'LOW':
|
169 | 175 | case 'INFO':
|
170 |
| - return 'mdi-information-outline'; |
| 176 | + return 'mdi-information-outline' |
171 | 177 | default:
|
172 |
| - return 'mdi-help-circle'; |
| 178 | + return 'mdi-help-circle' |
173 | 179 | }
|
174 | 180 | }
|
175 | 181 |
|
176 |
| - function calculateColor(severity: string){ |
| 182 | + function calculateColor (severity: string) { |
177 | 183 | switch (severity) {
|
178 | 184 | case 'CRITICAL':
|
179 | 185 | case 'HIGH':
|
180 |
| - return 'error'; |
| 186 | + return 'error' |
181 | 187 | case 'MEDIUM':
|
182 |
| - return 'warning'; |
| 188 | + return 'warning' |
183 | 189 | case 'LOW':
|
184 | 190 | return 'success'
|
185 | 191 | case 'INFO':
|
186 |
| - return 'primary'; |
| 192 | + return 'primary' |
187 | 193 | default:
|
188 |
| - return 'layer_01'; |
| 194 | + return 'layer_01' |
189 | 195 | }
|
190 | 196 | }
|
191 | 197 |
|
|
0 commit comments