fixing suggestions

This commit is contained in:
Ricardo 2026-02-01 07:31:21 +00:00
parent fe3550d4bb
commit 1ce7aae08e

View file

@ -59,7 +59,7 @@ export default {
return apiUrl;
},
endpointPage() {
const page = this.total - (this.options.limit ?? 5);
const page = Math.max(this.total - (this.options.limit ?? 5), 1);
let apiUrl = `${widgetApiEndpoints.cveVulnerabilities}`
+ `?resultsPerPage=${(this.options.limit ?? 5)}`
+ `&startIndex=${page}`
@ -116,7 +116,7 @@ export default {
data.vulnerabilities.forEach(({ cve = {} }) => {
cveList.push({
id: cve.id,
score: cve.metrics?.cvssMetricV2?.map(x => x.baseSeverity ?? 'UNSET') ?? 'UNSET',
score: this.parseScore(cve.metrics),
url: `https://nvd.nist.gov/vuln/detail/${cve.id}`,
description: this.parseDescriptions(cve.descriptions),
publishDate: cve.published,
@ -125,6 +125,17 @@ export default {
});
this.cveList = cveList;
},
parseScore(metrics = {}) {
if (!metrics || !metrics.cvssMetricV2) {
return 'Unset';
}
for (let i = 0; i < metrics.cvssMetricV2.length; i += 1) {
if (metrics.cvssMetricV2[i].baseSeverity !== undefined && metrics.cvssMetricV2[i].baseSeverity !== '') {
return metrics.cvssMetricV2[i].baseSeverity;
}
}
return 'Unset';
},
parseDescriptions(cveDescriptions = []) {
for (let i = 0; i < cveDescriptions.length; i += 1) {
if (cveDescriptions[i].lang === 'en') {