Skip to content

Commit 5ca18bc

Browse files
authored
Merge pull request #363 from nscuro/add-vdr-export
Add VDR export button to "Audit Vulnerabilities" tab
2 parents 1479dd4 + 952b6e3 commit 5ca18bc

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

src/i18n/locales/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,12 @@
229229
"inventory_with_vulnerabilities": "Inventory with Vulnerabilities",
230230
"vex_long_desc": "Vulnerability Exploitability Exchange (VEX)",
231231
"apply_vex": "Apply VEX",
232+
"apply_vex_tooltip": "Apply analyses from a Vulnerability Exploitability eXchange (VEX) document to this project.",
232233
"export_vex": "Export VEX",
234+
"export_vex_tooltip": "Export a Vulnerability Exploitability eXchange (VEX) document.",
233235
"upload_vex": "Upload VEX",
236+
"export_vdr": "Export VDR",
237+
"export_vdr_tooltip": "Export a Vulnerability Disclosure Report (VDR), as defined in NIST SP 800-161.",
234238
"project_reanalyze": "Reanalyze",
235239
"project_reanalyze_tooltip": "Runs configured analyzers to detect vulnerabilities in this project's components. Will use any cached results that haven't expired yet",
236240
"project_reanalyze_requested": "A Project Vulnerability Analysis has been requested. Project vulnerability data will be updated when the reanalysis task has completed.",

src/views/portfolio/projects/ProjectFindings.vue

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,26 @@
55
dropdown for version is changes, the table will not update. For whatever reason, adding the toolbar fixes it.
66
-->
77
<div id="findingsToolbar" class="bs-table-custom-toolbar">
8-
<b-button size="md" variant="outline-primary"
8+
<b-button id="apply-vex-button" size="md" variant="outline-primary"
99
v-b-modal.projectUploadVexModal
1010
v-permission:or="[PERMISSIONS.VIEW_VULNERABILITY, PERMISSIONS.VULNERABILITY_ANALYSIS]">
1111
<span class="fa fa-upload"></span> {{ $t('message.apply_vex') }}
1212
</b-button>
13+
<b-tooltip target="apply-vex-button" triggers="hover focus">{{ $t('message.apply_vex_tooltip') }}</b-tooltip>
1314

14-
<b-button size="md" variant="outline-primary"
15+
<b-button id="export-vex-button" size="md" variant="outline-primary"
1516
@click="downloadVex()"
1617
v-permission:or="[PERMISSIONS.VIEW_VULNERABILITY, PERMISSIONS.VULNERABILITY_ANALYSIS]">
1718
<span class="fa fa-download"></span> {{ $t('message.export_vex') }}
1819
</b-button>
20+
<b-tooltip target="export-vex-button" triggers="hover focus">{{ $t('message.export_vex_tooltip') }}</b-tooltip>
21+
22+
<b-button id="export-vdr-button" size="md" variant="outline-primary"
23+
@click="downloadVdr()"
24+
v-permission:or="[PERMISSIONS.VIEW_VULNERABILITY, PERMISSIONS.VULNERABILITY_ANALYSIS]">
25+
<span class="fa fa-download"></span> {{ $t('message.export_vdr') }}
26+
</b-button>
27+
<b-tooltip target="export-vdr-button" triggers="hover focus">{{ $t('message.export_vdr_tooltip') }}</b-tooltip>
1928

2029
<b-button id="reanalyze-button" size="md" variant="outline-primary"
2130
@click="reAnalyze()"
@@ -450,7 +459,7 @@
450459
}
451460
return url;
452461
},
453-
downloadVex: function (data) {
462+
downloadVex: function () {
454463
let url = `${this.$api.BASE_URL}/${this.$api.URL_VEX}/cyclonedx/project/${this.uuid}`;
455464
this.axios.request({
456465
responseType: 'blob',
@@ -477,6 +486,35 @@
477486
link.click();
478487
});
479488
},
489+
downloadVdr: function () {
490+
let url = `${this.$api.BASE_URL}/${this.$api.URL_BOM}/cyclonedx/project/${this.uuid}`;
491+
this.axios.request({
492+
responseType: 'blob',
493+
url: url,
494+
method: 'get',
495+
params: {
496+
format: 'json',
497+
variant: 'vdr',
498+
download: 'true'
499+
}
500+
}).then((response) => {
501+
const url = window.URL.createObjectURL(new Blob([response.data]));
502+
const link = document.createElement('a');
503+
link.href = url;
504+
let filename = "bom.json";
505+
let disposition = response.headers["content-disposition"]
506+
if (disposition && disposition.indexOf('attachment') !== -1) {
507+
let filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
508+
let matches = filenameRegex.exec(disposition);
509+
if (matches != null && matches[1]) {
510+
filename = matches[1].replace(/['"]/g, '');
511+
}
512+
}
513+
link.setAttribute('download', filename);
514+
document.body.appendChild(link);
515+
link.click();
516+
});
517+
},
480518
reAnalyze: function (data) {
481519
let analyzeUrl = `${this.$api.BASE_URL}/${this.$api.URL_FINDING}/project/${this.uuid}/analyze`
482520
this.axios.post(analyzeUrl).then((response) => {

0 commit comments

Comments
 (0)