|
5 | 5 | dropdown for version is changes, the table will not update. For whatever reason, adding the toolbar fixes it. |
6 | 6 | --> |
7 | 7 | <div id="findingsToolbar" class="bs-table-custom-toolbar"> |
| 8 | + <b-button size="md" variant="outline-primary" |
| 9 | + v-b-modal.projectUploadVexModal |
| 10 | + v-permission:or="[PERMISSIONS.VIEW_VULNERABILITY, PERMISSIONS.VULNERABILITY_ANALYSIS]"> |
| 11 | + <span class="fa fa-upload"></span> {{ $t('message.apply_vex') }} |
| 12 | + </b-button> |
| 13 | + |
| 14 | + <b-button size="md" variant="outline-primary" |
| 15 | + @click="downloadVex()" |
| 16 | + v-permission:or="[PERMISSIONS.VIEW_VULNERABILITY, PERMISSIONS.VULNERABILITY_ANALYSIS]"> |
| 17 | + <span class="fa fa-download"></span> {{ $t('message.export_vex') }} |
| 18 | + </b-button> |
| 19 | + |
| 20 | + <!-- Future use when CSAF support is added |
| 21 | + <b-dropdown variant="outline-primary" v-permission:or="[PERMISSIONS.VIEW_VULNERABILITY, PERMISSIONS.VULNERABILITY_ANALYSIS]"> |
| 22 | + <template #button-content> |
| 23 | + <span class="fa fa-download"></span> {{ $t('message.export_vex') }} |
| 24 | + </template> |
| 25 | + <b-dropdown-item @click="downloadVex('cyclonedx')" href="#">CycloneDX</b-dropdown-item> |
| 26 | + <b-dropdown-item @click="downloadVex('csaf')" href="#">CSAF</b-dropdown-item> |
| 27 | + </b-dropdown> |
| 28 | + --> |
8 | 29 | <c-switch style="margin-left:1rem; margin-right:.5rem" id="showSuppressedFindings" color="primary" v-model="showSuppressedFindings" label v-bind="labelIcon" /><span class="text-muted">{{ $t('message.show_suppressed_findings') }}</span> |
9 | 30 | </div> |
10 | 31 |
|
|
15 | 36 | :options="options" |
16 | 37 | @on-load-success="tableLoaded"> |
17 | 38 | </bootstrap-table> |
| 39 | + |
| 40 | + <project-upload-vex-modal :uuid="this.uuid" /> |
18 | 41 | </div> |
19 | 42 | </template> |
20 | 43 |
|
|
26 | 49 | import i18n from "../../../i18n"; |
27 | 50 | import permissionsMixin from "../../../mixins/permissionsMixin"; |
28 | 51 | import BootstrapToggle from 'vue-bootstrap-toggle'; |
| 52 | + import ProjectUploadVexModal from "@/views/portfolio/projects/ProjectUploadVexModal"; |
29 | 53 |
|
30 | 54 | export default { |
31 | 55 | props: { |
32 | 56 | uuid: String |
33 | 57 | }, |
34 | | - mixins: [bootstrapTableMixin], |
| 58 | + mixins: [ |
| 59 | + bootstrapTableMixin, |
| 60 | + permissionsMixin |
| 61 | + ], |
35 | 62 | components: { |
36 | 63 | cSwitch, |
37 | | - BootstrapToggle |
| 64 | + BootstrapToggle, |
| 65 | + ProjectUploadVexModal |
38 | 66 | }, |
39 | 67 | data() { |
40 | 68 | return { |
|
156 | 184 | detailViewByClick: false, |
157 | 185 | detailFormatter: (index, row) => { |
158 | 186 | let projectUuid = this.uuid; |
| 187 | + console.log(row); |
159 | 188 | return this.vueFormatter({ |
160 | 189 | i18n, |
161 | 190 | template: ` |
|
225 | 254 | return { |
226 | 255 | auditTrail: null, |
227 | 256 | comment: null, |
228 | | - isSuppressed: null, |
| 257 | + isSuppressed: !!(row && row.analysis && row.analysis.isSuppressed), |
229 | 258 | finding: row, |
230 | 259 | analysisChoices: [ |
231 | 260 | { value: 'NOT_SET', text: this.$t('message.not_set') }, |
|
306 | 335 | } |
307 | 336 | if (Object.prototype.hasOwnProperty.call(analysis, "isSuppressed")) { |
308 | 337 | this.isSuppressed = analysis.isSuppressed; |
| 338 | + console.log("Setting isSuppressed to " + analysis.isSuppressed); |
309 | 339 | } else { |
310 | 340 | this.isSuppressed = false; |
| 341 | + console.log("Setting isSuppressed to false"); |
311 | 342 | } |
312 | 343 | }, |
313 | 344 | makeAnalysis: function() { |
|
365 | 396 | } |
366 | 397 | return url; |
367 | 398 | }, |
| 399 | + downloadVex: function (data) { |
| 400 | + let url = `${this.$api.BASE_URL}/${this.$api.URL_VEX}/cyclonedx/project/${this.uuid}`; |
| 401 | + this.axios.request({ |
| 402 | + responseType: 'blob', |
| 403 | + url: url, |
| 404 | + method: 'get', |
| 405 | + params: { |
| 406 | + download: 'true' |
| 407 | + } |
| 408 | + }).then((response) => { |
| 409 | + const url = window.URL.createObjectURL(new Blob([response.data])); |
| 410 | + const link = document.createElement('a'); |
| 411 | + link.href = url; |
| 412 | + let filename = "vex.json"; |
| 413 | + let disposition = response.headers["content-disposition"] |
| 414 | + if (disposition && disposition.indexOf('attachment') !== -1) { |
| 415 | + let filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/; |
| 416 | + let matches = filenameRegex.exec(disposition); |
| 417 | + if (matches != null && matches[1]) { |
| 418 | + filename = matches[1].replace(/['"]/g, ''); |
| 419 | + } |
| 420 | + } |
| 421 | + link.setAttribute('download', filename); |
| 422 | + document.body.appendChild(link); |
| 423 | + link.click(); |
| 424 | + }); |
| 425 | + }, |
368 | 426 | refreshTable: function() { |
369 | 427 | this.$refs.table.refresh({ |
370 | 428 | url: this.apiUrl(), |
|
0 commit comments